Friday, November 27, 2015 doesn't save history in El Capitan and you are using RVM

The cause is described here
The fix is here

I copied the fix here just in case it's removed in the future

Another option is to create .bash_logout with a single line:


Wednesday, November 4, 2015

Setup Debian/Ubuntu apt package cache server with Ansible

Install elnappoo.apt-cacher-ng with Ansible Galaxy and then follow the instruction in the README tab or README in the github repository. Refer to the test.yml file as an example. If you cache server doesn't have ufw running, don't forget to set apt_cacher_ng_setup_ufw: False

Thursday, October 29, 2015

How to get calller function in Clojure

I posted this question on Clojurians slack channel.
What's clojure equivalent of ruby's `caller` method?
To put it another way, if a function is call from multiple places, at runtime, is there a way to print out caller for debugging purpose?
Thanks to Alex Miller. He answered
the Thread class has methods to inspect the stack
(Thread/dumpStack) will just dump that thread's stack to stderr
or (Thread/getStackTrace) gives you an array of StackTraceElement's that you can traverse and do whatever
Basically, we can just use Java's Thread class. To be more precise, getStackTrace is an instance method so we have to call it this way.
(.getStackTrace (Thread/currentThread))
We'll get back Java's array of StackTraceElement class.

You can copy and just use a function I wrote here

Tuesday, October 13, 2015

Convert FLV to MP4 with FFmpeg

Only for no AV recording
$ ffmpeg -i input.flv -c copy -copyts output.mp4
Tested on: OS X 10.11

Thursday, September 24, 2015

How to clear terminal screen in Clojure

Print some ANSI characters
(print (str (char 27) "[2J")) ; clear screen
(print (str (char 27) "[;H")) ; move cursor to the top left corner of the screen

Find out which process is using a particular port

I was never be able to remember options for netstat command. This option for lsof seems to be easier. Note that it requires a root access.
lsof -i :80
Change 80 to any port number you like.


Tuesday, August 25, 2015

On OS X, Java Control Panel and Terminal show different Java versions

That's because Java Control Panel shows version of JRE for normal Mac user, but command line on Terminal shows version of JDK. To update JDK version, need to download the full package from Oracle website.
Older JDK version won't be replace automatically to allow us to switch back if we want. So we have to manually remove it by following the instruction here