2012/04/18

使用 Octopress 寫 Blog

http://jekyllbootstrap.com/
http://ruhoh.com/
http://orgmode.org/worg/org-tutorials/org-jekyll.html
https://github.com/imathis/octopress/wiki

Jekyll

Jekyll is a simple, blog aware, static site generator. It takes a template directory (representing the raw form of a website), runs it through Textile or Markdown and Liquid converters, and spits out a complete, static website suitable for serving with Apache or your favorite web server. This is also the engine behind GitHub Pages, which you can use to host your project’s page or blog right here from GitHub.

https://github.com/mojombo/jekyll/wiki
http://orgmode.org/worg/org-tutorials/org-jekyll.html

Jekyll-Bootstrap

Octopress
Octopress 可以看成是一個 blog 書寫工具,它將你書寫的 blog 內容加工成靜態網頁。

[安裝 Ruby]
http://zx-1986.blogspot.com/2011/10/rvm.html

http://octopress.org/docs/deploying/github/
http://octopress.org/docs/deploying/heroku/

Enter the read/write url for your repository: git@github.com:zx1986/zx1986.github.com.git

http://markdown.tw/
http://octopress.org/docs/
http://zespia.tw/blog/2012/01/14/hello-octopress/
http://blog.lyhdev.com/2011/10/octopress-github-markdown.html
http://killtw.k2ds.net/blog/2011/10/29/how-to-install-rails/

2012/04/17

Sass

[Sass]

sudo apt-get ruby
sudo apt-get rubygems
sudo gem --update system
sudo gem install sass

[Scss]

語法改良後的 Sass,同樣使用 sass 命令來編譯,副檔名通常是 *.scss

[Compass]

sudo gem install compass

http://designshack.net/articles/css/sass-vs-stylus-who-wins-the-minimal-syntax-battle/

Reference:
http://sass-lang.com
http://compass-style.org
http://blueprintcss.org
http://960.gs
http://upgrade2rails31.com/sass-scss
http://upgrade2rails31.com/compass
https://github.com/imathis/fancy-buttons

2012/04/06

RVM - Ruby Version Manager

[安裝 rvm]
# 注意:使用 root 身份安裝的 rvm 是 system wide 的!
sudo su -

apt-get remove --purge ruby
apt-get remove --purge gem

apt-get install git autoconf patch curl bash wget

curl -L get.rvm.io | bash -s stable
usermod -a -G rvm YOUR_ACCOUNT

exit
logout
login

rvm notes

# ZSH 4.3.15 is buggy with RVM (2012/03)

[安裝 Ruby]
rvm install 1.8.6
rvm install 1.9.3

# rvm alias create default ruby-1.9.3
rvm --default use 1.9.3

ruby --version
which ruby
which gem

rvm help
rvm list
rvm list known
[使用 gemset]
rvm gemdir # 顯示 gems 資料夾

rvm gemset name # 查詢當前所用 gemset 的名稱
rvm gemset list # 查詢所有的 gemset
rvm gemset use NAME # 切換到指定的 gemset

rvm gemset create foo # 建立一個叫 foo 的 gemset 集合

rvm use 1.9.3@foo # 切換到 Ruby 1.9.3 搭配 foo 這個 gemset 的環境
rvm list # 查看 Ruby 1.9.3 的 foo 內有哪些 gems
rvm install rails # 在 Ruby 1.9.3 的 foo 內安裝 rails

rvm use 1.9.3@global # 切換回 Ruby 1.9.3 default 的 gemset 環境
rvm list # 查看 default 的 gemset 內有哪些 gems

rvm gemset export backup.gems # 將當前的 gems 備份
rvm gemset import backup.gems # 將 backup.gems 倒回來

# global gemset(~/.rvm/gemsets/global.gems)
# default gemset(~/.rvm/gemsets/default.gems)
# 這兩個 gemset 有點特殊,而且兩個其實不盡相同。
# global 會被 "added" 到每個用 rvm 安裝的 ruby
# default 會被 "included" 到每個新建的 gemset

[rvmrc]

