James John – Software Engineer

Archives

Python

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

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

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

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

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

My First Newbie Python Program

Just started my Python class few days ago and it’s pretty cooler compared to PHP, I just got to notice that Python doesn’t like long codes it wants everything short and simple still compared to PHP. Stuffs like: PHP: Is shorter and simple in Python: Am not a pro yet, am just that newbie 😀 […]

Setting Python3 as your Default Shell Python in Ubuntu

Default Ubuntu Python package version is 2.7, while in my Python class I use 3.4 and everything I keep typing python3 whenever I want to run python. Want to turn 3.4 to your default? Easy, BASH made this available by providing space for aliases in the config. Aliases is not only for this function, I […]

[Python] How to install Django in Windows 7

[Python] How to install Django in Windows 7

Hi all, Python is a Linux based language and its more easy to use in Linux than Windows both the Django we are about to install. Now before installing your Django, make sure you already have Python 2.6.5 or higher installed in your system. Now download Django files here https://www.djangoproject.com/download/ The files are usually in […]