Posts

Showing posts from August, 2012

[ Level One ] Watch mp4 video on Google Chrome on Ubuntu 12.04

When you install Google Chrome on Ubuntu 12.04, you might not watch mp4 video by Chrome, that's because you didn't install mpeg codec. (Ex. The online courses of Coursera) You could install ffmpeg-extra for chromium by apt-get command like below: $ sudo apt-get -y install chromium-codecs-ffmpeg-extra $ Wish this helps. regards, Stanley Huang

[ Level 2 ] Share terminal in Ubuntu

How to share terminal in Ubuntu terminal 1: $ id uid=1000(stanley) ... $ sudo chmod u+s /usr/bin/screen $ sudo chmod 755 /var/run/screen $ screen -S screen-share $ [ctrl + a] :multiuser on $ [ctrl + a] :acladd joseph terminal 2: $ ssh joseph@localhost $ screen -x stanley/screen-share Ref: http://blog.bodhizazen.net/linux/shared-ssh-sessions-update-for-jaunty-ubuntu-904/ http://www.pixelbeat.org/docs/screen/ #!/bin/bash -vx showUsage() { cat <<EOF Usage: $0 [session name] [multi user] Ex. $0 session guest HowTO connect from guest: \$ ssh guest@remote_host \$ guest> screen -x [session holder]/[session name] \$ guest> screen -x stanley/screen-share EOF } main () { if [ $# -lt 2 ] then showUsage exit 1 else pgName="`basename $0 | cut -d. -f1`" session="$1" user="$2" cfFile="/tmp/$pgName.cnf" cat /dev/null > $cfFile echo "multiuser on" >> $cfFile echo &

[ Level 3 ] Python config factory with __subclasses__.

It's a sample code for use __subclasses__ to validate the type. I write a config factory utility #!/bin/env python import os, sys if './' not in sys.path: sys.path.append('./') if './lib' not in sys.path: sys.path.append('./lib') if '../lib' not in sys.path: sys.path.append('../lib') if os.getcwd()+'/lib' not in sys.path: sys.path.append(os.getcwd()+'/lib') import yaml, json from libproperty import * from StringIO import StringIO from abc import * ## Property Abstract Class ## Subclass naming rule: xxxProperty. (e.g. JavaProperty, YamlProperty) class CommonProperty(object): __metaclass__ = ABCMeta def __init__(self, FILE=None): self._prop_file_output = self._prop_file = FILE self._prop = None pass @staticmethod def isValidType(type): return '%sProperty' % type in [ c.__name__ for c in CommonProperty.__subclasses__() ] @abstractmethod def save(self, FI