Raspberry Pi Setup

Install Raspbian “wheezy” image Download image from Raspberry Pi offical website Mount HOME to HDD Copy HOME data to disk $ sudo mkdir /media/new_home $ sudo mount /dev/sda1 /media/new_home $ sudo rsync -aXS /home/. /media/new_home/. $ sudo umount /media/new_home fstab #get disk UUID $ sudo blkid /dev/mmcblk0p1: SEC_TYPE="msdos" LABEL="boot" UUID="936C-7122" TYPE="vfat" /dev/mmcblk0p2: UUID="c1198422-7a7c-4863-8a8f-45a1db26b4f2" TYPE="ext4" /dev/sda1: UUID="2cd990b5-6c27-4933-95d0-fd00b000fe77" TYPE="ext4" #modify fstab $ echo "UUID=2cd880b5-6c27-4933-95d0-fd00b000fe77 /home ext4 defaults 0 2" | sudo tee --append /etc/fstab #mount HOMW without reboot. $ sudo mount -a Create a sudo user #create user with HOME directory $ sudo useradd -m oopsmonk #add user to sudo group $ sudo adduser oopsmonk sudo #set password $ sudo passwd oopsmonk Install necessary packages $ sudo aptitude full-upgrade -y $ sudo aptitude install tmux vim git python-setuptools -y $ sudo easy_install pip SAMBA server $ sudo aptitude install samba $ sudo cp /etc/samba/smb.conf /etc/samba/smb.conf.bak $ sudo vi /etc/samba/smb.conf enable sucurity user # security = user [rpi] comment = raspberry-pi path = /home/oopsmonk/ browseable = yes writable = yes read only = no #add smaba user and restart samba server $ sudo pdbedit -a -u oopsmonk $ sudo service samba restart Configre default editor $ echo "export EDITOR=vim" >> ~/.bashrc $ echo "export GIT_EDITOR=vim" >> ~/.bashrc $ echo "export TERM=screen-256color" >> ~/.bashrc $ echo "alias tmux='tmux -2'" >> ~/.bashrc $ source ~/.bashrc Boot from USB Disk Use dd or Win32DiskImager dump image to both SD card and USB Disk. ...

June 15, 2013 · 5 min · oopsmonk

Add Git SHA1 property in Apache ANT build.xml

Create git.SHA1 property in build.xml file. <available file=".git" type="dir" property="git.present"/> <target name="git.info" description="Store git info" if="git.present"> <exec executable="git" outputproperty="git.SHA1" failifexecutionfails="false" errorproperty=""> <arg value="log"/> <arg value="--pretty=oneline"/> <arg value="-n1"/> </exec> <condition property="git.version" value="${git.SHA1}" else="unknown"> <and> <isset property="git.SHA1"/> <length string="${git.SHA1}" trim="yes" length="0" when="greater"/> </and> </condition> <echo message="print git log : " /> <echo message="${git.SHA1}" /> </target> Reference: How to lookup the latest git commit hash from an ant build script

June 13, 2013 · 1 min · oopsmonk

Nginx Error - 413 Request Entity Too Large

nginx version: nginx/1.1.19, OS: Ubuntu12.04 Default nginx accepted body size limitation is 1MB. You can add client_max_body_size in nginx.conf. This parameter can put in http, server and location sections of configutation file. Enlarge body size to 10MB client_max_body_size 10M Or just disable it client_max_body_size 0 For example enlarge body size to 10MB Add to http section: $ sudo vi /etc/nginx/nginx.conf http { ## # Basic Settings ## sendfile on; tcp_nopush on; tcp_nodelay on; keepalive_timeout 65; types_hash_max_size 2048; client_max_body_size 10M; # server_tokens off; # server_names_hash_bucket_size 64; # server_name_in_redirect off; include /etc/nginx/mime.types; default_type application/octet-stream; ... } Or modify server and location section ...

June 5, 2013 · 1 min · oopsmonk

AWS S3 Download Bucket Folder

Currently, AWS web console not provide folder downloading. We can use s3cmd or s3Browser for this purpose. s3Browser is a freeware Windows client for S3 and CloudFront. s3cmd download Bucket folder: s3cmd sync s3://bucketname/folder /local/folder For download files using s3Browser, here is a tutorial. Uploading and Downloading Files to and from Amazon S3

May 28, 2013 · 1 min · oopsmonk

Web Micro Framework Battle

WSGI Micro Framworks 這陣子一直在找適合的Micro Framwork玩第一次的Web Application. 最後選擇用Bottle, 原因是: Single file module, no dependencies with other library. Document 但是好不好用又是另一回事, 用了就知道..XD 以下是由WSGI.org列出的Micro Framwork: bobo Bobo is a light-weight framework. Its goal is to be easy to use and remember. Bottle Bottle is a fast and simple micro-framework for small web-applications. It offers request dispatching (Routes) with url parameter support, Templates, key/value Databases, a build-in HTTP Server and adapters for many third party WSGI/HTTP-server and template engines. All in a single file and with no dependencies other than the Python Standard Library. ...

May 27, 2013 · 1 min · oopsmonk

Pandoc's Markdown Reference

#### [2015-02-12]This article doesn't render properly since I switched from Google Blogger to Github Pages. I won't fix this problem. Pandoc實現了基本的Markdown語法外, 還加了一些extention. 細節可參考: [Pandoc's Markdown][pmd] [Markdown語法][mdsyntax] [Markdown:Syntax][mds] [Pandoc Markdown and ReST Compared][MDcmpReST] Headers (Setext and atx) Setext-style只有兩階也就是HTML語法裡的h1及h2 tag,-跟=的個數沒有限制. atx-style共有6階, h1~h6. # This is H1. ## This is H2. ### This is H3. #### ... ###### This is H6. 除了階層較多之外, atx-style還可以使用Markdown syntax. ###This is *H3* header. Output: This is H3 header. Inline Formatting Basic Emphasis 斜體字: *, _ , 粗體字: **, __, ...

May 23, 2013 · 7 min · oopsmonk

uWSGI & Nginx on Ubuntu

Install uWSGI Configure uWSGI $ sudo apt-get install python-dev python-pip $ sudo pip uwsgi ################# uWSGI configuration ################# pcre = False kernel = Linux malloc = libc execinfo = False ifaddrs = True ssl = True matheval = False zlib = True locking = pthread_mutex plugin_dir = . timer = timerfd yaml = True json = False filemonitor = inotify routing = False debug = False zeromq = False capabilities = False xml = expat event = epoll ############## end of uWSGI configuration ############# *** uWSGI is ready, launch it with /usr/local/bin/uwsgi *** Successfully installed uwsgi Cleaning up... $ Test uWSGI Create test file called hello.py: ...

May 21, 2013 · 1 min · oopsmonk