This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# pre-requisities: sudo apt-get install libsvga1 libsvga1-dev | |
gcc -lvga helloworld.c -o helloworld | |
sudo ./helloworld | |
# output: | |
# (on screen: a small red point displaying for 5 sec) | |
# (on console: [svgalib: allocated virtual console #8]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- Add following content in .config/openbox/rc.xml --> | |
<!-- After saving, execute "openbox --reconfigure" to refresh --> | |
<!-- Ref: https://wiki.archlinux.org/index.php/Openbox#Window_snap_behaviour --> | |
<keybind key="W-Left"> | |
<action name="UnmaximizeFull"/> | |
<action name="MaximizeVert"/> | |
<action name="MoveResizeTo"> | |
<width>50%</width> | |
</action> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -e | |
LOGFILE=/var/log/apps/djangostart/console.log | |
LOGDIR=$(dirname $LOGFILE) | |
NUM_WORKERS=3 | |
# user/group to run as | |
USER=ubuntu | |
GROUP=ubuntu | |
cd /home/ubuntu/apps/djangostart/ | |
# setup |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# open a browser and view raw html (e.g. "cat some.html | viewhtml") | |
alias viewhtml='firefox "data:text/html;charset=utf-8;base64,$(base64 -w 0 <&0)"' | |
# url encode / decode | |
alias urlencode='python -c "import sys, urllib as ul; print ul.quote_plus(sys.argv[1])"' | |
alias urldecode='python -c "import sys, urllib as ul; print ul.unquote_plus(sys.argv[1])"' | |
# url shortener | |
alias shortenurl="python -c \"import sys, urllib as ul; print ul.urlopen('http://tinyurl.com/api-create.php?url=%s' % ul.quote_plus(sys.argv[1])).readline()\"" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[helloworld] | |
name = Terry |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# it depends on aliyun-oss SDK here | |
# http://help.aliyun.com/view/13438815.html | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import subprocess | |
def run_program(cmdargs): | |
"""Execute an OS program with arguments(in list form), and return the (returncode, stdout, stderr) result""" | |
p = subprocess.Popen(cmdargs, stdout=subprocess.PIPE, stderr=subprocess.PIPE) | |
output = p.communicate() | |
return p.returncode, output[0], output[1] | |
# example; | |
# run_program(['ls', '-l']) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/python | |
import subprocess, sys, re | |
PROGRAM_NAME = 'SmartRFProgConsole.exe' | |
FIRMWARE_NAME = 'test.hex' | |
# The Return Codes: | |
# 0 = Success | |
# 1 = System error | |
# 2 = Parameter error |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# (book part 1) | |
for i in {1..101} | |
do | |
wget "http://mylib.nlc.gov.cn/system/doc/pdfBooks/books/9831679/20120824_05/1302019/$i" -O "001_$i.pdf" | |
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
domain_name = '<domain_name>' | |
bucket_name = '<bucket_name>' | |
import qiniu.conf | |
qiniu.conf.ACCESS_KEY = '<qiniu_access_key>' | |
qiniu.conf.SECRET_KEY = '<qiniu_secret_key>' | |
import qiniu.rs, qiniu.rsf | |
import os, urllib, sys |