Get json results from mysql with python

This is just simple trick to retrieve data from mysql rows and turn into json. #!/usr/bin/env python import MySQLdb as mdb import sys con = mdb.connect(‘localhost’, ‘root’, ‘pass123’, ‘mydb1′, charset=’utf8’) cur = con.cursor(mdb.cursors.DictCursor) def get_post(): list = [] gw = {} cur.execute(“select * from tbl1_core”) rows = cur.fetchall() for i in rows: tes = [] # … Read more

Setup docker + jenkins + nginx

Let’s setup jenkins with docker with local url : jenkins.local First, add local url to /etc/hosts $ sudo echo -e “127.0.0.1\tjenkins.local” >> /etc/hosts Install docker and pull newest jenkins image $ sudo apt-get install docker.io $ sudo docker pull jenkins $ sudo docker run -itd –name jenkins –publish 8080:8080 –publish 50000:50000 jenkins Setup nginx $ … Read more

Save session rtorrent

Easy way to save session and load it again when you open up rtorrent, so you don’t have to start over again. Start rtorrent and set the session to some directory: $ rtorrent -s /tmp try to load it again: $ rtorrent -s /tmp

WordPress basic htaccess

I guess my wordpress turned into jeopardy because I didn’t realize I moved from nginx to apache, and apache needs .htaccess file for permalink my links in wp. This is just default htaccess config : # BEGIN WordPress <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^index\.php$ – [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule … Read more

Install different version of Python in linux

This is how I install python 2.7.13 without erasing the current version of python that exists inside the OS. It is an alternative install. $ wget https://www.python.org/ftp/python/2.7.13/Python-2.7.13.tar.xz $ tar xvf Python-2.7.13.tar.xz $ cd Python-2.7.13 $ ./configure $ make $ sudo make altinstall