Repos / hi.imnhan.com / ba1cb7ab96
commit ba1cb7ab96d8c5ef8d2283d4d2965c84c5ee447b
Author: nhanb <thanhnhan483@gmail.com>
Date:   Mon May 13 11:03:26 2013 +0700

    init

diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..f491c12
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,2 @@
+output/
+*.pid
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..39c9738
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,88 @@
+PY=python
+PELICAN=pelican
+PELICANOPTS=
+
+BASEDIR=$(CURDIR)
+INPUTDIR=$(BASEDIR)/content
+OUTPUTDIR=$(BASEDIR)/output
+CONFFILE=$(BASEDIR)/pelicanconf.py
+PUBLISHCONF=$(BASEDIR)/publishconf.py
+
+FTP_HOST=localhost
+FTP_USER=anonymous
+FTP_TARGET_DIR=/
+
+SSH_HOST=github.com
+SSH_PORT=22
+SSH_USER=git
+SSH_TARGET_DIR=nhanb/blog.git
+
+S3_BUCKET=my_s3_bucket
+
+DROPBOX_DIR=~/Dropbox/Public/
+
+help:
+	@echo 'Makefile for a pelican Web site                                        '
+	@echo '                                                                       '
+	@echo 'Usage:                                                                 '
+	@echo '   make html                        (re)generate the web site          '
+	@echo '   make clean                       remove the generated files         '
+	@echo '   make regenerate                  regenerate files upon modification '
+	@echo '   make publish                     generate using production settings '
+	@echo '   make serve                       serve site at http://localhost:8000'
+	@echo '   make devserver                   start/restart develop_server.sh    '
+	@echo '   make stopserver                  stop local server                  '
+	@echo '   ssh_upload                       upload the web site via SSH        '
+	@echo '   rsync_upload                     upload the web site via rsync+ssh  '
+	@echo '   dropbox_upload                   upload the web site via Dropbox    '
+	@echo '   ftp_upload                       upload the web site via FTP        '
+	@echo '   s3_upload                        upload the web site via S3         '
+	@echo '   github                           upload the web site via gh-pages   '
+	@echo '                                                                       '
+
+
+html: clean $(OUTPUTDIR)/index.html
+
+$(OUTPUTDIR)/%.html:
+	$(PELICAN) $(INPUTDIR) -o $(OUTPUTDIR) -s $(CONFFILE) $(PELICANOPTS)
+
+clean:
+	[ ! -d $(OUTPUTDIR) ] || find $(OUTPUTDIR) -mindepth 1 -delete
+
+regenerate: clean
+	$(PELICAN) -r $(INPUTDIR) -o $(OUTPUTDIR) -s $(CONFFILE) $(PELICANOPTS)
+
+serve:
+	cd $(OUTPUTDIR) && $(PY) -m pelican.server
+
+devserver:
+	$(BASEDIR)/develop_server.sh restart
+
+stopserver:
+	kill -9 `cat pelican.pid`
+	kill -9 `cat srv.pid`
+	@echo 'Stopped Pelican and SimpleHTTPServer processes running in background.'
+
+publish:
+	$(PELICAN) $(INPUTDIR) -o $(OUTPUTDIR) -s $(PUBLISHCONF) $(PELICANOPTS)
+
+ssh_upload: publish
+	scp -P $(SSH_PORT) -r $(OUTPUTDIR)/* $(SSH_USER)@$(SSH_HOST):$(SSH_TARGET_DIR)
+
+rsync_upload: publish
+	rsync -e "ssh -p $(SSH_PORT)" -P -rvz --delete $(OUTPUTDIR)/ $(SSH_USER)@$(SSH_HOST):$(SSH_TARGET_DIR) --cvs-exclude
+
+dropbox_upload: publish
+	cp -r $(OUTPUTDIR)/* $(DROPBOX_DIR)
+
+ftp_upload: publish
+	lftp ftp://$(FTP_USER)@$(FTP_HOST) -e "mirror -R $(OUTPUTDIR) $(FTP_TARGET_DIR) ; quit"
+
+s3_upload: publish
+	s3cmd sync $(OUTPUTDIR)/ s3://$(S3_BUCKET) --acl-public --delete-removed
+
+github: publish
+	ghp-import $(OUTPUTDIR)
+	git push origin gh-pages
+
+.PHONY: html help clean regenerate serve devserver publish ssh_upload rsync_upload dropbox_upload ftp_upload s3_upload github
diff --git a/content/modern-vim-plugin-management-pathogen-vs-vundle.md b/content/modern-vim-plugin-management-pathogen-vs-vundle.md
new file mode 100644
index 0000000..1bcc8da
--- /dev/null
+++ b/content/modern-vim-plugin-management-pathogen-vs-vundle.md
@@ -0,0 +1,279 @@
+Date: 2013-05-13
+Title: "Modern vim plugin management - Pathogen vs Vundle"
+Category: Blog
+Tags: tutorial
+Description: "Pimp your vim with little effort"
+
+
+For the impatient ones: Vundle is better than pathogen, use it.
+
+This post will explain how vim plugins work and how to easily manage your plugins with
+third-party tools: Pathogen or Vundle. I assume you are using a Linux distro and have git
+already installed. If not, consult Dr. Google for more details.
+
+## Vim plugins anatomy
+
+A vim plugin is simply a set of files that alter vim's behavior or add new functionalities to it.
+To make this possible, by default vim looks for files in your home folder (which is 
+`/home/username` or `~`):
+
+### ~/.vimrc (file)
+
+This is where you put your personalizations to vim: indentations, keybindings, etc. This post
+will not discuss in detail how you do your customizations. For now just know that it's there.
+
+You will probably want to move this file into your ~/.vim folder to be able to manage everything
+inside 1 folder. I will create `~/.vim/vimrc` then create a symlink pointing to it. Open a
+terminal and type:
+
+```bash
+ln -s ~/.vim/vimrc ~/.vimrc
+```
+
+### ~/.vim (directory)
+
+This should contain a bunch of subdirectories. Some examples:
+
+- autoload
+- ftplugin
+- colors
+- syntax
+- doc
+
+Each of these directories serves a particular purpose: `colors` contains colorschemes, `syntax`
+lets you add new rules for syntax highlighting, `doc` contains documentation...  
+A plugin will typically put its files into more than one directory here. For example, here is
+a plugin called [tagbar](https://github.com/majutsushi/tagbar), and I've installed it by
+copying its content into my `~/.vim` folder:
+
+```
+~/.vim
+├── autoload
+│   └── tagbar.vim
+├── doc
+│   ├── tagbar.txt
+│   └── tags
+├── plugin
+│   └── tagbar.vim
+├── README
+└── syntax
+    └── tagbar.vim
+```
+
+Everything looks good. Just copy and paste the whole thing, nice and simple. How about adding a
+decent colorscheme? Let's install [solarized](https://github.com/altercation/vim-colors-solarized):
+
+```
+├── autoload
+│   └── togglebg.vim
+├── bitmaps
+│   └── togglebg.png
+├── colors
+│   └── solarized.vim
+├── doc
+│   ├── solarized.txt
+│   └── tags
+└── README.mkd
+```
+
+Wait, `doc/tags` is already there. Ok, no problem! Let's just copy the content of solarized's
+tags file and paste it into the existing one. Now we have:
+
+```
+~/.vim
+├── autoload
+│   ├── tagbar.vim
+│   └── togglebg.vim
+├── bitmaps
+│   └── togglebg.png
+├── colors
+│   └── solarized.vim
+├── doc
+│   ├── solarized.txt
+│   ├── tagbar.txt
+│   └── tags
+├── plugin
+│   └── tagbar.vim
+├── README
+├── README.mkd
+└── syntax
+    └── tagbar.vim
+```
+
+Now what if you you decide that solarized sucks and want to get rid of it? Good luck finding
+which file belongs to which plugin. Oh, don't forget the merged `doc/tags` file!
+Now imagine you have 20-30 plugins installed (which is normal, by the way). It's not a
+pretty sight now, is it?
+
+## Pathogen to the rescue!
+
+The legendary Tim Pope came up with a genius solution:
+[pathogen](https://github.com/tpope/vim-pathogen).
+Now let's install it like any regular plugin (I've omitted the README):
+
+```
+~/.vim
+└── autoload
+    └── pathogen.vim
+```
+
+Put this at the beginning of your `~/.vimrc`:
+
+```
+execute pathogen#infect()
+```
+
+Create this directory: `~/.vim/bundle`. To install tagbar and solarized, just create their own
+directories here:
+
+```
+path
+├── autoload
+│   └── pathogen.vim
+└── bundle
+    ├── tagbar
+    │   ├── autoload
+    │   │   └── tagbar.vim
+    │   ├── doc
+    │   │   ├── tagbar.txt
+    │   │   └── tags
+    │   ├── plugin
+    │   │   └── tagbar.vim
+    │   ├── README
+    │   └── syntax
+    │       └── tagbar.vim
+    └── vim-colors-solarized
+        ├── autoload
+        │   └── togglebg.vim
+        ├── bitmaps
+        │   └── togglebg.png
+        ├── colors
+        │   └── solarized.vim
+        ├── doc
+        │   ├── solarized.txt
+        │   └── tags
+        └── README.mkd
+```
+
+What Pathogen does is that it adds every directory inside `bundle` into vim's "runtimepath".
+It means that each folder here can be considered a new `.vim` folder where vim looks for
+appropriate configuration files. The plugins are now isolated so removing or updating them
+becomes trivial: just remove or update its own directory.
+
+## Pathogen + Git
+
+Everything goes to the cloud these days, and certainly your vim setup should as well. If you
+haven't created a [Github](https://github.com) account, do it now. Create an empty repository
+with any name you want (mine is `.vim`). Don't commit yet. Create a file: `~/.vim/.gitignore`,
+add these lines to its content:
+
+```
+bundle/
+.netrwhist
+```
+
+.netrwhist is a local file generated by vim that is better off ignored. We also ignore bundle
+directory because the plugins will be included as git submodules (google *git submodule*
+for details). Remember to delete everything inside `bundle/`, because we will install the
+plugins again with git.
+
+Git init, commit and push to your github repo: (on the *git remote add...* line, replace `nhanb`
+with your github username, `.vim` with your repo name)
+
+```bash
+cd ~/.vim
+git init
+git add .
+git commit -m 'init'
+
+git remote add origin https://github.com/nhanb/.vim.git
+git push -u origin master
+```
+
+Everytime you edit anything in your .vim directory, remember to commit the changes and push to
+github:
+
+```bash
+git add . 
+git commit -m 'some message here'
+git push
+```
+
+If you want to install a plugin, see if it has a git repo (9 out of 10 times it has a
+github repo). Find its git url and add to your .vim as a submodule:
+
+```bash
+cd ~/.vim
+git add submodule https://github.com/majutsushi/tagbar.git bundle/tagbar
+git add submodule https://github.com/altercation/vim-colors-solarized.git bundle/solarized
+git submodule update --init
+git submodule foreach git pull origin master
+```
+
+When you need to update your plugins, just run the last line to make git pull updates for all
+plugins. 
+
+Here's the awesome part: when you're using a whole new computer and want to get all your vim settings
+from the cloud, simply clone your github repo, make a symlink for .vimrc and pull all plugins:
+
+    cd ~
+    git clone https://github.com/nhanb/.vim.git .vim
+    ln -s ~/.vim/vimrc ~/.vimrc
+    cd .vim
+    git submodule update --init && git submodule foreach git pull origin master
+
+Now you must be really excited, no? Git does everything for you: upload/download, add plugins,
+update plugins *and* remove plugins... There must be some simple git command to remove a
+submodule, right?
+
+**NO**. Sadly, no. To remove a git submodule, you'll need to manually edit 2 git files and
+remove the folder by hand. See
+[this Stackoverflow question](http://stackoverflow.com/questions/1260748/how-do-i-remove-a-git-submodule)
+for detailed instructions.
+
+## Vundle, the new cool kid
+
+This time let's start fresh: remove all submodules and pathogen. Your bundle folder should be
+now empty. Clone [Vundle](https://github.com/gmarik/vundle):
+
+    git clone https://github.com/gmarik/vundle.git ~/.vim/bundle/vundle
+
+Put this in your .vimrc (preferably at the beginning):
+
+    set nocompatible               " be iMproved
+    filetype off                   " required!
+
+    set rtp+=~/.vim/bundle/vundle/
+    call vundle#rc()
+
+    " let Vundle manage Vundle
+    " required! 
+    Bundle 'gmarik/vundle'
+
+    " My Bundles here:
+    "
+    " original repos on github
+    Bundle 'majutsushi/tagbar'
+    Bundle 'altercation/vim-colors-solarized'
+
+    " Github repos of the user 'vim-scripts'
+    " => can omit the username part
+    Bundle 'L9'
+    Bundle 'FuzzyFinder'
+
+    " non github repos
+    Bundle 'git://git.wincent.com/command-t.git'
+    " ...
+
+    filetype plugin indent on     " required!
+
+Relaunch vim, run `:BundleInstall` to install the "bundles" you listed in .vimrc. When you want
+to update them, `:BundleUpdate`. To remove a plugin, just delete its line in your .vimrc file
+then relaunch vim and run `:BundleClean` to remove its folder inside ~/.vim/bundle/
+
+Vundle follows Pathogen's approach: putting plugins in their separate directories. However,
+it also takes care of the git stuff for us too! Note that by default it uses `git clone`, not
+`git add submodule` to add plugins. If you're using Windows, there's Vundle for Windows too,
+though I've never tried it.
+
+That's it, happy coding! Feel free to leave your comments if there's anything wrong/unclear here.
diff --git a/develop_server.sh b/develop_server.sh
new file mode 100755
index 0000000..0909d7b
--- /dev/null
+++ b/develop_server.sh
@@ -0,0 +1,99 @@
+#!/usr/bin/env bash
+##
+# This section should match your Makefile
+##
+PY=python
+PELICAN=pelican
+PELICANOPTS=
+
+BASEDIR=$(pwd)
+INPUTDIR=$BASEDIR/content
+OUTPUTDIR=$BASEDIR/output
+CONFFILE=$BASEDIR/pelicanconf.py
+
+###
+# Don't change stuff below here unless you are sure
+###
+
+SRV_PID=$BASEDIR/srv.pid
+PELICAN_PID=$BASEDIR/pelican.pid
+
+function usage(){
+  echo "usage: $0 (stop) (start) (restart)"
+  echo "This starts pelican in debug and reload mode and then launches"
+  echo "A pelican.server to help site development. It doesn't read"
+  echo "your pelican options so you edit any paths in your Makefile"
+  echo "you will need to edit it as well"
+  exit 3
+}
+
+function alive() {
+  kill -0 $1 >/dev/null 2>&1
+}
+
+function shut_down(){
+  PID=$(cat $SRV_PID)
+  if [[ $? -eq 0 ]]; then
+    if alive $PID; then
+      echo "Killing pelican.server"
+      kill $PID
+    else
+      echo "Stale PID, deleting"
+    fi
+    rm $SRV_PID
+  else
+    echo "pelican.server PIDFile not found"
+  fi
+
+  PID=$(cat $PELICAN_PID)
+  if [[ $? -eq 0 ]]; then
+    if alive $PID; then
+      echo "Killing Pelican"
+      kill $PID
+    else
+      echo "Stale PID, deleting"
+    fi
+    rm $PELICAN_PID
+  else
+    echo "Pelican PIDFile not found"
+  fi
+}
+
+function start_up(){
+  echo "Starting up Pelican and pelican.server"
+  shift
+  $PELICAN --debug --autoreload -r $INPUTDIR -o $OUTPUTDIR -s $CONFFILE $PELICANOPTS &
+  pelican_pid=$!
+  echo $pelican_pid > $PELICAN_PID
+  cd $OUTPUTDIR
+  $PY -m pelican.server &
+  srv_pid=$!
+  echo $srv_pid > $SRV_PID
+  cd $BASEDIR
+  sleep 1
+  if ! alive $pelican_pid ; then
+    echo "Pelican didn't start. Is the pelican package installed?"
+    return 1
+  elif ! alive $srv_pid ; then
+    echo "pelican.server didn't start. Is the pelican package installed?"
+    return 1
+  fi
+  echo 'Pelican and pelican.server processes now running in background.'
+}
+
+###
+#  MAIN
+###
+[[ $# -ne 1 ]] && usage
+if [[ $1 == "stop" ]]; then
+  shut_down
+elif [[ $1 == "restart" ]]; then
+  shut_down
+  start_up
+elif [[ $1 == "start" ]]; then
+  if ! start_up; then
+    shut_down
+  fi
+else
+  usage
+fi
diff --git a/pelicanconf.py b/pelicanconf.py
new file mode 100644
index 0000000..a14f27d
--- /dev/null
+++ b/pelicanconf.py
@@ -0,0 +1,31 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*- #
+from __future__ import unicode_literals
+
+AUTHOR = u'Bui Thanh Nhan'
+SITENAME = u'Nhanb'
+SITEURL = ''
+
+TIMEZONE = 'Europe/Paris'
+
+DEFAULT_LANG = u'en'
+
+# Feed generation is usually not desired when developing
+FEED_ALL_ATOM = None
+CATEGORY_FEED_ATOM = None
+TRANSLATION_FEED_ATOM = None
+
+# Blogroll
+LINKS =  (('Pelican', 'http://getpelican.com/'),
+          ('Python.org', 'http://python.org/'),
+          ('Jinja2', 'http://jinja.pocoo.org/'),
+          ('You can modify those links in your config file', '#'),)
+
+# Social widget
+SOCIAL = (('You can add links in your config file', '#'),
+          ('Another social link', '#'),)
+
+DEFAULT_PAGINATION = 10
+
+# Uncomment following line if you want document-relative URLs when developing
+#RELATIVE_URLS = True
diff --git a/publishconf.py b/publishconf.py
new file mode 100644
index 0000000..02313c0
--- /dev/null
+++ b/publishconf.py
@@ -0,0 +1,24 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*- #
+from __future__ import unicode_literals
+
+# This file is only used if you use `make publish` or
+# explicitly specify it as your config file.
+
+import os
+import sys
+sys.path.append(os.curdir)
+from pelicanconf import *
+
+SITEURL = 'http://blog.nerdyweekly.com/blog'
+RELATIVE_URLS = False
+
+FEED_ALL_ATOM = 'feeds/all.atom.xml'
+CATEGORY_FEED_ATOM = 'feeds/%s.atom.xml'
+
+DELETE_OUTPUT_DIRECTORY = True
+
+# Following items are often useful when publishing
+
+#DISQUS_SITENAME = ""
+#GOOGLE_ANALYTICS = ""