Posts

Showing posts from December, 2017

How to print contents of any database file

  1 import sqlite3 as lite   2 import sys   3   4 def print_db_content(database_to_read):   5         conn = lite.connect(database_to_read);   6         cur = conn.cursor()   7         # http://stackoverflow.com/questions/305378/list-of-tables-db-schema-dump-etc-using-the-python-sqlite3-api   8         # Below query is equivalent to typing .tables in sqlite command line   9         query = "SELECT name from sqlite_master where type = 'table'"  10         tables_list = list(cur.execute(query))  11         print tables_list  12         for item in tables_list:  13                 query = "SELECT * from '" + str(item[0]) + "'"  14                 print query  15                 cur = conn.cursor()  16                 data = list(cur.execute(query))  17                 for item1 in data:  18                         print item1  if __name__ == "__main__":          if (len(sys.argv)<0):                  print 'Usage: python

Working effectively with iTerm2

Mar 22, 2012 I have been using iTerm in daily work for almost a year now. Along the way, I learned a few handy settings tweaks and shortcut keys to boost my productivity in command-line environment. Install iTerm2 If you haven’t heard of iTerm , it’s a popular open source alternative to Mac OS X Terminal . Give it a try, download and install it from http://www.iterm2.com . Fine-Tune Settings Launch iTerm, open iTerm > Preferences or just Cmd + , . Open tab/pane with current working directory Under Profiles tab, go to General subtab, set Working Directory to “Reuse previous session’s directory” . Enable Meta key To enable Meta key for Bash readline editing e.g. Alt + b to move to previous word, under Profiles tab, go to Keys subtab, set Left option key acts as: to “+Esc” . Hotkey to toggle iTerm2 Under Keys tab, in Hotkey section, enable “Show/hide iTerm2 with a system-wide hotkey” and input your hotkey combination, e.g. I use C

Macbook Keyboard Tips for Windows users

Image
Original Post - https://www.macworld.co.uk/how-to/mac/keyboard-shortcuts-mac-users-copy-paste-option-shortcuts-3504584/ The three most important keys on your Mac can be found to the left and right of the spacebar (for right and left handed use). Unfortunately these three keys seem to cause more confusion than any others. Using the Option or Alt key on a Mac There is a great deal of confusion over what Apple referrs to as the Option key . If you'are using a UK keyboard chances are this is called the Alt key so it's no wonder most people don't know where it is. The Alt (aka Option) key can be found between Control and Command. It has an icon that looks like a slope and a dip with a line above it. Chances are the first time you hear mention of Option you are following a tutorial and trying to fix something on your Mac. The Alt key is the one you use if you wish to select a boot partition when starting the computer, you also press it when typing certain chara

Useful commands in Linux

View the job launched via process id xargs -0 < /proc/<pid>/cmdline Get the history of commands run from a user. grep - e "$pattern" / home /*/. bash_history How to find the files difference between two directories in linux and also ignoring the extension?   comm -13 <(find dir1 -type f -exec bash -c 'basename "${0%.*}"' {} \;     | sort) <(find dir2 -type f -exec bash -c 'basename "${0%.*}"' {} \;   | sort)   Type the above command in one line. comm -13 - will show the filenames unique to directory 2 comm -12 - will show all filenames common to both directories comm -23 - will show the filenames unique to directory 1. grep -F -x -v -f fileB fileA     Github change author name without edit   git rebase -i HEAD~4 -x "git commit --amend --author 'name <email>' --no-edit"      Command to count the file extension of a particular type. find . -type f | sed -n '