Showing posts from May, 2015

[GIT] The git commands that I often use

I just list the git commands that I often use and keep in this document for reference.

// pull the newest commit from origin
git pull origin "your branch"

// check out to a branch
git checkout "your branch name"

// apply the diff file
gitapply "your diff file"

// Check the diff
gitdiff [your file]

// codecommit
git commit -a -m "This is bug."

// pushcommit to remote site,
git push "your remote site" "your branch"

// repository name
git remote rm origin
git remote add origin git@...git
git remote set-url origin git@...git

// add new remote repository name
git remote add "remote repository name" ssh://.......

//Force to go back the current newest commit
git reset --hard HEAD
HEAD^ // the previous commit
HEAD~2 // the previous two commit
git reset --hard eb2b844 // the previous a commit with your hash code
--soft // the change will be added to

[Django] The summary of "Writing your first Django app" in offical Django document

Well, if we want to really get understanding something, the best way is to study and do by yourself. The official Django web site gives us a very good example for those who are the first time to use Django. So this article is just the quick summary of this "Writing your first Django app" as follows:

Writing your first Django app, part 1
Writing your first Django app, part 2
Writing your first Django app, part 3
Writing your first Django app, part 4
Writing your first Django app, part 5
Writing your first Django app, part 6
Advanced tutorial: How to write reusable apps

$ django-admin startproject r300
$ python -m django --version
$ python -c "import django; print(django.get_version())"
$ django-admin startproject R300
$ python startapp demo
$ python migrate
$ python runserver

After finishing the above steps, we can get the file structure like the picture below:

This picture is about the polls application that looks like:

And this …

[Apache] Install Apache2 and mod_wsgi module

Install Apache Web Server
sudo apt-get install apache2 apache2-threaded-dev apache2-doc apache2-utils

Edit the main Apache configuration file to adjust the resource use settings./etc/apache2/apache2.conf

Install Support for Scripting ( Python )
sudo apt-get install libapache2-mod-python

An easy way to see which modules are installed is to run a list command on the directory:ls -al /etc/apache2/mods-available/

To enable an installed module, run the following command:a2enmod [module-name]

Install Apache Modules
sudo apt-get install libapache2-mod-wsgi

or to follow this intruction to compile and install from the source code:

Operate Apache Web Server
sudo apachectl restartsudo apachectl stopsudo apachectl start
Give a try with WSGI 

Add the following setting to /etc/apache2/sites-available/default
WSGIScriptAlias /myapp /home/liudanny/django_proj/

<Directory /home/liudanny/django_proj>
    Order allow,deny
    Allow from a…

[Python] A simple example of Python Egg

The following content is based on this article:

hello/ ==>
    def helloworld():
        print 'Hello World'

1. First, prepare your ==>
from distutils.core import setup # Distutils

        'hello': ['*.so'],

2.Run python sdist

3. Change a line in your ==>
#from distutils.core import setup # Distutils
from setuptools import setup, find_packages # Egg

        'hello': ['*.so'],

4. Run  python bdist_egg

5. Then you get a new file in your dist directory:

My example files and output package are here:

6. To install the egg file
> sudo easy_install hello-1.0-py2.7.egg
in cas…

[XorPlus] The verbose transaction of the commmand "set vlan-interface interface"

XorPlus# set vlan-interface interface vlan2 vif vlan2 address prefix-length 24
XorPlus# commit
Aug 28 2007 21:11:10 XorPlus local0.debug : [RTRMGR]Expanding xrl $(vlan-interface.targetname)/ifmgr/0.1/start_transaction->tid:u32=$(vlan-interface.TID)
Aug 28 2007 21:11:10 XorPlus local0.debug : [RTRMGR]Executing XRL: >finder://fea/ifmgr/0.1/start_transaction<
Aug 28 2007 21:11:10 XorPlus local0.debug : [RTRMGR]Expanding xrl $(vlan-interface.targetname)/ifmgr/0.1/create_interface?tid:u32=$(vlan-interface.TID)&ifname:txt=$(@)
Aug 28 2007 21:11:10 XorPlus local0.debug : [RTRMGR]Executing XRL: >finder://fea/ifmgr/0.1/create_interface?tid:u32=1523154&ifname:txt=vlan2<
Aug 28 2007 21:11:10 XorPlus local0.debug : [RTRMGR]Expanding xrl $(vlan-interface.targetname)/ifmgr/0.1/set_interface_enabled?tid:u32=$(vlan-interface.TID)&ifname:txt=$(interface.@)&enabled:bool=`~$(@)`
Aug 28 2007 21:11:10 XorPlus local0.debug : [RTRMGR]Executing XRL: >finder…

[Install] OpenGrok and Doxygen

Source tracing is a task/job that is heavily relied on good tool for software developers or programmers to fulfill their mission. My personal suggestions are OpenGrok and Doxygen. Here is not going to analysis their merits but just record my way to install them.

=== OpenGrok ===
Download Tomcat and start it up

$ tar zxvf apache-tomcat-7.0.61.tar.gz
$ cd apache-tomcat-7.0.61
$ bin/

Download OpenGrok binary

I put my source code under opengrok-0.12.1/src_code and directly use another way to integrate with Tomcat server as follows:
$ OPENGROK_TOMCAT_BASE=/home/liudanny/SourceCode/apache-tomcat-7.0.61 bin/OpenGrok deploy
$ sudo OPENGROK_TOMCAT_BASE=/home/liudanny/SourceCode/apache-tomcat-7.0.61 bin/OpenGrok index /home/liudanny/SourceCode/opengrok-0.12.1/src_code

Then we can see the result in the URL:


[Debian] Prepare Debian 7 with software development

This document is about the record for preparing Debian 7 with software development
=== Install the required packages ===
sudo apt-get install ctags
sudo apt-get install cscope
sudo apt-get install curl
sudo apt-get install autotools-dev
sudo apt-get install automake
sudo apt-get install subversion
sudo apt-get install libpam0g-dev
sudo apt-get install libtool
sudo apt-get install g++
sudo apt-get install libssl-dev
sudo apt-get install build-essential
sudo apt-get install linux-source
sudo apt-get install kernel-package
sudo apt-get install libncurses5-dev
sudo apt-get install make-kpkg
sudo apt-get install build-essential linux-source kernel-package libncurses5-dev
sudo apt-get install git python-dev python-virtualenv libssl-dev libffi-dev
sudo apt-get remove openjdk-6-jre-lib openjdk-6-jre-headless
#sudo apt-get -y install openjdk-7-jdk
echo "deb trusty main" | tee /etc/apt/sources.list.d/webupd8team-java.list
echo "deb…