James John – Software Engineer

Archives

Fun!

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 […]

A Simple PHP Method to Insert data to Database Using Arrays

Write once, run everywhere. A friend has been struggling with this and I’m here to help 😀 . It’s been long and I decided to stretch out and use the opportunity to update my blog 😛 This is simple – view on Git USAGE:

Parsing and Fetching DNS Resolvers in /etc/resolv.conf Using Python

In an app development I needed to use my system resolvers which is different from my ISP default resolver, and Python keeps taking my ISP resolver. I decided to put up this simple function to get resolvers for me in /etc/resolv.conf, here is it: https://github.com/donjajo/py-world/blob/master/resolvconfReader.py I hope this helps

NGStatesLGA: Nigerian 36 States & Local Government Areas PHP Class

Recently a friend of mine complained about this – not seeing States and LGA online for developers’ use. I took it upon myself to make this available to us and make work easier for us. It took me 3hrs to arrange it, which my source was from this site, thanks to them 🙂 How to […]

Simple PHP Mail Function Using Swift Mailer

Using the built-in mail() function is PHP is pretty cool but not cool if you’re sending bulk or large mails and secondly it always head for the Spam box 😀 because not all needed headers are there. But using a mailer, I use Swift Mailer and it’s cool for me, get Swift Mailer and also […]

ISO Alpha-2 Country Codes and Names in PHP Array

I sweated out arranging this but I think it’s gonna be useful to someone someday 🙂 This array can by handy if you create a function to get countries an HTML Option element and adding your selected, e.g below: I hope this helps 🙂

Using PyMySQL as MySQL Driver for Python3

When it comes to DBMS am pretty cool with MySQL, having used it for long (since I started programming though) I haven’t gone for another or tested another yet, so each language I move into I try to see if it incorporates MySQL. Back there in PHP I was pretty cool with it, now in […]

How to Send POST Request Using urllib Only in Python3

Jumped into Python, having the urllib, urllib2 and urllib3 for Python3; Unfortunate for me as I’m using Python3 there is no urllib2 for it and POST requests in most places I’ve seen it used are used with urllib2. I had no choice than to deal with what I have, digging into Python documentary site I […]

Securing Your AJAX Call-up Pages – Advanced

AJAX is cool, makes it able for you to do multiple things on a page without reloading and creating extra pages but how secure can it be? You may wish to run some actions on an AJAX page and without security even GoogleBot in the act of crawling your page executes the action. AJAX requests […]

Getting MIME Types on Files & Buffers in Python

Through programming languages I’ve been through, finding MIME types is not that kinda easy, the language might not have a built-in function for that or if they have it won’t be that efficient, I can recall in PHP I’d activated the finfo module to find MIME type of existing files. Now in Python, we have […]