Fork me on GitHub

5/13/2013

Git alias problem

Recently, don't know why, I found the git aliasing does not work. When I use git st aliasing command, I got below error:

fatal: cannot exec 'git-st': Not a directory
Problem is /usr/bin/python is not directed to directory

After search for a while, I found it should be caused by my environment variable PATH.

Use the command echo $PATH |tr ':' '\n' |xargs ls -ld, I found there is a symbolic link in the list /usr/bin/python -> python2.7 If it is removed, the git aliasing problem is gone.

I think it should be noticed that the environment path should points to directories not to files.

[~]$ echo $PATH |tr ':' '\n' |xargs ls -ld

drwxr-xr-x 2 root      root         4096 Apr 17 09:52 /bin
drwxrwxr-x 2 brownylin brownylin    4096 Apr 25 09:41 /home/brownylin/Java/maven3/bin
drwxr-xr-x 2 root      root        40960 May  9 13:07 /usr/bin
lrwxrwxrwx 1 root      root            9 Apr 15 15:54 /usr/bin/python -> python2.7
drwxr-xr-x 2 root      root         4096 Apr 24 11:34 /usr/local/bin


References

Git alias problem
http://stackoverflow.com/questions/4019501/git-alias-problem

5/06/2013

Personal wiki based on vimwiki

Recently, I am looking for a simple solution for personal wiki. My basic requirement is no need of database, easy deploy and lightweight.

Finally, I found the vimwiki is a perfect solution with some other services.

vimwiki: Simple syntax, perfectly integrated with vim. Export each single wiki to separate html file.
google-code-prettyfy: Used to make code snippets well formated.
Github pages: Used to host/publish the wiki.
Bootswatch: There are many beautiful and basic templates to beautify your wiki

Below is a brief description about how to setup the personal wiki which utilize above tools. Enjoy them :)


1. Vimwiki installation

https://code.google.com/p/vimwiki/wiki/Installation

  1. Download and unpack vimwiki_N_N.zip. (N_N is version number ie 0_8)
  2. Place unpacked files into (create directory if it isn't exists):
    Linux: ~/.vim/
    Windows: ~/vimfiles/, where ~ is a home directory, usually C:\Documents and Settings\USERNAME\
  3. To install help, open Vim and run :helptags ~/vimfiles/doc command.
  4. Modify vimrc as below, <F4> is mapped to generate html
" // --- vimwiki --- //
let g:vimwiki_list = [{'path': '~/Dropbox/vimwiki/',
			\'template_path': '~/Dropbox/vimwiki/template/',
			\'template_default': 'default',
			\'template_ext': '.html',
			\'path_html': '~/Dropbox/github/vimwiki/'}]

map <F4> :VimwikiAll2HTML<cr>


2. Use google-code-prettify for code highlight

https://code.google.com/p/google-code-prettify/

1. Download code-prettify (ex: prettify-small-4-Mar-2013.tar.bz2)
https://code.google.com/p/google-code-prettify/downloads/list

2. Modify the default vimwiki template
Add below code block before </head> and change <body> to <body onload='prettyPrint()'>

Use your prettify.js and prettify.css instead of http://XXX/prettify.css and ttp://XXX/prettify.js

<link href='http://XXX/prettify.css' rel='stylesheet' type='text/css'/>
<script language='javascript' src='http://XXX/prettify.js' type='text/javascript'/>
<script type='text/javascript'>
document.addEventListener(&#39;DOMContentLoaded&#39;,function() { prettyPrint();});
</script>

The result default.html of vimwiki should looks like as below

<html>
<head>
<link rel="Stylesheet" type="text/css" href="%root_path%%css%">
<title>%title%</title>
<meta http-equiv="Content-Type" content="text/html; charset=%encoding%">
<!-- Bootstrap: Bootswatch template goes here -->
<link href="http://XXX/bootstrap.min.css" rel="stylesheet"
media="screen" type='text/css'>

<!-- google-code-prettify -->
<link href='http://XXX/prettify.css' rel='stylesheet' type='text/css'/>
<script language='javascript' src='http://XXX/prettify.js' type='text/javascript'/>
<script type='text/javascript'>
document.addEventListener(&#39;DOMContentLoaded&#39;,function() { prettyPrint();});
</script>

</head>
<body onload='prettyPrint()'>
%content%
</body>
</html>


3. Use Github pages to host/publish you wiki

http://pages.github.com/

  1. Build a project page for the vimwiki
    https://help.github.com/articles/creating-project-pages-manually