Saturday, December 9, 2017

Clojure has lesser typing error problems than the others well-known dynamic typing languages

Give these snippets a try.
// JS
function foo () {
# Ruby
def foo
; Clojure
(defn foo [] 
  (bar 1))

As you can see from the images below, Clojure doesn't allow you to refer to an undeclared symbol. I believe this takes away quite a bit of typing error issues.

Wednesday, July 12, 2017

Config number of file descriptors on Linux

Check file descriptor limit for a process. Vary depending on owner of the process
$ cat /proc/{process-id}/limits
Check current number of file descriptors of a process
$ sudo ls /proc/{process-id}/fd | wc -l
Set file descriptors limit for a user at /etc/security/limits.conf
*    soft nofile 64000
*    hard nofile 64000
root soft nofile 64000
root hard nofile 64000
Check system file descriptor limit
$ cat /proc/sys/fs/file-max
Check current number of system file descriptors
$ cat /proc/sys/fs/file-nr 


Thursday, September 1, 2016

[PostgreSQL] How to verify if replication catch up with master change

[Run on master] Check master location with
SELECT pg_current_xlog_location();
 [Run on replica] Check replica replayed location with
SELECT pg_last_xlog_replay_location();
[Run on master] Check replica status from master
SELECT client_addr, state, sent_location, write_location, flush_location, replay_location FROM pg_stat_replication;
*write, flush, replay are status of replica

[Run on replica] Check time from the latest reply
SELECT now() - pg_last_xact_replay_timestamp() AS replication_delay;

Wednesday, August 24, 2016

Shorthand for Git upstream (tracked) remote branch

It's @{u}.

For example, if you are on master branch, and master branch is tracked with origin/master. You can use git merge @{u} instead of git merge origin/master.


Clojure how to get JVM options from inside application

(.getInputArguments ( Credit:  How to get vm arguments from inside of java applic...