Sunday, October 30, 2011

install Plone 4.1.x

Ubuntu: 11.10

Install all the required package
sudo apt-get install build-essential
sudo apt-get install libssl-dev
sudo apt-get install libxml2-dev
sudo apt-get install libbz2-dev
sudo apt-get install libjpeg62-dev
sudo apt-get install libreadline6-dev
 
 
./install.sh --target=/home/vyang/opt/plone --with-python=/usr/bin/python2.6 standalone 

Tuesday, October 25, 2011

Install RVM and Ruby



rvm, virutualenv

Remove ubuntu's ruby-rvm

sudo apt-get --purge ruby-rvm

Install 

curl -L https://get.rvm.io | bash -s stable
rvm list known
rvm install 1.9.3-head

Configuration (.bashrc)

 PATH=$PATH:$HOME/.rvm/bin # Add RVM to PATH for scripting
source /home/victor.yang/.rvm/scripts/rvm




Install sproutcore

 Ubuntu 11.10

Step 1 has be done before step 2, otherwise the ruby will complain about "zlib not installed"

  1. apt-get install zlib1g-dev libssl-dev libreadline5-dev libxml2-dev libsqlite3-dev
  2. Follow steps in install sproutcore on linux



Monday, October 24, 2011

install sun-jdk 6, 7 on Ubuntu 12.04

 
http://www.devsniper.com/ubuntu-12-04-install-sun-jdk-6-7/
 
sudo update-alternatives --config java
sudo update-alternatives --config javac
 
sudo update-alternatives --install "/usr/bin/java" "java" "/usr/lib/jvm/jdk1.7.0/bin/java" 1
sudo update-alternatives --install "/usr/bin/javac" "javac" "/usr/lib/jvm/jdk1.7.0/bin/javac" 1
sudo update-alternatives --install "/usr/bin/javaws" "javaws" "/usr/lib/jvm/jdk1.7.0/bin/javaws" 1 

Tuesday, October 11, 2011

Python study notes

python overview
  • abstraction: 
    • type: dynamic binding, strong type(for catching bugs)
    • object is first class:objects can be freely passed around, inspected, and placed in various data structures (e.g., lists or dictionaries) at run-time.
  • organizing code: package, module, class,method, function. 
  • flow control: if/else,while, iterator,generator, coroutine
  • error handling: try/except/finally
History of Python builtin types   
  • Influenced by ABC

python user defined class design
  • runtime data structure of instances and class, inheritance
    • instance dict, class dict
  • why "self" is needed
  • class implementation requires no special syntax: just a collection of functions (methods), variables (class variables), computed attributed(properties).  
  • new style classes
    • __new__(cls,*args,**kwargs) is used for change value for subclassing immutable type  
  • Attributes,Properties and Descriptors 
  • History of descriptor,staticmethod, classmethod, property
  • metaclass explained: metaclass 
    • type(name, bases, dict) Return a new type object. This is essentially a dynamic form of the class statement. Python will look for __metaclass__ in the class definition. If it finds it, if will use it to create the object class Foo. If it doesn't, it will use type to create the class.
       

object is first class
  • how to make method first class? via bound and unbound method
every statement is treated the same
  • benefit: share the same grammar rule, and hence the compiler could use the same byte code generation function for all of them.
exception design
  • early days implemented as string token (from Modula-3) 
  • user defined class as replacement


Monday, October 10, 2011

cpython source code study note





Python 2.7.2 source code
  • main():Modules/python.c 
  • Py_Main():Modules/main.c
  • Py_Initialize(): Python/pythonrun.c
    • PyRun_SimpleFileExFlags
    • PyRun_FileExFlags
      • PyParser_ASTFromFile returns AST module
        • Parser build CST: PyParser_ParseFileFlagsEx: Parser/parsetok.c
        • Transform CST to AST: PyAST_FromNode(): Python/ast.c
      • run_mod(mod) 
        • PyAST_Compile(mod) compile AST into byte code
        • PyEval_EvalCode runs the byte code
    • create first interpreter PyInterperterState_New()
    • create first thread PyThreadState_New()
    • initialize __builtin__ module: _PyBuiltin_Init()
    • initialize sys module: _PySys_init()