Playing with Apache access_log

February 23rd, 2013

last 1000 entries
tail -1000 access_log

real time
tail -f access_log

IP address
tail -f access_log | awk '{print $1}'

User Agent
tail -f access_log | awk '{print $12}'
tail -f access_log | awk ‘{print $13}’

listing total access number of each unique ip address in last 20000 entries > ip.log
tail -20000 access_log | awk '{print $1}' | sort | uniq -c > ip.log

sort/rank them > ip.log.sorted
sort -t$'\t' -k2 -nr ip.log > ip.log.sorted

Auto Mount afp

July 16th, 2012


/- auto_afp

to /etc/auto_master


/Volumes/MyShare -fstype=afp afp://computername/sharename

to /etc/auto_afp

Adding all deleted file in git

July 7th, 2012

add only all deleted files

git ls-files --deleted | xargs git rm

add all including deleted files

git add -u

Encrypt and Decrypt tar file using OpenSSL with password

May 21st, 2012


tar cfvz directory | openssl des3 -salt > encrypted_directory.tar.gz


cat encrypted_directory.tar.gz | openssl des3 -d -salt |tar -xv

Export & Import whole collections in database MongoDB (dump and restore)

April 22nd, 2012


mongodump -v -h mongodb_host -d mongo_database_to_export

use -c to export collection only
2. you will see “dump” directory

ls dump

3. transfer dump directory to other server.

scp dump user@server:~

4. on the new server go to the directory where “dump” directory is located

cd ~



install kakasi on CentOS

April 22nd, 2012




tar xfvz kakasi-2.3.4.tar.gz


cd kakasi-2.3.4






make install

Moving git repository

December 30th, 2011

1. clone existing repo (accessible to server/specific user directory eg user@server:path_to/git_repository)

git clone –bare path/url/to/old/repository repository.git


scp -r /path_to/repository_name.git

2. Replace origin

git remote rm origin
git remote add origin

Set up git repository on local machine or on own server

December 30th, 2011

1. create a directory (accessible to server/specific user directory eg user@server:path_to/git_repository)

mkdir repository_name.git
cd repository_name.git


scp -r /path_to/repository_name.git

2. initialize as git repository

git init –bare

3. initialize git on the project

cd /path_to/project
git init

4. add remote

git remote add origin

5. git add commit push to repository

git add *
git commit -m “initial commit”
git push origin master

Keyboard Shortcut: Switch Between Windows under same Application using Japanese Keyboard in MacBook Pro

May 14th, 2011

When I was using MacBook with US keyboard, I like the keyboard shortcut to switch windows under same application ( ⌘ + `).
This shortcut didn’t work in my MacBook pro with Japanese Keyboard, until I found the way to change the shortcut key for it.

System Preferences → Keyboard