2014年7月26日 星期六

linux 下 chrome 界面亂碼解決方法

修改 /etc/fonts/conf.d/49-sansserif.conf倒數第四行,改成下面這樣或是換成其他你喜歡的字型。


ubuntu


參考資料:
http://blog.csdn.net/loveaborn/article/details/29579787


如果上面這個方法無效,試試看下面指令
$ sudo apt-get install ttf-wqy-microhei ttf-wqy-zenhei xfonts-wqy

2014年7月14日 星期一

一些黑底白字的瀏覽器外掛或 pdf reader

chrome:

High Contrast
Night Reading Mode  (推薦)

pdf reader:
evince  (到 view -> inverted color 將白底換成黑底)

2014年7月12日 星期六

How to build x86_64 image for qemu using buildroot

Download buildroot and change into buldroot folder. And then type below command.
make qemu_x86_64_defconfig
make -j8
qemu-system-x86_64 -M pc -kernel output/images/bzImage -drive file=output/images/rootfs.ext2 -append root=/dev/sda -vga std

Enjoy it.

scala 中 for ...yield 與 map, flatMap, withFilter 之互換


-------------------------------
for(x <- expr1) yield expr2
expr1.map(x => expr2)

-------------------------------

for(x <- expr1 if expr2) expr3
expr1.withFilter(x => expr2).map(x => expr3)

-------------------------------

for(x <- expr1 if expr2; seq) yield expr3
for(x <- expr1 withFilter expr2; seq) yield expr3

-------------------------------

for(x <- expr1; y <- expr2; seq) yield expr3
expr1.flatMap(x => for (y <- expr2; seq) yield expr3)

-------------------------------


for ((x1, x2) <- expr1) yield expr2
expr1.map{case(x1, x2) => expr2}

-------------------------------

for(pat <- expr1) yield2

expr1 withFilter {
  case pat = > true
  case _ => false
} map {
  case pat => expr2
}

2014年6月26日 星期四

How to attach to running container?



If you want to attach to running container, it's possible. First, use `sudo docker ps--no-trunc` to find your container full id. And use `sudo lxc-attach --name your_id` to attach. The way seems to be dangerous. Look before you leap.

2014年6月22日 星期日

introduce to call_seq.

    A tool to help you trace code efficiently. call_seq record the program how to run and save the result to file with json format.


Quick start to try it.
                $ pip install pyside pyqode.core pyqode.python
                $ git clone https://github.com/ya790206/call_seq
                $ python demo.py
                $ python -m call_seq.browser output.json        

How to record the program how to run.
    if __name__ == '__main__':
        with CallSeq(name='output.json'):
            test() #  the code you want to trace

After the file `output.json` created, then you run the below command.
python -m call_seq.browser output.json
Now you can trace code using call_seq.browser. Enjoy it.





2014年5月4日 星期日

scala 檔案目錄操作

如果你要對目錄下作一下操作,如列出所有的檔案之類的。可以考慮用 reflect.io 這個 package。簡單的用法如下。

import reflect.io._

Directory(".").list


iscala

iscala ,一個類似 ipython 的東西,不過他是給 scala 用的。用這個 shell 最大的好處是,你可以按 tab 健來觀察該物件有哪些屬性或方法。

iscala 的官方網站在這。https://github.com/mattpap/IScala。比較簡單的安裝方法就到這個頁面下載 iscala ,然後用下面 bash 執行。(注意:你可能要修改你的 JAR_PATH 路徑)

#!/bin/bash
JAR_PATH="$(dirname $(dirname $(readlink -f $0)))/lib/IScala.jar"
KERNEL_CMD="[\"java\", \"-jar\", \"$JAR_PATH\", \"--profile\", \"{connection_file}\", \"--   parent\", \"$@\"]"
ipython console --profile scala --KernelManager.kernel_cmd="$KERNEL_CMD" --no-banner

2014年5月3日 星期六

在 sbt 下使用 scala 內建的 actor



在 build.sbt 裡新增
libraryDependencies +=
      "org.scala-lang" % "scala-actors" % "2.10.0"

scala-actors 是 library name
2.10.0 是版本號

他有提供什麼 library 以及版本可從下面列表去找

scala 的 library 列表
https://oss.sonatype.org/content/groups/public/org/scala-lang/