• Activity
  • Votes
  • Comments
  • New
  • All activity
  • Showing only topics with the tag "programming". Back to normal view
    1. JSON data format for MCQ data bank

      I'm creating a data bank of MCQ (Multi Choice Questions) and their answers so that an app can be built around it. Regarding the actual storage format, I have two ideas: An array of objects with...

      I'm creating a data bank of MCQ (Multi Choice Questions) and their answers so that an app can be built around it. Regarding the actual storage format, I have two ideas:

      1. An array of objects with keys (q for question, a for choice-a, etc.).
      2. An array of arrays.

      The first one is obviously more readable. Here is a brief sample of what I have so far:

      {
          "data": [
              {
                  "q": "What kind of language is Python?",
                  "a": "Compiled",
                  "b": "Interpreted",
                  "c": "Parsed",
                  "d": "Elaborated",
                  "r": "b"
              },
              {
                  "q": "Who invented Python?",
                  "a": "Rasmus Lerdorf",
                  "b": "Guido Van Rossum",
                  "c": "Bill Gates",
                  "d": "Linus Torvalds",
                  "r": "b"
              }
      	]
      }
      

      The app will read the q key to print the question, then present the four options (a, b, c and d). And the last key (r) will store the right answer. This is very much readable when viewed as a JSON file also. However, what I am thinking is that once the data-bank grows in size into hundreds/thousands of QA, a lot of space will be wasted by those keys (q,a,b,etc.) isn't it? In this case, an array like this is more efficient from storage perspective:

      {
          "data": [
              [
                  "What kind of language is Python?",
                  "Compiled",
                  "Interpreted",
                  "Parsed",
                  "Elaborated",
                  1
              ],
              [
                  "Who invented Python?",
                  "Rasmus Lerdorf",
                  "Guido Van Rossum",
                  "Bill Gates",
                  "Linus Torvalds",
                  1
              ]
      	]
      }
      

      In this case, each array will have 6 items viz. the question, four choices and finally the index of the correct choice (1==Interpreted, etc.).

      Which of these two formats is better? Feel free to suggest any third format which is even better than these two.

      2 votes
    2. Best news sources and blogs to keep you informed about IT and Software Development

      To be honest, I've bookmarked many but I'm too busy to actually read any of them! But from now onwards, I've decided to give them a try at least once each day, I just want to know from you which...

      To be honest, I've bookmarked many but I'm too busy to actually read any of them! But from now onwards, I've decided to give them a try at least once each day, I just want to know from you which ones are better sources of information and which aren't. Feel free to add more to this list. In no particular order:

      20 votes
    3. Database schema for an upcoming comment hosting system

      I'm working on a small and simple comment hosting platform in PHP (SQLITE database) to host comments for my static blog https://prahladyeri.github.io/. No login, sign-ups or third party OAuth,...

      I'm working on a small and simple comment hosting platform in PHP (SQLITE database) to host comments for my static blog https://prahladyeri.github.io/. No login, sign-ups or third party OAuth, just plain old Wordpress.org style commenting system.

      I have come up with the following DB schema so far to store the comments (comments table) and enable the administrator's dashboard authentication (users table). Can this be improved further?

      -- init.sql
      
      drop table if exists comments;
      drop table if exists posts;
      drop table if exists users;
      
      create table comments (
      	id integer primary key,
      	reply_to_id integer references comments (id),
      	post_id integer references posts (id),
      	message text,
      	name text,
      	email text,
      	website text,
      	ip text, -- $_SERVER['REMOTE_ADDR']
      	notify text default 'n',
      	status text default 'Approved', -- Approved/Spam
      	created_at datetime default (datetime(CURRENT_TIMESTAMP, 'localtime')),
      	modified_at datetime default (datetime(CURRENT_TIMESTAMP, 'localtime'))
      );
      
      create table posts (
      	id integer primary key,
      	user_id integer references users (id),
      	uri text -- /blog/2024/05/some-slug.html
      );
      
      create table users (
      	id integer primary key,
      	username text not null,
      	password text not null,
      	email text, -- can be null
      	name text not null,
      	website text, -- comments will be posted to this site
      	role text not null, -- Admin/Staff
      	created_at datetime default (datetime(CURRENT_TIMESTAMP, 'localtime')),
      	modified_at datetime default (datetime(CURRENT_TIMESTAMP, 'localtime')),
      	unique (username),
      	unique (email)
      );
      
      -- create default data
      -- create a default admin user who handles to dashboard
      insert into users(username,password, name, role, website)
      values("admin", "admin108", 'Admin', 'Admin', 'https://example.com/');
      
      14 votes
    4. How do you organize your Linux packages?

      Hello everyone. I am planning to get back into Linux development after working with Mac only for almost a decade. On Mac, one of the most important lessons that I learned was to always use...

      Hello everyone.

      I am planning to get back into Linux development after working with Mac only for almost a decade. On Mac, one of the most important lessons that I learned was to always use Homebrew. Using various package managers (e.g. Homebrew, NPM, Yarn, Pip, etc.) creates situations in which you don't know how to uninstall or upgrade certain pieces of software. Also, it's hard to generate a complete overview.

      How do you Linux folks handle this?

      Bonus question: How do you manage your dotfiles securely? I use Bitwarden, and it's a bit clunky.

      If that helps, I want to try Mint and always use Oh My ZSH!.

      6 votes
    5. Honest Question: Why did PHP remove dynamic properties in 8.x?

      I understand PHP has had many criticisms in the past but I'm not sure the existence of dynamic properties of instantiated objects was ever one of them. In fact, dynamic properties are pretty much...

      I understand PHP has had many criticisms in the past but I'm not sure the existence of dynamic properties of instantiated objects was ever one of them. In fact, dynamic properties are pretty much the hallmark of most interpreted or dynamic programming languages. Python allows it all the time and so do many others like Ruby, Perl, etc.

      I don't know what PHP developers achieved by removing dynamic properties feature from the language but one thing that resulted out of this is that many applications based on widely used veteran PHP frameworks (such as CodeIgniter and CakePHP) came to a halt all of a sudden due to an error like this after upgrading to PHP 8:

      A PHP Error was encountered
      Severity: 8192
      Message: Creation of dynamic property CI_URI::$config is deprecated
      Filename: core/URI.php
      Line Number: 102
      Backtrace:
      File: C:\xampp\htdocs\inv_perpus\index.php Line: 288 Function: require_once
      

      The influence of Corporate IT in various open source foundations is pretty well known and also well known is the extent to which corporate greed goes to achieve its interests and objectives across the world. The only way to assuage this uncomfortable thought (at least in this particular case) is to ask if there was any technical merit at all in removing dynamic properties feature from a dynamic programming language?

      I for one couldn't find any such merit here.

      12 votes