rvmrc 是 rvm 的 runtime configuration,可以依據作用範圍的不同做區分。

系統範圍的:/etc/rvmrc
使用者範圍的:~/.rvmrc
專案範圍的:.rvmrc

組合技:
rvm --create --rvmrc 1.9.3@project
# 搭配 Ruby 1.9.3 建立一個叫 project 的 gemset,並 use 它,並幫它建立一個 .rvmrc

MRI:Matz's Ruby Interpreter(Matz 的 Ruby 直譯器)
p.s. Matz 是發明 Ruby 語言的日本程式設計師 Yukihiro Matsumoto 的昵稱。

Reference:
http://sirupsen.com/get-started-right-with-rvm/
http://beginrescueend.com
http://beginrescueend.com/rvm/install
http://beginrescueend.com/rvm/basics

2012/04/05

Ubuntu 的 ATi 驅動

https://wiki.ubuntu.com/X/Troubleshooting/FglrxInteferesWithRadeonDriver
https://help.ubuntu.com/community/RadeonDriver

我的 laptop 有一張非常古怪的顯示卡:ATI Mobility Radeon X2300
ATi 對 Linux 本來就很不友善了,再加上這張怪卡,更有得煩了。
lspci -nn | grep VGA
01:00.0 VGA compatible controller [0300]: ATI Technologies Inc Mobility Radeon X2300 [1002:718a]
我的環境是 Ubuntu 11.10 i386,先來認識一些名詞。

[Mesa]
Mesa is a software library for 3D computer graphics that provides a generic OpenGL implementation for rendering three-dimensional graphics on multiple platforms.

[Radeon Driver]
Open Source driver for many ATI graphics cards called "radeon" or "ati". It will provide 2D and 3D acceleration in your video hardware. This driver is not as fast as the closed-source, proprietary "fglrx" driver from AMD/ATI Inc. for some cards, but has better dual-head support, and supports some older chipsets that fglrx does not.

[Catalyst | fglrx]
fglrx is a proprietary, Linux binary-only driver for ATI graphic chips with support for 3D acceleration. fglrx is the name of the Linux display driver used for ATI Radeon and ATI FireGL family of video adapters and stands for "FireGL and Radeon for X". It contains both free and open-source and proprietary parts.

=== fglrx ===

fglrx 就是 Catalyst for Linux
ATi 很小氣,不願意開放它的驅動原始碼,只提供編譯好的二進位驅動檔給 Linux OS
每個不同的 Linux 發行版再自行打包它們的 ATi Driver,就是 fglrx(FireGL and Radeon for X)
你看 ATi 取的這爛名字 ....

fglrx 雖然還有其他問題:
http://www.thinkwiki.org/wiki/Problems_with_fglrx
http://askubuntu.com/questions/78906/ati-amd-proprietary-fglrx-graphics-install-fails-how-can-i-resolve-the-problem

但是大家最推薦、最簡便的解法還是使用 fglrx

不管是透過 PPA 使用 apt-get 安裝:
https://launchpad.net/~ubuntu-x-swat/+archive/x-updates
https://launchpad.net/~xorg-edgers/+archive/ppa

或下載官方原始檔來編譯安裝(ATi Radeon 系列):
http://support.amd.com/us/gpudownload/linux/previous/Pages/radeon_linux.aspx

只是根據硬體支援清單,我的 Radeon X2300 看起來已經不被新版的 fglrx 支援了:
http://wiki.cchtml.com/index.php/Hardware#Not_Yet_Supported_or_Unoffically_Supported

我測試了 apt-get 安裝的 fglrx:
sudo apt-add-repository ppa:ubuntu-x-swat/x-updates
sudo apt-add-repository ppa:xorg-edgers/ppa
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install fglrx fglrx-amdcccle
sudo apt-get install fglrx-updates fglrx-amdcccle-updates
sudo apt-get update
sudo apt-get upgrade
也測試了官方不同版本的的原始檔安裝:
ati-driver-installer-9-3-x86.x86_64.run
ati-driver-installer-10-12-x86.x86_64.run
ati-driver-installer-11-10-x86.x86_64.run
ati-driver-installer-11-12-x86.x86_64.run

