Tuesday, April 26, 2016

Set daemon config for Docker for Mac

Just follow what describe in this link How to run a insecure-registry

Capture the screen in case the link is gone in the future

Unix, use output of the previous command

Not a direct solution but it suits my need.
Use !! to expand the previous command and evaluate it with $() or ``
For example;

$ which pinata  
$ ls -lh `!!`
Credit: http://stackoverflow.com/a/5955674/1032449 

Thursday, February 25, 2016

Interesting use case example for `are` macro in Clojure test

I found an interesting use case for are in Clojure test.

You might have ever written a test for your data conversion logic. E.g.
  • Converting data pulled from third-party web service into your internal schema.
  • Converting data fetched from your database to more mobile friendly schema before sending out.
This is an example snippet of test for such a scenario.

convert-test1 shows the style I had been writing until recently. convert-test2 shows how using are making the test better.

  • No more duplication of field values between input and output.
  • No more duplication between output schema and code under test schema.
  • It can be use as a document showing clearly how each individual field is mapped.
An error message in convert-test1 is better. It shows clearly which field is wrong while convert-test2 throw out the whole problematic result data.

Updated: I have retested, are does report problem for an individual case as well.

Wednesday, February 10, 2016

[ClojureScript] Run all tests in multiple namespaces in REPL

From ClojureScript wiki, it says
If you have many test namespaces it's idiomatic to create a test runner namespace which imports all of your test namespaces and then invokes run-tests
I personally couldn't get it to work. Though I have managed to make run-all-tests works. This is an example

(ns myns.test.runner
  (:require [cljs.test :refer-macros [run-all-tests]]

(run-all-tests #"myns.test.*")

[DataScript][Solved] Error: Expected number or lookup ref for entity id, got

When you are trying to use Map specification of Datomic's pull api and you got this error
Error: Expected number or lookup ref for entity id, got ....
This happens because you didn't specify schema for that data attribute. Schema is optional on DataScript but it is required in this case. Add this line to your database, the issue should be fixed
{:your-attribute1 {:db/valueType :db.type/ref}
 :your-attribute2 {:db/valueType :db.type/ref}}

Friday, November 27, 2015

Terminal.app doesn't save history in El Capitan and you are using RVM

The cause is described here https://github.com/rvm/rvm/issues/3540#issue-113491283
The fix is here https://github.com/rvm/rvm/issues/3540#issuecomment-152824133

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