2015年9月7日 星期一

[阿宅專區] ESP8226正夯

ESP8226正夯, Adafruit 也做了自己的 breakout, 還有教學
Home Automation in the Cloud with the ESP8266 & Adafruit IO

話說, 為什麼他們做起來就好有趣的樣子阿?

2015年9月3日 星期四

[程式語言] multi-threading

有鑑於 facebook 的搜尋實在是太難用了, 資料丟上去就跟消失沒兩樣, 因此還是要在這邊紀錄一下比較安心...

Why your GUI app freezes, 告訴你 GUI 程式要怎麼寫

2015年8月3日 星期一

[Arduino] Pulse Sensor

今天在搞 Arduino Pulse Sensor, 文件很齊, 希望有機會移植到 Raspberry Pi 上

不過事情總是沒這麼順利, 一開始在 Windows XP 上使用 Arduino IDE 的版本就有問題, 試了 1.6.5 和 1.0.5 都不行, 最後用了 1.5.8 終於可以順利執行

換到 Ububnut 上, 又出現錯誤訊息
error while loading shared libraries: libtinfo.so.5: cannot open shared object file: No such file or directory
搜尋了一下, 加上 soft link 就可以了
sudo ln -s /usr/lib/libncurses.so.5 /usr/lib/libtinfo.so.5
sudo ln -s /usr/lib/libtinfo.so.5   /usr/lib/libtinfo.so

2015年8月2日 星期日

[電路圖] 寫給軟體工程師看的電子學

RC 電路: http://www.raspberrypi-spy.co.uk/2012/08/reading-analogue-sensors-with-one-gpio-pin/

2015年7月26日 星期日

[胡言亂語] Android Studio

最近在找 Android Studio 的資料, 發現簡中的文件比繁中多太多了, 雖然是早已經知道的結果, 可是還是不禁要感嘆一下 reference: Android Studio系列教程

2015年7月25日 星期六

[Tips] 切換 Python 版本

電腦裡裝了很多版本的 Python
python             python2.6          python2.7          python3.4-config   python3.4m-config  
python2            python2.6-config   python3.4          python3.4m         python-config      
預設是使用超級舊的 2.6.5, 有些模組功能不支援, 例如 subprocess 的 check_output 只在 python2.7 以後才能使用
python --version
Python 2.6.5
我們可以利用 update-alternatives 切換 python 的版本 先查一下可使用的版本, 真糟糕不能用
update-alternatives --list python
update-alternatives: error: no alternatives for python.
加入 2.6
sudo update-alternatives --install /usr/bin/python python /usr/bin/python2.6 1
update-alternatives: using /usr/bin/python2.6 to provide /usr/bin/python (python) in auto mode.
加入 2.7
sudo update-alternatives --install /usr/bin/python python /usr/bin/python2.7 2
update-alternatives: using /usr/bin/python2.7 to provide /usr/bin/python (python) in auto mode.
加入 3.4
sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.4 3
update-alternatives: using /usr/bin/python3.4 to provide /usr/bin/python (python) in auto mode.
再查一下可使用的版本
update-alternatives --list python
/usr/bin/python2.6
/usr/bin/python2.7
/usr/bin/python3.4
可以很高興的切換版本了
sudo update-alternatives --config python
There are 3 choices for the alternative python (providing /usr/bin/python).

  Selection    Path                Priority   Status
------------------------------------------------------------
* 0            /usr/bin/python3.4   3         auto mode
  1            /usr/bin/python2.6   1         manual mode
  2            /usr/bin/python2.7   2         manual mode
  3            /usr/bin/python3.4   3         manual mode

Press enter to keep the current choice[*], or type selection number: 2
update-alternatives: using /usr/bin/python2.7 to provide /usr/bin/python (python) in manual mode.
看看現在使用的 python 版本吧
python --version
Python 2.7.6
這套工具特別適合程式語言版本的切換, Java 更是需要阿

最近發生了一個趣事, 切換版本以後 apt-get 會用到 python 的指令都爛掉了, 錯誤訊息如下:
After this operation, 0B of additional disk space will be used.
(Reading database ... 417151 files and directories currently installed.)
Preparing to replace python-pkg-resources 0.6.10-4ubuntu1 (using .../python-pkg-resources_0.6.10-4ubuntu1_all.deb) ...
Traceback (most recent call last):
  File "/usr/bin/pycentral", line 2300, in 
    main()
  File "/usr/bin/pycentral", line 2294, in main
    rv = action.run(global_options)
  File "/usr/bin/pycentral", line 1653, in run
    runtimes = get_installed_runtimes(with_unsupported=True)
  File "/usr/bin/pycentral", line 278, in get_installed_runtimes
    default_version = pyversions.default_version(version_only=True)
  File "/usr/share/pycentral-data/pyversions.py", line 172, in default_version
    raise ValueError, "/usr/bin/python does not match the python default version. It must be reset to point to %s" % debian_default
ValueError: /usr/bin/python does not match the python default version. It must be reset to point to python2.6
dpkg: warning: old pre-removal script returned error exit status 1
dpkg - trying script from the new package instead ...
Traceback (most recent call last):
  File "/usr/bin/pycentral", line 2300, in 
    main()
  File "/usr/bin/pycentral", line 2294, in main
    rv = action.run(global_options)
  File "/usr/bin/pycentral", line 1653, in run
    runtimes = get_installed_runtimes(with_unsupported=True)
  File "/usr/bin/pycentral", line 278, in get_installed_runtimes
    default_version = pyversions.default_version(version_only=True)
  File "/usr/share/pycentral-data/pyversions.py", line 172, in default_version
    raise ValueError, "/usr/bin/python does not match the python default version. It must be reset to point to %s" % debian_default
ValueError: /usr/bin/python does not match the python default version. It must be reset to point to python2.6
dpkg: error processing /var/cache/apt/archives/python-pkg-resources_0.6.10-4ubuntu1_all.deb (--unpack):
 subprocess new pre-removal script returned error exit status 1
Traceback (most recent call last):
  File "/usr/bin/pycentral", line 2300, in 
    main()
  File "/usr/bin/pycentral", line 2294, in main
    rv = action.run(global_options)
  File "/usr/bin/pycentral", line 1477, in run
    runtimes = get_installed_runtimes()
  File "/usr/bin/pycentral", line 278, in get_installed_runtimes
    default_version = pyversions.default_version(version_only=True)
  File "/usr/share/pycentral-data/pyversions.py", line 172, in default_version
    raise ValueError, "/usr/bin/python does not match the python default version. It must be reset to point to %s" % debian_default
ValueError: /usr/bin/python does not match the python default version. It must be reset to point to python2.6
dpkg: error while cleaning up:
 subprocess installed post-installation script returned error exit status 1
Errors were encountered while processing:
 /var/cache/apt/archives/python-pkg-resources_0.6.10-4ubuntu1_all.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)
拜了咕狗以後, 才發現還是要把 default python 路徑(/usr/bin/python)指到一個喜歡的人上面(python2.6)
sudo ln -sf /usr/bin/python2.6 /usr/bin/python

2015年7月9日 星期四

[計算機概論] The TTY demystified

這篇有很詳盡的介紹 TTY 的歷史, 好像叫 demystified 的都很厲害?

貼幾張圖吧: