Understand how Git works in 5 diagrams

Git has been a perfect choice for Version Control System. With git we can promptly switch between different revisions fromour project, logging every line changed from the code, and check the difference between any two revisions.

In this article I’m gonna explain you how Git objects, the most important part in Git, works.

Git Obejcts

If you have Git repositories in your computer, you must have noticed that there is a folder named .git in your root of the repository.

Read More

Install cx-Oracle on Mavericks correctly

cx-Oracle is a Python Oracle DB connection package, ealier today I met some trouble installing on my macbook running Mavericks, after hacking I found the means to install it correctly:

  1. Download instantclient-basic-macos.x64- and instantclient-sdk-macos.x64- from http://www.oracle.com/technetwork/topics/intel-macsoft-096467.html.
  2. Download the cx-Oracle source code from http://cx-oracle.sourceforge.net.

  3. Create a new directory to place the Oracle client files.

    mkdir -p /opt/oracle/

Read More

Contribute your project to the world: submit a package to PyPI

The PyPI(Python Package Index) is a repository of software for the Python programming language. There are currently 45k packages. Anyone can upload a Python project on it. Since your project being successfully uploaded, everybody in the world can simply install it by pip or easy_install. It’s significant to learn how to submit a project on PyPI.

Create the setup.py

Assume that you have a project named my_project, firstly you need to move it into an empty folder, then create a file named setup.py like this:


Read More

Improve you Python: what is metaclass?

The significance of understanding metaclass lies not in using itself, but in understanding what classes are in Python. For the purposes of this post, I will be talking about classes in Python, and try to explain what is metaclass.

Everything in Python is an object.

It is well-known that everything in Python is an object, and classes are used to create objects.

In fact, classes are objects too.

>>> class Dog(object):
... pass
>>> foo = Dog()
>>> type(foo)
<class '__main__.dog'>
>>> foo
<__main__.Dog object at 0x10baf0f10>

When we defined the classs Dog, Python created an object named Dog, and the object Dog is an object as well as an object creator.

Read More

Some questions you may be asked during a Python job interview.

It’s fairly easy to learn the Python syntax, but Python as a full-featured language, is not that easy to be fully mastered.

In my experience, these questions are the most likely be asked during a Python job interview, I wrote down the answers, hope that may help you!

**Q: What is lambda operator in Python, how do you use it?****

A: The lambda operator or lambda function is a way to create small anonymous functions

for example:

>>> f = lambda x, y : x + y
>>> f(2,2)

Read More

A fresh start

Recently I shut down my weblog, thinking about how to write articles with more influence. Then I decided to start a brand new blog, and this time I write articles only in English.

For years I’ve been blogging in Chinese, which developed me a bad habit: Always want to translate some nice stuff from English to Chinese, and rarely write something on my own. Due to this, I decided to start a English weblog where I write only original articles.

Besides, I write stuff for improving my English, English is the working language of the hacker culture and the Internet, for better take part in technical discussions, I must improve my fluency in English.

I will share my ideas and thoughts, continue writing interesting stuff here.

So this is the fresh start.