=== Radeon Driver ===

使用 apt-cache search radeon,找到下列套件:
xserver-xorg-video-ati - X.Org X server -- AMD/ATI display driver wrapper
xserver-xorg-video-ati-dbg - X.Org X server -- AMD/ATI display driver wrapper (debugging symbols)
xserver-xorg-video-radeon - X.Org X server -- AMD/ATI Radeon display driver
xserver-xorg-video-radeon-dbg - X.Org X server -- AMD/ATI Radeon display driver (debugging symbols)
radeontool - utility to control ATI Radeon backlight functions on laptops

fglrx-amdcccle-updates - Catalyst Control Center for the AMD graphics accelerators
fglrx-amdcccle - Catalyst Control Center for the AMD graphics accelerators
fglrx-updates - Video driver for the AMD graphics accelerators
fglrx-updates-dev - Video driver for the AMD graphics accelerators (devel files)
fglrx - Video driver for the AMD graphics accelerators
fglrx-dev - Video driver for the AMD graphics accelerators (devel files)

libdrm-radeon1 - Userspace interface to radeon-specific kernel DRM services -- runtime
libdrm-radeon1-dbg - Userspace interface to radeon-specific kernel DRM services -- debugging symbols

根據 https://help.ubuntu.com/community/RadeonDriver
看起來 Radeon Driver 另外一個可以嘗試的選擇。

If you've previously installed the ATI binary/proprietary driver (a.k.a Catalyst/fglrx), you need to make sure it's fully purged before trying to use the open-source ati/radeon driver.
sudo apt-get purge fglrx*
sudo apt-add-repository ppa:xorg-edgers/ppa
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install xserver-xorg-video-ati* xserver-xorg-video-radeon* radeontool

但是,在使用 Chrome 或 Firefox 搭配 Flash 時,gnome 經常會當掉,很糟糕。
將 Flash 套件移除之後,目前還沒有出現當幾狀況!COOL!

Reference:
http://www.hardwareheaven.com/modtool.php
http://ubuntuforums.org/showthread.php?t=1556555
http://ubuntuforums.org/showthread.php?t=1250530
http://wiki.cchtml.com/index.php/Ubuntu_Oneiric_Installation_Guide
http://en.wikipedia.org/wiki/AMD_Catalyst
http://maketecheasier.com/install-custom-gnome-shell-themes/2011/09/27
http://mrrichard.hubpages.com/hub/How-to-Install-FGLRX-in-Ubuntu-1010
https://wiki.ubuntu.com/X/Troubleshooting/FglrxInteferesWithRadeonDriver
https://help.ubuntu.com/community/BinaryDriverHowto/ATI
https://help.ubuntu.com/community/RadeonDriver
https://help.ubuntu.com/community/RadeonHD
http://mrrichard.hubpages.com/hub/How-to-Install-FGLRX-in-Ubuntu-1010
http://support.amd.com/us/gpudownload/linux/previous/Pages/radeon_linux.aspx
http://askubuntu.com/questions/124292/what-is-the-correct-way-to-install-ati-catalyst-video-drivers-fglrx/129200#129200
http://askubuntu.com/questions/71457/how-can-i-set-up-dual-monitor-display-with-ati-driver

Node.js

[什麽是 Node.js]
# 如果你熟悉 Linux 與程式開發,我想我應該可以這樣子解釋 Node.js

shell$ python hello.py
shell$ perl hello.py
shell$ ruby hello.rb
shell$ php hello.php

shell$ alias javascript='node'
shell$ javascript hello.js
Node.js 把 javascript 從瀏覽器中釋放出來了!

[使用 nvm 安裝 Node.js]
git clone http://github.com/creationix/nvm.git ~/nvm
source ~/nvm/nvm.sh
nvm install v0.6.10
nvm use v0.6.10
nvm alias default 0.6

node --help

which node
which npm

使用 nvm 安裝 nodejs 後,它會自動安裝相應版本的 npm(Nodejs Package Manager)。
使用 npm 可以安裝各種 nodejs 模組。

