PHPNews

Listing files using glob patterns in nodejs

In a previous post we saw how to monitor files changes in nodejs. This was required in a cron job to check which files were changed by the cron process. I also needed to search for files in a particular directory to check which files were newly created by the process. Although this is possible using the file-state-…

Continue reading »

Written by code-diesel - - Aggregated on Monday May 7, 2018


Monitoring file changes using NodeJS

During script runs – that change files – I frequently need to check which files have been modified by the scripts, especially in CRON automated tasks. This allows me to take appropriate actions depending on the file state change. The following post shows how we can monitor file state changes in nodejs. For this …

Continue reading »

Written by code-diesel - - Aggregated on Tuesday May 1, 2018


Fuzzy string matching in NodeJS

String matching is an integral part of any programming language. Many times, however, one requires to get a fuzzy instead of an exact match between strings. Usually in search applications the same word may be spelled differently – which if we do an exact math will return empty results. Fuzzy matching allows you to …

Continue reading »

Written by code-diesel - - Aggregated on Monday April 23, 2018


Creating custom stream filters in PHP

In this post we will see how to create a custom stream filter. Streams , first introduced in PHP 4.3, provide an abstration layer for file access. A number of different resources besides files – like network connections, compression protocols etc. can be regarded as “streams” of data which can be serially read and …

Continue reading »

Written by code-diesel - - Aggregated on Wednesday April 11, 2018


Five APIs All Developers Need to Know

Every day, dozens of developer tools get released online. Some new developers opt for doing all their work manually, while others choose to explore new tools. If you fall into the second category, then you need to start using APIs. The acronym stands for Application Programming Interface. In essence, it’s a programin…

Continue reading »

Written by code-diesel - - Aggregated on Friday April 6, 2018


Unpacking binary data in PHP

Working with binary files in PHP is rarely a requirement. However when needed the PHP ‘pack’ and ‘unpack’ functions can help you tremendously. To set the stage we will start with a programming problem, this will keep the discussion anchored to a relevant context. The problem is this : We want to write a function that …

Continue reading »

Written by code-diesel - - Aggregated on Wednesday April 4, 2018


How to calculate the size of a MySQL database

Many times we need to calculate the size of a MySQL database through code for purpose like database backup or to check how fast the database is growing for a certain application. The database size can be easily ascertained using phpmyadmin or other desktop tools, but that requires you to manually launch the tool and …

Continue reading »

Written by code-diesel - - Aggregated on Monday April 2, 2018


How to profile and debug MySQL queries for speed

Most MySQL applications need profiling for speed enhancements at one time or other. I’ve developed several web applications in the past wherein MySQL queries were a major bottleneck in the application performance. In the past however there were no easy tools to analyse SQL queries in a running application and we …

Continue reading »

Written by code-diesel - - Aggregated on Monday April 2, 2018


How to get list of MySQL user accounts

Many a time it is required to get a list of MySQL users on your system for auditing purpose or maintenance. The following few options will give you a quick way to do the same. SELECT user FROM mysql.user; This will generate the the following output depending on your system. +----------+ | User …

Continue reading »

Written by code-diesel - - Aggregated on Friday March 30, 2018


the design of the US Area Codes

Like the QWERTY keyboard design, which was originally designed so as to slow down typing and prevent key jams in the original typewriters; US Area codes also depend on the design of the then rotary telephones . On the rotary telephone dial, the digits are arranged in a circular layout so that a finger wheel may be …

Continue reading »

Written by code-diesel - - Aggregated on Thursday March 1, 2018


6 data visualization javascript libraries

A recent web visualization project forced me to explore some data visualization libraries for JavaScript. Below are a few I narrowed down during the development phase. Leaflet Leaflet is the leading open-source JavaScript library for mobile-friendly interactive maps. Weighing around 38 KB of JS, it has all …

Continue reading »

Written by code-diesel - - Aggregated on Tuesday February 6, 2018


Switching WordPress to HTTPS

Finally, after much deliberation, I decided to move my blog to https. For the past few months I had encountered articles pointing that google gives a higher ranking for sites served over https. I had decided against https as I was afraid it may slow down by blog. However, the following message from google forced me to …

Continue reading »

Written by code-diesel - - Aggregated on Thursday September 14, 2017


Querying MySQL in Go

Recently I’ve been experimenting with Go, mainly due to its excellent concurrency support. Being a web developer my natural instinct was to integrate it in existing projects – connecting with MySQL was a initial choice. The following is the Go code to connect with MySQL.   package main   import ( "fmt" …

Continue reading »

Written by code-diesel - - Aggregated on Monday June 19, 2017


Scraping Uber ride history data

This month I’ll complete 1 year riding with Uber. The process of booking a ride and the response time has been amazing. This post however is on a different matter. As a data aficionado I was curious on the various locations I had travelled over the year and the cost each month. Heading over to the Uber API docs was a …

Continue reading »

Written by code-diesel - - Aggregated on Tuesday April 11, 2017


Accessing Google Page Insights in PHP

Google Page Insights is a required tool to have when analyzing the speed and usability of your site. As you may know these metrics influence how google ranks your page in search results. If you frequently make changes to your web site designs than it becomes mandatory to check the metrics after each change to make …

Continue reading »

Written by code-diesel - - Aggregated on Tuesday March 21, 2017


Data Quality in web applications

There is nothing painful than having to rebuild a database after you find that the records in the database are corrupted. Data corruption in databases can take many forms – from allowing inaccurate data to be entered to data field truncation due to inadequate field length. This post gives an introduction to the data …

Continue reading »

Written by code-diesel - - Aggregated on Friday March 17, 2017