Coder's notes

For your infomation

Screen tutorial (Fedora Linux)

If you work on terminal a lot, you might find screen is useful. Screen provides a virtual terminal which supports multiple windows, copy paste, etc. and it’ll continue to run after you have closed the real terminal you are working on. It’s distributed with most Linux distro so it’s most likely that you won’t have to install it. Just type screen to run. If it was not pre-installed or you want to update it to latest version you can try:

Fedora: sudo -c “yum install -y screen”

Ubuntu: sudo apt-get install screen

After you have started screen just type echo $STY. If you see something like 3002.pts-0.localhost you’ll know that you are inside a screen.

The features that I find most useful of screen are creating/switching/closing windows and copy paste. Let’s try these first.

Multiple windows

If you press Ctrl+a Ctrl+c (keep pressing Ctrl while you press a and then c) you can create a new screen. To switch between windows, you can try Ctrl+c Ctrl+” (double quotes) to show windows list, use arrow keys to navigate around, and then press Enter to select the windows that you want. An alternative method is to press Ctrl+[0-9] to activate the windows you want to (start from 0).

Copy paste & screen scrolling

If you want to copy paste a part on the screen, press Ctrl+a Ctrl+[ to activate copy-paste mode. After that you can use arrow keys to move around. You may use space to mark the start point and the end point. After you have marked the end point copy-paste mode will be deactivated. You also can deactivate this mode using ESC key (I often use this to scroll up and down the current window). Pasting can be done simply by pressing Ctrl+a Ctrl+]

Starting, detach and resume a screen session

To detach from a screen session, you can press Ctrl+a Ctrl+d (detaching). The screen will continue to run in the background. You can quit screen completely by Ctrl+a Ctrl+\

If you want to resume a screen session that running in the background, type screen -dr into the terminal.

Further reading

Now you knew enough to use screen. There are many more features in screen user manual at:


Javascript Game Engines

More ways to write Javascript

Javascript Design Patterns

Create Excel File with Python

Install Xlsx

$ git clone
$ cd XlsxWriter
$ sudo python install


import xlsxwriter

workbook = xlsxwriter.Workbook('hello.xlsx')
worksheet = workbook.add_worksheet()

worksheet.write('A1', 'Hello world')


Create a simple site with Python, CGI, Apache 2 on Fedora

  • su to become root
  • Create the following directory structure
    • /var/www/mysite
      • cgi-bin
      • html
        • index.html
  • Sample content for

    print(“Content-type: text/html\n”)
    Hello Python CGI <br/><a href=’../’>Home</a>

  • Sample content for index.html
    Home <br/>
    <a href=’cgi-bin/’>CGI</a>
  • If you use SQLite, create a sample database file.
  • edit /etc/httpd/conf/httpd.conf, add the following code to the end of the file
    ScriptAlias /mysite/cgi-bin/ /var/www/mysite/cgi-bin/
    Alias /mysite/html /var/www/mysite/

    <Directory “/var/www/mysite/cgi-bin/”>
    AddHandler cgi-script .py
    AllowOverride None
    Options +Indexes +ExecCGI
    Order allow,deny
    Allow from all

    <Directory “/var/www/mysite/”>
    AllowOverride None
    # Allow open access:
    Require all granted

  • Run the following code in the terminal
    chcon -h -t httpd_sys_content_t /var/www/mysite/cgi-bin/
    # You need this line if you want to write to a database file
    chcon -h -t httpd_sys_content_rw_t /var/www/mysite/cgi-bin/database.db
    chcon -h -t httpd_sys_script_exec_t /var/www/mysite/cgi-bin/*.py
    chgrp apache /var/www/mysite/html -R
    chmod uo+r /var/www/mysite/html -R
    chmod uo+x /var/www/mysite/cgi-bin -R
  • Now try to start server by typing
     service httpd start
  • Go to your website from your browser at: http://localhost/mysite/

Using Git

Clone project `foo’ of user `user‘ from Github

git clone --recursive

Add a submodule into a repository

git submodule add
git submodule init
git submodule update

Undo modification

git checkout -- [filename]

Update submodule to latest version

git fetch && git checkout master && git merge origin/master

Generate SSH key for passwordless push to Github


ls -al ~/.ssh
ssh-keygen -t rsa -C ""
eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_rsa

# Now add key to Github account (~/.ssh/

# Test connection
ssh -T

# Update the repository remote URL to SSH
git remote set-url origin
git remote -v

LaTeX on Windows

  • Install MikTeX
  • Install TeXMaker
  • Use embedded PDF viewer
    Option > Configure TexMaker > Commands > PDF viewer > Embed (click photo to zoom)texmaker embedded

LaTeX for linguistics

Blog at

Up ↑