Baking 2014
原味戚風蛋糕(Chiffon Cake) 芋頭麵包(Taro Bread) 小餅乾(Biscuit) 萬聖節餅乾(Halloween Cookies) 海蒂白麵包(アルプスの少女ハイジ・ハイジの白パン) 黑糖饅頭(Brown Sugar Steamed Bread) 蛋糕土司(Cake Toast) 香蕉土司(Banana Toast)
原味戚風蛋糕(Chiffon Cake) 芋頭麵包(Taro Bread) 小餅乾(Biscuit) 萬聖節餅乾(Halloween Cookies) 海蒂白麵包(アルプスの少女ハイジ・ハイジの白パン) 黑糖饅頭(Brown Sugar Steamed Bread) 蛋糕土司(Cake Toast) 香蕉土司(Banana Toast)
Generating SSH keys for GitHub Here are github account and work account. GitHub: SSH Key: github_id_rsa Account: oopsmonk Work: SSH Key: work_id_rsa Account: SamChen Add SSH config File Modify ~/.ssh/config # Default github Host github.com HostName github.com PreferredAuthentications publickey IdentityFile ~/.ssh/github_id_rsa # Work git server Host work.gitserver.com HostName work.gitserver.com PreferredAuthentications publickey IdentityFile ~/.ssh/work_id_rsa Git Repository Configuation GitHub Project: $ git clone https://github.com/abc/projectA.git $ cd projectA #github account $ git config user.name "oopsmonk" $ git config user.email "oopsmonk@example.com.tw" Working Project: $ git clone https://work.com.tw/repo/projectW.git $ cd projectW #working account $ git config user.name "SamChen" $ git config user.email "SamChen@example.com.tw" Now you can deal with git repositories using different accounts. ...
installation Requirements $ sudo apt-get install -y make build-essential libssl-dev zlib1g-dev libbz2-dev \ libreadline-dev libsqlite3-dev wget curl llvm install pyenv $ cd ~ $ git clone git://github.com/yyuu/pyenv.git .pyenv $ echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bashrc $ echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bashrc $ echo 'eval "$(pyenv init -)"' >> ~/.bashrc install pyenv-virtualenv $ git clone https://github.com/yyuu/pyenv-virtualenv.git ~/.pyenv/plugins/pyenv-virtualenv $ echo 'eval "$(pyenv virtualenv-init -)"' >> ~/.bashrc $ exec $SHELL Common Usage (Command Reference) List all available versions $ pyenv version -l Install python2.7.8 to pyenv $ pyenv install 2.7.8 List installed versions $ pyenv versions * system (set by /home/oopsmonk/.pyenv/version) 2.7.8 3.4.2 Creating a virtualenv $ pyenv virtualenv 2.7.8 mypy-2.7.8 List virtualenvs $ pyenv virtualenvs mypy-2.7.8 (created from /home/oopsmonk/.pyenv/versions/2.7.8) mypy-3.4.2 (created from /home/oopsmonk/.pyenv/versions/3.4.2) # current versions $ pyenv versions * system (set by /home/oopsmonk/.pyenv/version) 2.7.8 3.4.2 mypy-2.7.8 mypy-3.4.2 Use python via virtualenv # show current version oopsmonk@VBox:~/markdown-note$ python --version Python 2.7.6 # Change to other version oopsmonk@VBox:~/markdown-note$ pyenv activate mypy-2.7.8 (mypy-2.7.8)oopsmonk@VBox:~/markdown-note$ python --version Python 2.7.8 # Deactivate (mypy-2.7.8)oopsmonk@oopsmonk-VBox:~/markdown-note$ pyenv deactivate oopsmonk@oopsmonk-VBox:~/markdown-note$ python --version Python 2.7.8 # Why current version is 2.7.8? it's supposed to 2.7.6. oopsmonk@oopsmonk-VBox:~/markdown-note$ pyenv activate mypy-3.4.2 (mypy-3.4.2) oopsmonk@oopsmonk-VBox:~/markdown-note$ pyenv deactivate oopsmonk@oopsmonk-VBox:~/markdown-note$ python --version Python 3.4.2 oopsmonk@oopsmonk-VBox:~/markdown-note$ pyenv versions system 2.7.8 3.4.2 mypy-2.7.8 * mypy-3.4.2 (set by PYENV_VERSION environment variable) # delete a virtualenv $ pyenv uninstall mypy-2.7.8 # Go back to original system version $ alias pyenv_deactivate='pyenv deactivate && unset PYENV_VERSION' oopsmonk@oopsmonk-VBox:~/markdown-note$ pyenv activate mypy-3.4.2 (mypy-3.4.2) oopsmonk@oopsmonk-VBox:~/markdown-note$ pyenv_deactivate oopsmonk@oopsmonk-VBox:~/markdown-note$ python --version Python 2.7.6 Use python via pyenv # Global python version $ pyenv global # python version in current folder oopsmonk@oopsmonk-VBox:~/markdown-note$ pyenv local mypy-3.4.2 oopsmonk@oopsmonk-VBox:~/markdown-note$ pyenv version mypy-3.4.2 (set by /home/oopsmonk/markdown-note/.python-version) oopsmonk@oopsmonk-VBox:~/markdown-note$ cd .. oopsmonk@oopsmonk-VBox:~$ pyenv version system (set by /home/oopsmonk/.pyenv/version) oopsmonk@oopsmonk-VBox:~$ cd - /home/oopsmonk/markdown-note oopsmonk@oopsmonk-VBox:~/markdown-note$ pyenv version mypy-3.4.2 (set by /home/oopsmonk/markdown-note/.python-version) oopsmonk@oopsmonk-VBox:~/markdown-note$ pyenv local --unset oopsmonk@oopsmonk-VBox:~/markdown-note$ pyenv version system (set by /home/oopsmonk/.pyenv/version) # python version in current shell oopsmonk@oopsmonk-VBox:~/markdown-note$ pyenv shell mypy-3.4.2 oopsmonk@oopsmonk-VBox:~/markdown-note$ pyenv version mypy-3.4.2 (set by PYENV_VERSION environment variable) oopsmonk@oopsmonk-VBox:~/markdown-note$ cd - /home/oopsmonk oopsmonk@oopsmonk-VBox:~$ pyenv version mypy-3.4.2 (set by PYENV_VERSION environment variable) oopsmonk@oopsmonk-VBox:~$ pyenv shell --unset oopsmonk@oopsmonk-VBox:~$ pyenv version system (set by /home/oopsmonk/.pyenv/version) oopsmonk@oopsmonk-VBox:~$ cd - /home/oopsmonk/markdown-note oopsmonk@oopsmonk-VBox:~/markdown-note$ pyenv version system (set by /home/oopsmonk/.pyenv/version)
Advanced Bash-Scripting Guide sed awk Internal Variables #current parent pid $$ #last background process pid $! #last exit status $? #current instance pid, Bash 4.x above. $BASHPID Arithmetic Expansion a=12 b=$(($a + 10)) b=`expr $a + 1` b=$(expr $a + 1) let b=$a+3 #let b=$a + 3 #incorrect let "b = $a + 3" declare -i b=$a+$a Manipulating Strings String is a number if [[ $var =~ ^-?[0-9]+$ ]]; then echo "$var is a number" fi if [[ ! $var =~ ^-?[0-9]+$ ]]; then echo "$var is not a number" fi Find String between two words or characters var="Hello there are (123340) and (123)" #last string between '(' and ')'. substr=$( echo $var | sed 's/.*(\(.*\)).*/\1/' ) #String between '(' and ')'. substr=$( echo $var | awk -v FS="(\(|\))" '{print $2 " " $4}' ) #String between 'there' and 'and'. substr=$( echo $var | awk -v FS="(there|and)" '{print $2}' ) #String between 'there' and 'and'. substr=$( echo $var | sed 's/.*there\(.*\)and.*/\1/' ) #String between 'there' and 'and'. substr=$( echo $var | grep -o -P '(?<=there).*(?=and)' ) Loop read variables #read from file echo "123, abc, hello world!" > /tmp/test echo "12 43, ddd, !" >> /tmp/test while IFS=',' read var1 var2 var3 do echo "var1=$var1 var2=$var2 var3=$var3" done < "/tmp/test" #read from variable x="one, two, three" while IFS=',' read var1 var2 var3 do echo "var1=$var1 var2=$var2 var3=$var3" done <<< $x iterate IP address #iterate class C ip address for i in 192.168.100.{1..10} do echo "$i" done #iterate class B ip address for x in 192.168.{1..5} do for i in $x.{1..10} do echo "$i" done done infinite while loop while : do echo "infinite loops [ CTRL+C to stop]" sleep 5 done Array # Simple array arrayA=( Mon Tue Wed Thu Fri Sat Sun ) echo "${!arrayA[*]}" # 0 1 2 3 4 5 6 echo "${#arrayA[*]}" # 7 echo "${arrayA[*]}" # Mon Tue Wed Thu Fri Sat Sun echo "${!arrayA[@]}" # 0 1 2 3 4 5 6 echo "${#arrayA[@]}" # 7 echo "${arrayA[@]}" # Mon Tue Wed Thu Fri Sat Sun echo "${arrayA[2]}" # Wed echo "$arrayA" # Mon echo "${arrayA[20]}" # null arrayA=( one two ) echo "${arrayA[*]}" # one two arrayA+=( three "four" ) echo "${arrayA[*]}" # one two three four # Key/Value declare -A arrayB=( ["Mon"]="Monday" ["Tue"]="Tuesday" ["Wed"]="Wednesday" ["Thu"]="Thursday" ["Fri"]="Friday" ["Sat"]="Saturday" ["Sun"]="Sunday" ) echo "${!arrayB[*]}" # Thu Tue Wed Mon Fri Sat Sun echo "${#arrayB[*]}" # 7 echo "${arrayB[*]}" # Thursday Tuesday Wednesday Monday Friday Saturday Sunday echo "${!arrayB[@]}" # Thu Tue Wed Mon Fri Sat Sun echo "${#arrayB[@]}" # 7 echo "${arrayB[@]}" # Thursday Tuesday Wednesday Monday Friday Saturday Sunday echo "${arrayB[2]}" # null echo "$arrayB" # null echo "${arrayB["Tue"]}" # Tuesday declare -A arrayB=( ["one"]=1 ["two"]="2" ) echo "${!arrayB[*]}" # one two echo "${arrayB[*]}" # 1 2 arrayB+=( ["three"]="3" ["four"]=4 ) echo "${!arrayB[*]}" # four one two three echo "${arrayB[*]}" # 4 1 2 3 arrayB+=( ["four"]="aa" ["five"]="5a1c" ) echo "${!arrayB[*]}" # four one five two three echo "${arrayB[*]}" # 4aa 1 5a1c 2 3 I/O redirection Forking Processes pid_perfix="/tmp/proc-" function doSomething(){ local pid_file="$pid_perfix$BASHPID" echo "this is task $1 : $pid_file " > $pid_file sleep 5 } w_pid="" for task in {1..5} do doSomething $task & w_pid+="$! " sleep 1 done for p in $w_pid do wait $p done #clean up for p in $w_pid do #del pid file rm "$pid_perfix$p" done exit 0
Use RRDTool monitor Raspberry Pi, include CPU temperture, Memory usage, Disk I/O, Network I/O… Install install packages $sudo apt-get install libcairo2-dev libpango1.0-dev libglib2.0-dev libxml2-dev \ librrd-dev python2.7-dev rrdtool python-rrdtool $wget https://pypi.python.org/packages/source/p/psutil/psutil-2.1.1.tar.gz $tar xf psutil-2.1.1.tar.gz $cd psutil-2.1.1 $sudo python setup.py install Download or clone rpi-monitor on github https://github.com/oopsmonk/rpi-monitor Setup Crontab By defualt, the cron.log is disabled in Raspbian. To enable it: sudo vi /etc/rsyslog.conf find the line and uncomment it. # cron.* /var/log/cron.log Restart rsyslog via: ...
起司麵包 綜合麵包 平底鍋做麵包 戚風蛋糕 香蕉核桃馬芬蛋糕 鮭魚炒飯
This is a git tutorial, create svn upstream on GitHub. Use MOC project as a example. #Checkout SVN and push to GitHub. Install packages $ sudo apt-get install subversion git-svn Create git repository (it will take a long time) $ git svn clone svn://daper.net/moc/trunk --no-metadata ./moc-svn-git $ cat moc-svn-git/.git/config [core] repositoryformatversion = 0 filemode = true bare = false logallrefupdates = true [svn-remote "svn"] noMetadata = 1 url = svn://daper.net/moc/trunk fetch = :refs/remotes/git-svn Update SVN repository ...