May 5, 2014

Fast DNS Resolver

I called this "Fast DNS Resolver" not because it is fast (at execution). It is because it is short, and simply resolve the IP address (including reverse DNS) for a list FQDN for me (fast).

(If you are looking for really fast execution python script to resolve DNS, try this Asynchronous DNS Resolution)

#!/usr/bin/python
import os, sys, socket, argparse
name = ""
 
if __name__ == "__main__":
    parser = argparse.ArgumentParser(description='Fast DNS Resolver for domain list', version='%(prog)s 1.0')
    parser.add_argument('-R', dest='rdns', action='store_true', default=False, help='reverse dns')
    parser.add_argument('infile', nargs='+', type=str, help='list of input files')
    args = parser.parse_args()
 
    domains = []
    for f in args.infile:
        with open(f, 'rt') as data:
            for line in data.readlines():
                domains.append(line.strip())
    for domain in domains:
        try:
            host =  socket.gethostbyname(domain)
        except Exception, e:
            host = "-"
        finally:
            if args.rdns:
                try:
                    name, alias, addresslist = socket.gethostbyaddr(host)
                except Exception, e:
                    name = "-" # reverse dns name
                print "%s:%s:%s" %(domain, host, name)
            else:
                print "%s:%s" % (domain, host)

Feb 21, 2014

How to stop images from showing up in Android Gallery?

Application stores pictures at their respective photos, and we download "photos" and keep it for ourselves. But Android Gallery searches and indexes those pictures/photos on the entire SD automatic, and shows them in the Gallery. This can be an embarrass to us sometimes.

How can we stop the images at certain folders from showing up in Android Gallery?

If you like to hide an individual files from the gallery, just rename the file of the picture/photo with a . prefix.

If you would like to hide an entire directory that keeps yours images, just create an empty file with the file name .nomedia in the same folder.

Feb 14, 2014

Nokia 5110 LCD as Display for RPi

Successful on getting my Nokia5110 LCD works with my RPi. Here're the photos.
sudo ./pi_logo.py

sudo ./sunclock.py

sudo ./rpimonitor-load.py

sudo ./pi_logo100.py

Feb 8, 2014

Tetris in zsh

Add the following 3 lines into your .zshrc:
autoload -U tetris 
zle -N tetris 
bindkey  "^T" tetris  # Ctrl-t to play

Update on ScreenRC

Just update the ~/.screenrc today!

  • htop
  • F11 and F12 key binding
  • etc