Keyboard shortcuts in interactive psql
psql = PostgreSQL interactive terminal
I’ve read this article (http://www.depesz.com/index.php/2008/03/30/keyboard-shortcuts-in-psql) today and decided to try on my MacBook.
Interestingly, all shortcuts were working fine in normal shell, but no action as soon as run “psql db_name” and go into interactive psql prompt.
After searching google, found out that psql on Mac OS was [...]
Mac OS X and colorized Terminal.app
I used to like colorized bash prompt on my Linux boxes, whereas default Terminal.app prompt will give you a bit boring colors.
You can change that with below snippet of code in your .bashrc
PS1=’\[\033[01;32m\]\u\[\033[01;34m\] @ \[\033[01;31m\]\h \[\033[00;34m\][ \[\033[01;34m\]\W \[\033[00;34m\]]\[\033[01;32m\] \[\033[00m\]‘
If you want to test above prompt without doing any changes to your current/default prompt, you can [...]
How to brute-force password protected zip file?
Imagine a situation when you need to unzip a password protected zip file. So, how do we do it?
Get a password file (file that will contain possible passwords one per line)
Write a bash script, total 8 lines of code
Run the script and wait… (depends on processing power, password file size, etc)
synack@deimos $ cat crack.sh#!/bin/bash# Author: [...]
PostgreSQL, copy from a file as non-superuser
testdb=> COPY weather FROM ‘/tmp/input_data.txt’;
ERROR: must be superuser to COPY to or from a file
HINT: Anyone can COPY to stdout or from stdin. psql’s \copy command also works for anyone.
So, how do we copy?
there is more than a way to skin a cat…
CREATE TABLE table1 (
code char(5),
name char(10)
);
synack@deimos db $ cat /tmp/input_data.txt
1,kamchi
2,mahabat
3,kamila
postgres@deimos [...]
How to unzip multiple password-protected zip files?
I’ve faced a situation where needed to unzip multiple password protected zip files and at the same time the correct password could be a word in upper case or in lower case (e.g. abcd1234, ABCD1234).
So, below is a script that can help you get things moving… But, for now it’s only doing validation for “successful [...]