https://www.gravatar.com/avatar/f819a092b23cb25a09f87436f68df217?s=240&d=mp

Ang Gao

Software Engineer @ TripAdvisor, CS Ph.D @ University College Cork

Pelican basic

Installation 1 pip install pelican markdown Create a skeleton project 1 pelican-quickstart Create an article 1 2 3 4 5 Title: My First Review Date: 2010-12-03 10:20 Category: Review Following is a review of my favorite mechanical keyboard. Generate your site 1 pelican content Preview your site 1 2 3 cd ~/projects/yoursite/output python -m SimpleHTTPServer navigating to http://localhost:8000

Python Note Four

sys module argv command line arguments, including file name exit([arg]) exits the current program, optionality with a given number or error message. (if called within try/finally block, the finally clause is still executed) modules: a dictionary mapping module name to loaded module path: a list of directory names where modules can be found platform: a platform identifier such as sunos/win32 stdin stdout stderr os module

Python Note Three

Iterator protocol Objects that implements the __iter__ method, __iter__ returns an iterator object, which has a method called next (in PY3 __next__) return its “next value” And StopIteration raised when no more values to return. 1 2 3 4 5 6 7 8 9 10 class Fib: def __init__(self): self.a = 0 self.b = 1 def next(self): self.a, self.b = self.b, self.a + self.b return self.

Virtualenv and Virtualenvwrapper

virtualenv virtualenv is software for isolating python package environments (e.g. import paths). site-packages should mostly be for system-installed python and not python that you are installing as a user. [1] virtualenv ENV source ENV/bin/active Once the virtualenv is activated, the virtualenv’s python (and other executables) will be on your PATH and you will have a new environment variable, VIRTUAL_ENV, that points to the path of the virtualenv, as well as a deactivate function for deactivating the virtualenv [2].

Python Note Two

Polymorphism: even if you don’t know what kind of object a variable refer to, you may still able to perform operations on it, that will work differently depending on the class(type) of the object Polymorphism enables you to call the methods of an object without knowing its class (type of object). Encapsulation enables you to use the object without worrying about how it’s constructd. To make a method or attribute private (inaccessible from outside) simply starts its name with two underscores

jekyll configuration

insert pictures in the post add variable img_url: http://anggao.github.io/assets/images in _config.yml store pictures in assets/images refer a picture in the post by ![ruby]({{site.img_url}}/ruby.png}) support Latex add following code block in _layouts/default.html 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 <!-- MathJax Section --> <script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script> <script> MathJax.Hub.Config({ tex2jax: { skipTags: ['script', 'noscript', 'style', 'textarea', 'pre'] } }); MathJax.