Coder's notes

For your infomation


Web Development

HTML, Javascript, CSS, jQuery, etc.

Using webmode with Emacs

Want better HTML editing features for Emacs? Not happy with Jinja template editing in Emacs? Try this and you won’t be disappointed.

Download web-mode.el from to your local folder (e.g. ~/.emacs.d/custom-modes).

mkdir ~/.emacs.d/custom-modes
wget -P ~/.emacs.d/custom-modes

Now open~/.emacs and add the following lines

(add-to-list 'load-path "~/.emacs.d/custom-modes")

(require 'web-mode)
(add-to-list 'auto-mode-alist '("\\.phtml\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.tpl\\.php\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.[agj]sp\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.as[cp]x\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.erb\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.mustache\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.djhtml\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.html?\\'" . web-mode))

;; Indentation for web-mode.el
(setq web-mode-markup-indent-offset 2)
(setq web-mode-css-indent-offset 2)
(setq web-mode-code-indent-offset 2)

Restart Emacs. Now try to edit any HTML, CSS or Jinja template file 🙂


Javascript Game Engines

More ways to write Javascript

Javascript Design Patterns

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/

Create a free website or blog at

Up ↑