Jim Cheung

Friday, April 01, 2016

I've read a lot core.async stuffs, in order to get a clearer mind about how to use the library correctly.

one thing I didn't notice before and always wondered is: how can you tell a go block is done it's job?

the answer is very simple, go block ends with putting the evaluated value to a channel and returns it.

Saturday, April 02, 2016

finally upgraded the nvidia driver on my old laptop, it kept crashing when connected with external monitor.

tried all ppa approaches, didn't work. finally succeeded by following this guide: How to Install NVIDIA 346.35 Stable Driver in Ubuntu 14.04

my driver is GeForce 8400M GS, not supported by version 346.xx mentioned in the article, I need to download the 340.xx version (the 346.xx installer will tell you about this)

create /etc/modprobe.d/blacklist-nouveau.conf, with content:

blacklist nouveau
blacklist lbm-nouveau
options nouveau modeset=0
alias nouveau off
alias lbm-nouveau off

also run these two commands:

$ echo options nouveau modeset=0 | sudo tee -a /etc/modprobe.d/nouveau-kms.conf
$ sudo update-initramfs -u

reboot, Ctrl+Alt+F1 to leave X, and :

$ sudo stop lightdm

then run the 340.xx installer.

Monday, April 04, 2016

after read this article: The puts and takes of core.async

I tried to find out more about the difference between pending put and parking.

found this: Clojure core.async put! versus go block - Stack Overflow about core.async

Question:

  1. How does put! achieve asynchrony? Does it also uses a thread-pool?

  2. Does put! also uses parking?

  3. What is the role of the finite state-machine in the go block? Is it what enables parking?

  4. Should I always try to use put! rather than go because it is cheaper? In that case, does that mean that put! achieve the exact same concurrency goodness as go, and that go is only used when I want to reason about complex asynchronous code?

Answer:

  1. If put! is not accepted immediately, it places a pending put (the value to be put on the channel + the put! callback) on a queue internal to the channel. Note that an exception will be thrown if there is no room in the queue (max capacity is currently fixed at 1024).

The callback will be called on a pooled thread if (1) the put is not immediately accepted or (2) an explicit false is passed in as a final argument to the put! call (this argument is called on-caller?, see put!'s docstring for details).

  1. "Parking", in the context of go blocks, refers to suspending execution of a go block's state machine by recording certain details of its current state and saving them inside a channel, or possibly several channels, so that it can be restarted later. (Note that this arrangement means that if all the channels holding references to a suspended go block are GC'd, the go block itself can also be GC'd.) In other contexts it similarly refers to putting a thread of control in a state of suspended animation. put! is just a function (well, it's backed by a protocol method, but then that is just a protocol method), so the concept doesn't apply.

  2. Yes. It basically steps through the code in the go block, possibly suspending it when control reaches certain "custom terminals" (<!, >!, alt!).

  3. Not necessarily, you should first consider the risk of overflowing the internal queue (see point 1 above).

also watched this presentation as suggested: Implementation details of core.async Channels - Rich Hickey

the talk has more details about the pending operation queues.

Thursday, April 07, 2016

installed Riemann and tried few things, I really like it, not a drop-in solution but a really simple Concepts.

I'm reading sample chapters of this book: The Art of Monitoring

also reading Mastering Clojure

an interesting article: Overtone Recipes - Recreating Daft Punk's Da Funk, I really want to spend some time on Overtone and Quil

Tuesday, April 12, 2016

got interested in troff after reading Brian Kernighan on the typesetting of "The Go Programming Language" book

there're few classical macros come with groff (the GNU troff), mm, ms and me: see Macro packages (the page also provides links for the guide of each macro)

UNIX Document Processing and Typesetting mentions these 3 macros in the Using Macro Packages with nroff/troff section.

leaning the ms macro from this page UNIX Text Formatting Using the -ms Macros and -ms quick reference, produce pdf file using:

groff -ms [input] | ps2pdf - [output]

and the output was gorgeous.

Mastering Clojure is very good. I read many fundamental books on clojure, but this one still brings me something new.

Wednesday, April 13, 2016

Spinnaker seems using debian package to build the code image (see Hello Deployment), and using s3 as debian repository is very cool. I might need to find a time to try that out.

for other netflix oss components, I'm currently checking on:

few links to help to understand:

it's very heavy java and microservices oriented, could start with:

Thursday, April 14, 2016

found a command online to could be used for clearing the php opcache: php-fpm-cli

$ php-fpm-cli -r 'opcache_reset();' -connect 127.0.0.1:9000
$ php-fpm-cli -r 'var_dump(opcache_get_status());' -connect 127.0.0.1:9000

cgi-fcgi command can be found on libfcgi0ldbl package on ubuntu, I've used this command to debug some fastcgi issues, but wasn't thinking could use it to clear the opcode cache.

didn't follow the Toronto Java Users Group for quite a while, they always got interesting topics:

Tuesday, April 19, 2016

saw a funny usage of watch, when downloading/copying a large file, this command watches the file size every 100ms:

$ watch -n 0.1 du -s filename

Thursday, April 21, 2016

found a very interesting article: Building an offline page for theguardian.com

I tried disconnect my laptop and reload the page, it just loaded ... crazy! (btw, the guardian's frontend is open sourced)

Service workers explained and The Service Worker Cookbook are good starts.

Friday, April 22, 2016

Ubuntu new LTS version 16.04 has been released: The squirrel has landed!

some readings:

Upgrade Ubuntu 16.04 on desktop is quit easy:

Sunday, April 24, 2016

playing with new ubuntu desktop, Ubuntu 16.04 Makes Ubuntu Exciting Again has one good tip:

move unity launcher to bottom:

$ gsettings set com.canonical.Unity.Launcher launcher-position Bottom
# revert
$ gsettings set com.canonical.Unity.Launcher launcher-position Left

Friday, April 29, 2016

about unpack an apk file, it's pretty easy actually. you'll need dex2jar and jd-gui:

playing with send commands to tmux panes, some simple commands

Blog Archive