• Activity
  • Votes
  • Comments
  • New
  • All activity
  • Showing only topics with the tag "programming". Back to normal view
    1. Does emacs or vim have better support for PHP parameter hinting and intellisense?

      In the coming days, I'm going to give a serious try to one of these "super flexible but super high learning curve editors" called vim and emacs. I'm just unable to make up my mind on which one...

      In the coming days, I'm going to give a serious try to one of these "super flexible but super high learning curve editors" called vim and emacs. I'm just unable to make up my mind on which one though I've heard and read many good things about both.

      Right now I use Notepad++ and php type hints is one of the essential features I highly depend on. When I type a php function call such as strpos(, NPP shows the function signature in tooltip.

      From my initial research so far, I came to know that none of these editors provide this basic feature out of the box, at least not without some tweaks. For example, vim does provide something called "omni-box" when you press C-X C-O but even in that case, it won't show the popup/hint in case of a single completion option (for that you have to enable the menuone option as described here).

      The point is that I want to have a seamless and comfy PHP editing environment without spending a lot of time on these tweaks - I might invest some learning time if there is more utility in the long term, especially compared to what I currently get from Notepad++. How does emacs fare in this regard? Is there better PHP support than vim for that?

      Finally, I'm already ruling out the "heavy" IDEs like Eclipse PDT and PHP Storm as my laptop configuration isn't that high, it has an Intel Atom processor and just 2 GB RAM which crawls if I try to put too much load on it.

      8 votes
    2. 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
    3. 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
    4. 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
    5. 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
    6. 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
    7. FKCaps launches URSA keycaps for topre switches

      I'm not sure if anyone else here is into topre switch keyboards, but keycaps for topre are notoriously hard to find. Topre is niche within a niche, so options are limited. But for the last year or...

      I'm not sure if anyone else here is into topre switch keyboards, but keycaps for topre are notoriously hard to find. Topre is niche within a niche, so options are limited. But for the last year or so, FKCaps in collaboration with 23_Andreas have been working to launch keycaps in a new profile specifically designed for topre called URSA, compatible with HHKB, Leopold, and Realforce boards. They have now opened for pre-order, scheduled to be delivered in January 2025.

      I don't normally go for pre-orders or group buys, but I couldn't say no to this. The URSA profile and the caps themselves look great, and while I do enjoy the OEM keycaps on my HHKB, I also like having other options and trying new things. I've got a black HHKB Pro Hybrid Type-S, and I went with the black caps with legends. The mock-up image looks beautiful. I'm excited.

      If you're unfamiliar with the HHKB, or Happy Hacking Keyboard, it's a Unix-style board that has been around for 25 years, designed by a Japanese computer scientist because he wanted a more versatile board for programming and working in the command line on multiple operating systems. What makes the layout special, and why I enjoy it, is because the caps lock key has been replaced by a control key, and delete/backspace has been moved down a row for easier reach and to allow the tilde/backtick key to live on the top right. It's designed so you can easily reach everything from the homerow, and keys like the arrows, home, end, page up, page down are on a secondary layer accessed by the function key. Further, you can change board functionality through DIP switches on the bottom of the board. It's just so fun and pleasant to type on. Build quality is superb and these boards are known to stand the test of time.

      So if there are any other topre enthusiasts around here, I urge you to check URSA out. You can read more about the keycaps here.

      Your Happy Hacking Keyboard deserves some fresh caps (Verge)

      22 votes
    8. Chrome/Firefox Plugin to locally scrape data from multiple URLs

      As the title suggests, I am looking for a free chrome or firefox plugin that can locally scrape data from multiple URLs. To be a bit more precise, what I mean by it: A free chrome or firefox...

      As the title suggests, I am looking for a free chrome or firefox plugin that can locally scrape data from multiple URLs. To be a bit more precise, what I mean by it:

      • A free chrome or firefox plugin
      • Local scraping: it runs in the browser itself. No cloud computing or "credits" required to run
      • Scrape data: Collects predefined data from certain data fields within a website such as https://www.dastelefonbuch.de/Suche/Test
      • Infinite scroll: to load data that only loads once the browser scrolls down (kind of like in the page I linked above)

      I am not looking into programming my own scraper using python or anything similar. I have found plugins that "kind of" do what I am describing above, and about two weeks ago I found one that pretty much perfectly does what is described ("DataGrab"), but it starts asking to buy credits after running it a few times.

      My own list:

      • DataGrab: Excellent, apart from asking to buy credits after a while
      • SimpleScraper: Excellent, but asks to buy credits pretty much immediately
      • Easy Scraper: Works well for single pages, but no possibility to feed in multiple URLs to crawl
      • Instant Data Scraper: Works well for single pages and infinite scroll pages, but no possibility to feed in multiple URLs to crawl
      • "Data Scraper - Easy Web Scraping" / dataminer.io: Doesn't work well
      • Scrapy.org: Too much programming, but looks quite neat and well documented

      Any suggestions are highly welcome!

      Edit: A locally run executable or cmd-line based program would be fine too, as long as it just needs to be configured (e.g., creating a list of URLs stored in a .txt or .csv file) instead of coded (e.g., coding an infinite scroll function from scratch).

      8 votes