Jim Cheung

Thursday, March 03, 2016

because of Direct your gopher client to gopher://gopher.metafilter.com, I installed lynx-cur to test it out (I'm not that old and didn't use gopher before).

I tried couple more text-based web browsers: elinks and w3m. I tried to find one that could send url to firefox, found only w3m can easily do it:

# add to ~/.w3m/config or /etc/w3m/config
extbrowser firefox &

(on OS X, can use extbrowser open)

then use M to open current url in firefox.

some basic usage of w3m (hit H for full list):

| q       | exit                             |
| space   | next page                        |
| b       | previouse page                   |
| esc-l   | link list                        |
| s       | go back to buffered history page |
| o       | open option panel                |
| T       | copy current page in a new tag   |
| { and } | previous / next tab              |
| esc-t   | tab list                         |
| ctrl-t  | open link in new tab             |
| R       | refresh current page             |
| U       | type in new url                  |
| L       | list link in current page        |
| B       | go back                          |
| ctrl-q  | close current page               |
| ctrl-h  | view history                     |
| ctrl-k  | view cookies                     |
| esc-a   | add bookmark                     |
| esc-b   | bookmarks                        |

gnome-terminal can't display images while xterm can.

Friday, March 04, 2016

from the discussion thread of curl vs Wget, learned a couple tricks:

to make curl redirect by default:

echo "-L" >> ~/.curlrc

mirroring a web documentation site:

wget -r -l5 -k -np -p https://docs

from eshell and why can't I convert to you, I learned:

in eshell, you can cd to a remote server:

cd /ssh:machine:/home/

M-& to perform async shell command.

and multi-term package, but I didn't find it useful and it broke some color themes.

back to clojure, when doing cider-jack-in, can connect the nrepl session by:

lein repl :connect localhost:port

useful when working on tmux.

Monday, March 07, 2016

playing logo programming language with clojure-turtle.

when searching about mysql HA (again), MySQL Router is one thing that I didn't notice before.

and MariaDB 10.1 looks very sexy, here's a guide to set it up on digitalocean.

I want a tool that could log what processes are running on the server, not monitoring a specific process, but seems not easy to find one. until I saw cpustat, take a look at the limitation section will know why there're no tools for this job.

Tuesday, March 08, 2016

lein trampoline run will not start an extra jvm process, so it's lightweight than lein run.

I learned it from Clojure Reactive Programming, I just started reading it, quite good actually.

Friday, March 11, 2016

