This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Dirty configuration for hosting multiple websites on the same server. Note: Just for development only | |
## Add /etc/nginx/sites-enabled/myconfig | |
server{ | |
server_name website1.com; | |
location / { | |
proxy_pass http://127.0.0.1:8888; | |
} | |
} | |
server{ | |
server_name website2.com; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Migration | |
$ python manage.py makemigrations <app_name> | |
$ python manage.py migrate <app_name> | |
# Time zone for Vietnam | |
## Change in settings.py | |
TIME_ZONE = 'Asia/Ho_Chi_Minh' | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ sudo pip install pip | |
$ sudo pip install django | |
$ sudo apt-get install python-mysqldb | |
$ django-admin startproject <project> | |
# Edit settings.py | |
INSTALLED_APPS = ( | |
'<project>', | |
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Create database for storing Vietnamese | |
mysql> CREATE DATABASE `dbname` CHARACTER SET utf8 COLLATE utf8_general_ci; | |
# Export and import database | |
$ mysqldump -u username -p dbname > db_backup.sql | |
$ mysql -u username -p -h hostname dbname < data.sql | |
# Display each row of the query result in line-by-line instead of table format: | |
mysql> select * from tablename \G; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# https://github.com/django-ckeditor/django-ckeditor | |
$ sudo pip install django-ckeditor | |
# Edit settings.py | |
Add 'ckeditor' to your INSTALLED_APPS setting. | |
Add: | |
STATIC_URL = '/static/' | |
STATIC_ROOT = os.path.join(BASE_DIR, 'static') # <app_dir>/static | |
MEDIA_URL = '/static/uploads/' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
SCRIPTPATH=$(cd "$(dirname "$0")"; pwd) | |
"$SCRIPTPATH/bhm" -importPath bhm -srcPath "$SCRIPTPATH/src" -runMode prod |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import ( | |
"os" | |
"log" | |
"fmt" | |
"flag" | |
"encoding/json" | |
) | |
type Configuration struct { | |
Host string |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Logging | |
import ( | |
"log" | |
"time" | |
) | |
func response(rw http.ResponseWriter, r *http.Request) { | |
rw.Write([]byte("Hello world!")) | |
log.Printf(time.Now().String(), r.Method, r.URL.String()) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Get path of directory in which the script is stored | |
DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd ) | |
echo $DIR | |
# Use content of a file as argument | |
kill -9 $(<./thin.pid) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Note: | |
# RVM does not control the system Ruby or its gems. Only Rubies and gems installed by RVM are under it's control! | |
# Install RVM | |
$ gpg --keyserver hkp://keys.gnupg.net --recv-keys D39DC0E3 | |
$ \curl -sSL https://get.rvm.io | bash -s stable --ruby | |
$ source /home/ubuntu/.rvm/scripts/rvm | |
# Install a Ruby version | |
$ rvm install ruby-1.9.3 |