Mar 18, 2012

OpenSSH configuration file

Putty is a lovely ssh program, but I love console2 even more.

To use ssh to connect to Amazon EC2 server, you need cygwin to run openssh in Windows environment.
The command is (under cygwin):

ssh -i MySite.pem ubuntu@xxx.amazonaws.com
To make the command shorter, create "~/.ssh/config"
and add:

Host MySite
User ubuntu
Port 22
IdentityFile ~/.ssh/MySite.pem
HostName xxx.amazonaws.com

To connect, just type:

ssh MySite

Mar 16, 2012

Setting selective sync of Dropbox on Amazon EC2 server

Dropbox provides an easy to backup the server. However, the default setting synchronizes all of the files to the server, which is very annoying.
I don't want all of my personal stuff to be stored in a public server.

In order to select the file which you would like to sync, download dropbox.py
and type the following commands in the terminal:
python dropbox.py exclude add ~/Dropbox/*
python dropbox.py exclude remove ~/Dropbox/<folder-to-sync> 

The first command excludes all of files from your dropbox.
The second one adds the folder which is going to be synchronized.

Mar 7, 2012

Setting up Django on ubuntu



Here are the steps to setup Django on Amazon EC2 server:
The image is ubuntu-maverick-10.10-amd64-server-20101225
Choose the ebs one, otherwise you will lose everything after you shutdown your server
  1. sudo apt-get update
  2. sudo apt-get install apache2
  3. wget http://www.djangoproject.com/download/1.3/tarball/
  4. mv index.html Django-1.3.tar.gz
  5. tar xzvf Django-1.3.tar.gz
  6. cd Django-1.3
  7. sudo python setup.py install
  8. sudo  apt-get install libapache2-mod-wsgi
  9. create "/home/ubuntu/mysite/django-server.wsgi"
  10. import os, sys
    sys.path.append('/home/ubuntu/')
    sys.path.append('/home/ubuntu/mysite')
    os.environ['DJANGO_SETTINGS_MODULE'] = 'mysite.settings'
    import django.core.handlers.wsgi
    application = django.core.handlers.wsgi.WSGIHandler()
  11. sudo /etc/init.d/apache2 start
  12. cd  /etc/apache2/sites-available
  13. sudo cp  default mysite
  14. edit "mysite"
  15. Listen 8000
    <VirtualHost *:8000>
            WSGIScriptAlias / /home/ubuntu/mysite/django-server.wsgi
            WSGIDaemonProcess server1piece user=www-data group=www-data processes=1 threads=10
            ServerAdmin webmaster@localhost
            DocumentRoot /home/ubuntu/
            Alias /static/admin/ /home/ubuntu/Django-1.3/django/contrib/admin/media/
  16. a2ensite mysite
  17. sudo /etc/init.d/apache2 reload
  18. sudo /etc/init.d/apache2 restart
  19. cd ~
  20. django-admin startproject mysite
  21. cd ~/mysite
  22. django-admin startapp myapp 
  23. python manage.py runserver 0.0.0.0:8000

Dec 10, 2011

Open source software for Windows Mobile


Just played around my phone, and saw a list of "software disclaimer", that includes:

  1. Boost
  2. FreeImage
  3. Lua
  4. Luabind
  5. OpenGL
  6. STLPort 5.0
  7. RapidXML
  8. SWIG
  9. BString
It seems that open source softwares are something that all developers should know. Especially non-GPL ones

Nov 17, 2011

My Google Chrome extensions

Here is the list of my Chrome extensions:

1. Google Mail Checker
2. Google Dictionary
3. Yet Another Google Bookmarks Extension
4. Evernote : Google Notebook is the best online notebook, but Google has stopped to its support. Evernote is an acceptable replacement, but not as easy-to-use as Google Notebook. Evernote is my temporary solution for now.

Goodbye Firefox!!!

Firefox was a good browser. However, the newer versions of Firefox have very poor compatibility with existing extensions. I am tired of finding new extensions for every new update. New technologies should help us finish our tasks efficiently, instead of giving us more tasks to do.

My #1 candidate for browser is Google Chrome. It is fast, stable and has the replacements for all of  my current Firefox extensions. Good job Google!

Jul 11, 2011

A Sleep function for VIM

I need to let VIM wait for cscope.exe to rebuild the tag file, but there are no build-in sleep function for VIM, so I made one here:

"a sleep function which allows vim to wait for the other processes to finish
com! -complete=command -nargs=+ Sleep call s:Sleep(<q-args>)
fun! s:Sleep(millisec)
  let ct = localtime()
  let dt = 0
  while dt < (a:millisec/1000)
    let dt = localtime() - ct
  endwhile
endfun

Just put it into your _vimrc.
To invoke it, type ":Sleep 10000" to let VIM wait for 10 secs.

 
TEMPLATE HACKS AND TWEAKS BY [ METAMUSE ] BLACKCAT 1.1
/scripts/shBrushJScript.js'/>