recently switched back from vi mode to default on bash, because I'm more comforable with emacs key bindings now. one thing bothers me is that the reverse search on history, I can't forward a search (ctrl-s doesn't work).

the answer in here explains why ctrl-s is not working:

historically (and still today, in some terminals), Ctrl-S pauses the output, and Ctrl-Q resumes it.

stty -ixon will make it work again. (type stty -a and check currently is ixon or -ixon)

ixon is enable XON/XOFF flow control

answers from here has another 2 excellent tricks:

"\e[A": history-search-backward
"\e[B": history-search-forward

add above 2 lines to ~/.inputrc, then when you type a command and press up or down arrow key, will search history starting with that.

the other one is use # to tag a command:

command #tag1 #tag2

then search with the tag:

ctrl+r #tag1

I'm checking the whether keepalived could be used to provide HA for a nfs server, this gist has the config as a reference: nfs ha keepalived configure file

checking the seesaw library, playing with Seesaw REPL Tutorial. It's so good, why not everyone is using clojure?

JUXT Radar and The Clojure Toolbox are great resources for clojurian.

looking forward for this book: Optimizing Java : Practical Techniques for Improved Performance Tuning by Benjamin Evans (Java in a Nutshell, Well-Grounded Java Developer) and James Gough

one big news from java community is JEP 286: Local-Variable Type Inference, I found it's funny on the other hand php community is proposing depreciate it.

Saturday, March 12, 2016

clj-ns-browser is an example of using seesaw.

about transducer:

(->> (range 10)
     (map inc)
     (filter even?)
;; (2 4 6 8 10)

here 3 sequences were created (range, map and filter), the extra unnecessary allocation could be avoided by transducer:

(def xform
  (comp (map inc)
        (filter even?)))

(->> (range 10)
     (sequence xform)

same thing applies to core.async:

(def result (chan 10))
(def transformed
  (->> result
       (map< inc)
       (filter< even?)
       (into [])))

;; using transducer
(def transformed
  (->> (pipe result (chan 10 xform))
       (into [])))

gonna train the slack bot using Markov Chain Carin Meier wrote a tutorial using Markov Chain

also found another simple one clojure-markov-chains, run with

java -cp clojure-1.8.0.jar clojure.main markov.clj

Tuesday, March 15, 2016

fed few text files to train the markov chains bot, the result is not that good. I think a bot that remembers what I told him may be more useful.

read a little bit Mastering Clojure Macros, can't wrap my head around macros, try again later.

Wednesday, March 16, 2016

finally get the Emacs daemon running on my mac, require a shell script though:



if ! $(ps -e|grep -q "[E]macs.*--daemon")
  $EMACS --daemon=$NAME --user=$NAME

$BIN/emacsclient --socket-name=$NAME -n -c "$*"

change -n -c above to -t for running a frame in terminal.

reading Linux Journal Jan 2016 issue, it's funny that feature article is something about cgi, a web server I've nerver heard of and a C program from 2000. but it's using systemd and mentioned Let's encrypt, so confusing.

the other feature article is much more fun: elasticsearch, syslog-ng and riemann

I thought Riemann is just a monitoring system. but actually it processes streams, well, using clojure is much much better than dealing with logstash.

didn't pay much attention about difference between .bash_profile and .bashrc before, one article in linux journal told the difference. profiles loaded when logged in, rc loaded when an interactive terminal opened.

for large data set, can use the Stack Exchange Data Dump

here's a Script to import the stackexchange dumps into MySQL

Thursday, March 17, 2016

about adding to swap to vm, normally won't need it and not recommended. but I'm running too many things on a $5 droplet ...

here's How To Add Swap on Ubuntu 14.04

sudo fallocate -l 4G /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
sudo swapon -s

add to /etc/fstab:

/swapfile   none    swap    sw    0   0

and tune for vps system, add to/etc/sysctl.conf:

vm.vfs_cache_pressure = 50

Saturday, March 19, 2016

emacs evil-mode I changed using emacs-state instead of insert-state, then I can use all emacs movement key bindings when editing. one problem is how to return to normal-state because Esc key doesn't work. couple lines are added:

(defalias 'evil-insert-state 'evil-emacs-state)
(define-key evil-emacs-state-map (kbd "<escape>") 'evil-normal-state)

also changed cursor-type in different states:

(setq evil-normal-state-cursor '(box "purple")
      evil-emacs-state-cursor '((bar . 3) "yellow"))

one interesting article recently is tcpdump is amazing, it mentioned pcap

my colleague pointed out that packetbeat supports different sniffer types: pcap, af_packet and pf_ring.

also there is Linux BPF Superpowers

other interesting tools are: sysdig, wireshark and tshark

I have no particular interest on this area, but I'm reading Practical Packet Analysis

also added these two to reading list:

Thursday, March 24, 2016

good summary of HA options of postgresql: PostgreSQL Replication Solutions (pdf)

citus is very interesting, looks like the way to go: Citus Unforks From PostgreSQL, Goes Open Source

for mysql, check this article: Database High Availability

mysql fabric is one option if you want to keep using innodb, because mysql cluster you'll have to use ndb engine (see MySQL Fabric Frequently Asked Questions)

mysql proxy is another way to separate read/write without touching application level logic: MySQL Proxy FAQ

or maybe try MySQL Load Balancing with HAProxy

facebook has their own solution for scaling the mysql: XDB: Shared MySQL hosting at Facebook scale

Friday, March 25, 2016

there is a DNS Outage at DigitalOcean, it's funny that we build our application with HA and fault tolerance in mind, but we didn't pay much attention to name servers, lesson learned.

Monday, March 28, 2016

podcasts to listen:

Wednesday, March 30, 2016

when doing pretty output on console, using clojure's print-table is very easy, for Java I use asciitable.

when listening to Cognicast Episode 095, heard another project by Nathan Marz: specter, check this post: Functional-navigational programming in Clojure(Script) with Specter and this talk: Specter: overcome your fear of nested Clojure data

cascalog is another famous project by Nathan Marz. I saw this library many times in different books, but didn't know it was a project by him until now. (I knew storm and was reading his book Big Data: Principles and best practices of scalable realtime data systems before).

Netflix's Hystrix, I read it from an article back to 2013: Building Clojure services at scale, here's a more recent post about Hystrix: Embracing Failure with Hystrix

there's a clojure bindings for it. I think it's quite useful some of my tasks, better spend some time on it.

Thursday, March 31, 2016

I always looking for a terminal like my old apple II, finally I got it: cool-retro-term

ubuntu is easy:

sudo add-apt-repository ppa:noobslab/apps 
sudo apt-get update
sudo apt-get install cool-retro-term

OS X can download the dmg from their Releases page

if just want the fonts, check out cool-retro-term/app/qml/fonts and True Type VT220 Font

Blog Archive