但是每次要使用好像都要 source nvm.sh 一次,而且 nodejs 也沒有加到系統路徑中。

[使用 apt-get 安裝 Node.js]
sudo apt-get install python
sudo apt-get install openssh-server libssl-dev
sudo apt-get install python-software-properties
sudo add-apt-repository ppa:chris-lea/node.js
sudo apt-get update
sudo apt-get install nodejs

[自行編譯安裝 Node.js]
sudo apt-get install python
sudo apt-get install openssh-server libssl-dev
git clone --depth 1 git://github.com/joyent/node.git
cd node
git checkout v0.4.12
./configure
make -j2    # -j sets the number of jobs to run
sudo make install

[安裝 Node.js 的套件管理程式 NPM]
# Node Packages Manager

sudo su -
curl http://npmjs.org/install.sh | sh

強力推薦的電子書:
http://contpub.org/read/nodejs-wiki-book

Framework:
https://github.com/dreamerslab/coke

http://nodejs.tw
http://wiki.nodejs.tw
https://github.com/dreamerslab/nodejs.basics

Reference:
http://nodejs.org
http://npmjs.org
https://github.com/joyent/node/wiki/Installation
https://github.com/joyent/node/wiki/Installing-Node.js-via-package-manager
https://github.com/nodejs-tw/nodejs-community-book
https://www.facebook.com/NodeJS.tw
http://jsdc.tw

2012/04/02

在 RHEL 6 安裝 MySQL Cluster

各個 MySQL Cluster 套件的描述:
MySQL-Cluster-server-gpl.x86_64 : a very fast and reliable SQL database server
MySQL-Cluster-client-gpl.x86_64 : MySQL Cluster - Client
MySQL-Cluster-devel-gpl.x86_64 : Development header files and libraries
MySQL-Cluster-embedded-gpl.x86_64 : embedded library
MySQL-Cluster-gpl-shared-compat.x86_64 : MySQL shared client libraries for MySQL 5.1.61-1, 5.0.95-1, 4.1.23-0, 4.0.27-0
MySQL-Cluster-shared-compat-gpl.x86_64 : MySQL shared client libraries for MySQL 5.1.61-1, 5.0.95-1, 4.1.23-0, 4.0.27-0
MySQL-Cluster-shared-gpl.x86_64 : Shared libraries

http://forums.mysql.com/read.php?25,519007,519073
This one package replaces the following packages from previous versions.

$ rpm -qp --obsoletes MySQL-Cluster-server-gpl-7.2.4-1.el6.x86_64.rpm
MySQL-Cluster-server
MySQL-Cluster-management
MySQL-Cluster-storage
MySQL-Cluster-extra
MySQL-Cluster-tools
# MySQL-Cluster-server 中即包含了以上幾個舊版的 rpm 內容

[角色]

MySQL Cluster 內有三種角色:
Management Node
MySQL Node
Data Node

三種角色可以分別由三臺(或者三臺以上)的主機來擔任,也可以是一臺主機擔任三種角色。
三種角色是不會互相衝突的,亦即不同角色可以共存在同一臺主機中。
但是,傳統的 MySQL 及其相關的 lib 不可以混在 MySQL Cluster 的主機上。

Management Node 核心是 ndb_mgmd(ndb management daemon),


MySQL Node 核心是 mysqld(看起來很像是傳統單機版的 MySQL Server),


Data Node 核心是 ndbd(ndb daemon),

[安裝]

yum erase mysql* mysql-*
yum install MySQL-Cluster-server
yum install MySQL-Cluster-client

Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing     : MySQL-Cluster-server-gpl-7.2.4-1.el6.x86_64
                                                             
PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:

/usr/bin/mysqladmin -u root password 'new-password'
/usr/bin/mysqladmin -u root -h test-ndb-node02.mfc.cwb password 'new-password'

Alternatively you can run:
/usr/bin/mysql_secure_installation

which will also give you the option of removing the test
databases and anonymous user created by default.  This is
strongly recommended for production servers.

See the manual for more instructions.

Please report any problems with the /usr/bin/mysqlbug script!

[設定]

[管理]