James John – Software Engineer

Archives

Fun!

How I Append Data Into JSON at Constant Time – PHP

php-jsondb is a light framework that provides an object and methods to perform CRUD operation on a JSON file, using a similar interface to that of RDBMS. In a situation where you are within a small scale project, you can use this library to read and store data in a JSON file, allowing cross-language support […]

How I Created AWS S3 Hierarchical File System Using PHP

Story cut short, I got a project to pull files from Amazon S3 and allow users to navigate into sub-directories knowing S3 is a Flat file system. I wrote some PHP functions to take the folders and make them array keys of an multidimensional array. The plan was the put the files into the arrays […]

WP Meta Query: Query to Strictly Get Not Existing Meta Key and Value

This is the second time I am working on a plugin project like this, first time I don’t remember the project so I couldn’t get back the code, had to rewrite it. This time I am making a post so I could come back to it in the future. So in this case, lets say […]

How to Escape MySQL REGEXP Strings in PHP

It’s usually weird with MySQL in everything I guess. Again, I ran into using Regex in MySQL using REGEXP which is pretty cool. MySQL escape strings with double backslash \\, unlike other programming languages using single slash. But the problem here is that the string to be escaped is in a PHP variable, how do […]

MySQL Default Column Value with Control Flow Operations

After a long while, I faced another problem which I solved and it feels awesome which I’m going to share right away! I must say, MySQL is awesome! The more you write MySQL the less you write PHP vice versa. So on this post I’m going to share how to input default column value with […]

PHP-JSONDB: A PHP Class that Reads JSON File as Database

It’s funny though. One noon at Cafe Neo in Sabo, Yaba, I was waiting on my friend Magnus while he met his friend. Sipping my coffee and using my laptop, with the bad network there, I couldn’t browse with my GLO SIM; I then decided to play around. I exported my MySQL Database as JSON […]

MySQL2MySQLi: A Small Program to Help Migrate from PHP mysql_* to mysqli_*

Stumbled upon a very monstrous PHP project, very old of course, the client complained that the web host refused to downgrade the server for them and this project doesn’t work anymore because it was written with bunch of mysql_* depreciated function. Now it was my job to start editing these files one after the other, […]

Python-SiDB: A Less Query SQLite Database Library

SiDB – A Simple Database Library for sqlite3, after writing similar thing for PHP MySQL, since I use Python too I decided to build for it too for my easier coding. After building and seeing how helpful it is, I decided to share. What Does SiDB do? In all, its for less SQL Queries, it […]

PHP SiDB – A Simple Database Framework

With the purpose of faster work, I wrote this framework last year and I recognized it would be useful for others. What does it do? SiDB makes it faster to Insert data to Database Retrieve data from Database Delete data from Database Run other queries All happens in just a line and no worries of […]

Recursively Delete Files Based on Time Old Using Python

As a system admin, was stuck one day looking for a way to delete old files and it brought me to this code. This short code will delete files recursively if directory provided as the argument, if it’s a file, it just deletes the file if it matches the given time frame So with the […]