<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-34829202</id><updated>2012-02-17T07:42:11.100+09:00</updated><category term='ibus'/><category term='J2ME'/><category term='Servers Quicklink'/><category term='Gadget'/><category term='Subversion'/><category term='SftpDrive'/><category term='Thunderbird'/><category term='Rails'/><category term='Others'/><category term='Tips'/><category term='Windows'/><category term='Netem'/><category term='Latex'/><category term='OMNet'/><category term='Printer'/><category term='Netbeans'/><category term='Vim'/><category term='Doja'/><category term='Akregator'/><category term='japanese'/><category term='Kubuntu'/><category term='Ruby'/><category term='incron'/><category term='unicode'/><category term='Ctags'/><category term='Rant'/><category term='Mutt'/><category term='offlineimap'/><category term='unison'/><category term='Android'/><category term='Servers'/><category term='OpenSSH'/><category term='backup'/><title type='text'>私のTech記憶</title><subtitle type='html'>Any piece of knowledge I acquire today has a value at that moment proportional to my skill to deal with it. Tomorrow, when I am more skilled, that same knowledge will have higher value.</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://piao-tech.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/34829202/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://piao-tech.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>龍神</name><uri>http://www.blogger.com/profile/16648963337079496096</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>93</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-34829202.post-636565305072657772</id><published>2011-02-22T23:56:00.010+09:00</published><updated>2011-11-27T03:43:31.568+09:00</updated><title type='text'>Google contacts with sup email client.</title><content type='html'>&lt;h2&gt;Introduction&lt;/h2&gt;&lt;br /&gt;Recently I found about sup [&lt;a href="http://sup.rubyforge.org"&gt;1&lt;/a&gt;] and gave it a try to replace mutt. One of my requirements is access to my Gmail contacts from within the client so I can auto-complete the To, CC and BCC fields with my already registered contacts.&lt;br /&gt;&lt;br /&gt;Fortunately I already had a ruby script to integrate Gmail contacts with mutt [&lt;a href="http://piao-tech.blogspot.com/2010/01/google-contacts-in-mutt.html"&gt;2&lt;/a&gt;] and since sup can be extended via ruby scripts it was extremely easy to get my script working with sup. &lt;br /&gt;&lt;br /&gt;&lt;h2&gt;SUP email client with Gmail contacts&lt;/h2&gt;&lt;br /&gt;Sup hooks system [&lt;a href="http://sup.rubyforge.org/wiki/wiki.pl?Hooks"&gt;3&lt;/a&gt;] is very powerful and allows us to add all kinds of functionality to sup using simple ruby scripts. One such hooks is called "extra-contact-addresses.rb" and from the hooks documentation we can read:&lt;br /&gt;&lt;br /&gt;&lt;script type="syntaxhighlighter" class="brush:bash"&gt;&lt;![CDATA[extra-contact-addresses-----------------------File: $HOME/.sup/hooks/extra-contact-addresses.rbA list of extra addresses to propose for tab completion, etc. when the user is entering an email address. Can be plain email addresses or can be full "User Name &lt;email@domain.tld&gt;" entries.Variables: noneReturn value: an array of email address strings.]]&gt;&lt;/script&gt;&lt;br /&gt;&lt;br /&gt;What this means is that we must create an script inside our $HOME/.sup/hooks directory called extra-contact-addresses.rb that returns an array of email addresses in plain format (e.g. myemail@gmail.com) or full format (e.g. User Name &amp;lt;username@gmail.com&amp;gt;).&lt;br /&gt;&lt;br /&gt;Here is the script I implemented for this purpose:&lt;br /&gt;&lt;br /&gt;&lt;script type="syntaxhighlighter" class="brush:ruby"&gt;&lt;![CDATA[### Author: Horacio Sanson (hsanson at gmail)# Date:   2011/02/20## Descr:#    Sup mail client hook to load gmail contacts into the mail client.## Installation:#    To use this script you need ruby and rubygems 1.8 and the gdata gem. To#    install these in Ubuntu/Kubuntu use the following commands.##      sudo aptitude install ruby1.8 rubygems-1.8 libopenssl-ruby1.8#      sudo gem1.8 install gdata##    You can also use ruby 1.9.1 and rubygems 1.9.1 but you will need to modify#    the gdata gem that is not compatible with ruby 1.9.1. Modifying the gdata#    gem is very easy: simply delete the require jcode and $KCODE lines in the#    gdata source. To find were these lines are simply run the script and it#    will show you an error about jcode and a warning about KCODE so follow the#    backtrace and remove the problem lines.##    Make sure to read the comments below to learn how to configure this script#    to work with your GMail account.##    Then simply copy this script inside your ~/.sup/hooks directory## Resources:#    - http://piao-tech.blogspot.com/2010/01/google-contacts-in-mutt.html#    - http://sup.rubyforge.org/wiki/wiki.pl?LbdbIntegrationrequire "rubygems"require "gdata"require "fileutils"def update_cache  ## Set up here your GMail account username and password  username="myusername"  password="mysecretpassword"  # Make sure this value is larger than the total number of contacts you have.  maxresults=999  # How much time before the local cache expires in seconds.  update_interval=3600  # Where to store the local cache for faster query times.  cachefile="~/.sup/gcontacts"  # DO NOT MODIFY anything below this line unless you know what you are doing.  user_hash = nil  cache_file_path = File.expand_path(cachefile)  if ! File.exists?(cache_file_path) or                   Time.now - File.stat(cache_file_path).mtime &gt; update_interval    #STDERR &amp;lt;&amp;lt; "Updating from gmail\n"    user_hash = []    client = GData::Client::Contacts.new    begin      client.clientlogin("#{username}@gmail.com", password)    rescue GData::Client::AuthorizationError      STDERR &amp;lt;&amp;lt; "Failed to authenticate\n"      return nil    rescue =&amp;gt; e      STDERR &amp;lt;&amp;lt; "Failed to log into Gmail: #{e}\n"    end    # Create a hash list of all users    contacts_url = "http://www.google.com/m8/feeds/contacts/"    contacts_url += "#{username}%40gmail.com/full?max-results=#{maxresults}"    feeds = client.get(contacts_url).to_xml    feeds.elements.each('entry') { |entry|      name = entry.elements['title'].text      id = entry.elements['id'].text      entry.elements.each('gd:email') { |email|        if name and ! name.empty?          user_hash.push("#{name} &amp;lt;#{email.attribute('address').value}&amp;gt;")        end        # To allow completion for name and email        user_hash.push("#{email.attribute('address').value}")      }    }    File.open(File.expand_path(cachefile),"wb") { |fd|      fd &amp;lt;&amp;lt; Marshal.dump(user_hash)    }    user_hash  else    #STDERR &amp;lt;&amp;lt; "Updating from local cache\n"    user_hash = []    if File.exists?(File.expand_path(cachefile))      File.open(File.expand_path(cachefile),"rb") { |fd|        user_hash = Marshal.load(fd.read)      }    end    user_hash  endend# Run the update_cache method that returns an array of gmail contacts compatible# with sup hook.update_cache]]&gt;&lt;/script&gt;&lt;br /&gt;&lt;br /&gt;Simply copy this script to "~/.sup/hooks/extra-contact-addresses.rb" and your are ready to go. When composing or replying and email you can press Tab to autocomplete email addresses.&lt;br /&gt;&lt;br /&gt;&lt;h2&gt;Resources&lt;/h2&gt;[1] &lt;a href="http://sup.rubyforge.org"&gt;http://sup.rubyforge.org/&lt;/a&gt;&lt;br /&gt;[2] &lt;a href="http://piao-tech.blogspot.com/2010/01/google-contacts-in-mutt.html"&gt;http://piao-tech.blogspot.com/2010/01/google-contacts-in-mutt.html&lt;/a&gt;&lt;br /&gt;[3] &lt;a href="http://sup.rubyforge.org/wiki/wiki.pl?Hooks"&gt;http://sup.rubyforge.org/wiki/wiki.pl?Hooks&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/34829202-636565305072657772?l=piao-tech.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://piao-tech.blogspot.com/feeds/636565305072657772/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://piao-tech.blogspot.com/2011/02/google-contacts-with-sup-email-client.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/34829202/posts/default/636565305072657772'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/34829202/posts/default/636565305072657772'/><link rel='alternate' type='text/html' href='http://piao-tech.blogspot.com/2011/02/google-contacts-with-sup-email-client.html' title='Google contacts with sup email client.'/><author><name>龍神</name><uri>http://www.blogger.com/profile/16648963337079496096</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-34829202.post-4242101540754275769</id><published>2010-12-29T23:08:00.009+09:00</published><updated>2011-11-27T11:53:42.862+09:00</updated><title type='text'>Get KDE 4 .4.2  working with xrdp</title><content type='html'>&lt;h2&gt;Problem Statement&lt;/h2&gt;KDE4 &lt;a href="#resources"&gt;[1]&lt;/a&gt; looks horrible when accessed remotely via vnc &lt;a href="#resources"&gt;[2]&lt;/a&gt; and since xrdp &lt;a href="#resources"&gt;[3]&lt;/a&gt; is simply a proxy that depends on vnc we get the same horrble look when accessing KDE using Windows RDP client.&lt;br /&gt;&lt;br /&gt;The usual response from KDE developers is that vnc is bad and you should change your vnc server or use another remote desktop technology so I tested all vnc server implementations I found and I can tell that x11vnc is the only one that is simple and works correctly with KDE4 so the solution to my problem was simple: get xrdp to work with x11vnc.&lt;br /&gt;&lt;br /&gt;&lt;h1&gt;Configure KDE4 with x11vnc server&lt;/h1&gt;This cannot be more easy. In Ubuntu simply install the package:&lt;br /&gt;&lt;script type="syntaxhighlighter" class="brush:bash"&gt;&lt;![CDATA[sudo aptitude install x11vnc]]&gt;&lt;/script&gt;&lt;br /&gt;then in a terminal (konsole) run this command:&lt;br /&gt;&lt;script type="syntaxhighlighter" class="brush:bash"&gt;&lt;![CDATA[x11vnc -usepw -display :0 -forever -repeat -noxdamage -xkb]]&gt;&lt;/script&gt;&lt;br /&gt;The first time you run this command it will ask you to input a password. Choose any one you like and remember it because you will need it to connect remotely to x11vnc.  The -noxdamage option is only needed if you have desktop effects enabled in plasma. If you have these plasma effects enabled and you do not use the -noxdamage option you will see some XDamage errors in the x11vnc output. You can also ask x11vnc to turn off the monitor when a remote client connects using the -clientdpms option and to lock the screen when the client disconnects using the -gone option. Be warned that the -clientdpms and -gone options were not working very well last time I tried. For example is difficult to recover the session from the desktop unless the remote client&lt;br /&gt;disconnects.&lt;br /&gt;&lt;br /&gt;&lt;h2&gt;Configure KDE4 with xrdp server&lt;/h2&gt;Install the xrdp packages:&lt;br /&gt;&lt;script type="syntaxhighlighter" class="brush:bash"&gt;&lt;![CDATA[sudo aptitude install xrdp]]&gt;&lt;/script&gt;&lt;br /&gt;Edit the &lt;i&gt;/etc/xrdp/xrdp.ini&lt;/i&gt; file and add an entry like:&lt;br /&gt;&lt;script type="syntaxhighlighter" class="brush:bash"&gt;&lt;![CDATA[[MyHOME]name=MyHOMElib=libvnc.soip=127.0.0.1port=5900password=ask]]&gt;&lt;/script&gt;    &lt;br /&gt;Finally restart xrdp service:&lt;br /&gt;&lt;script type="syntaxhighlighter" class="brush:bash"&gt;&lt;![CDATA[sudo service xrdp restart]]&gt;&lt;/script&gt;&lt;br /&gt;&lt;br /&gt;&lt;h2&gt;Accessing remotely you KDE session via Windows RDP client&lt;/h2&gt;In a windows machine open the remote desktop client (usually found in accessories) and input your KDE machine IP address.  After the connection is established you will get a popup with some options including the one we created above (MyHOME) so select it, input the password you set to x11vnc and enjoy.&lt;br /&gt;&lt;br /&gt;&lt;h2&gt;Troubleshooting&lt;/h2&gt;If you use Gnome instead of KDE you be encounter a bug that messes up the keyboard &lt;a href="#resources"&gt;[6]&lt;/a&gt;. To fix it you must disable the keyboard plugin of the gnome-settings-daemon using hte gconf-editor. To do this open the gconf-editor and navigate all the way to the folder:&lt;br /&gt;&lt;script type="syntaxhighlighter" class="brush:bash"&gt;&lt;![CDATA[/apps/gnome_settings_daemon/plugins/keyboard]]&gt;&lt;/script&gt;&lt;br /&gt;and set the active option to False.&lt;br /&gt;&lt;br /&gt;&lt;h2&gt;Enabling the Kana Henkan key (Japanese Keyboards)&lt;/h2&gt;To get the japanese kana key (top left in japanese keyboards) to work you need to apply a patch&lt;br /&gt;&lt;a href="#resources"&gt;[7]&lt;/a&gt; and install the patched deb:&lt;br /&gt;&lt;script type="syntaxhighlighter" class="brush:bash"&gt;&lt;![CDATA[sudo apt-get install build-essential fakeroot dpkg-devsudo apt-get source xrdpsudo apt-get build-dep xrdpsudo patch -p0 &lt; ~/Patches/xrdp-japanese.patchdpkg-buildpackage -rfakeroot -b]]&gt;&lt;/script&gt;&lt;br /&gt;&lt;br /&gt;&lt;h2&gt;Resources&lt;/h2&gt;[1] &lt;a name="resources" href="www.kde.org"&gt;www.kde.org&lt;/a&gt;&lt;br /&gt;[2] &lt;a href="http://en.wikipedia.org/wiki/Virtual_Network_Computing"&gt;http://en.wikipedia.org/wiki/Virtual_Network_Computing&lt;/a&gt;&lt;br /&gt;[3] &lt;a href="http://xrdp.sourceforge.net"&gt;http://xrdp.sourceforge.net&lt;/a&gt;&lt;br /&gt;[4] &lt;a href="http://forum.xbmc.org/showthread.php?t=74791"&gt;http://forum.xbmc.org/showthread.php?t=74791&lt;/a&gt;&lt;br /&gt;[5] &lt;a href="http://adrianpopagh.blogspot.com/2010/06/connecting-with-remote-desktop-rdp-to.html"&gt;http://adrianpopagh.blogspot.com/2010/06/connecting-with-remote-desktop-rdp-to.html&lt;/a&gt;&lt;br /&gt;[6] &lt;a href="https://bugs.launchpad.net/ubuntu/+source/xrdp/+bug/320393"&gt;https://bugs.launchpad.net/ubuntu/+source/xrdp/+bug/320393&lt;/a&gt;&lt;br /&gt;[7] &lt;a href="http://blogs.sun.com/thaniwa/entry/ja_xrdp"&gt;http://blogs.sun.com/thaniwa/entry/ja_xrdp&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/34829202-4242101540754275769?l=piao-tech.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://piao-tech.blogspot.com/feeds/4242101540754275769/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://piao-tech.blogspot.com/2010/12/get-kde-4-42-working-with-xrdp.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/34829202/posts/default/4242101540754275769'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/34829202/posts/default/4242101540754275769'/><link rel='alternate' type='text/html' href='http://piao-tech.blogspot.com/2010/12/get-kde-4-42-working-with-xrdp.html' title='Get KDE 4 .4.2  working with xrdp'/><author><name>龍神</name><uri>http://www.blogger.com/profile/16648963337079496096</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-34829202.post-4789823821190679895</id><published>2010-11-06T12:13:00.004+09:00</published><updated>2011-11-27T18:44:54.223+09:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Vim'/><title type='text'>2010 Vim Configuration</title><content type='html'>&lt;script type="syntaxhighlighter" class="brush:plain"&gt;&lt;![CDATA[""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" Description:""  This vimrc is my default vim configuration file."""" Prerequisites:""  - This configuration has been tested only on Ubuntu/Kubuntu version 10.10 ""    and 11.10. It may work in lower Ubuntu versions and other Debian ""    distributions but there is no guarantee."""" Installation:""  The instructions here install the required software packages and sets our""  vim configuration directory under git versioning control. By using git to""  manage our configuration we get several benefits:""""    - History record of our configuration files.""    - Easy synchronization among several machines via git cloning.""    - Easy handling of experimental configurations via branches.""    - Easy setup of per machine configurations via tags.""    - Easy handling of plugins via panthogen and git submodules.""""  This assumes you are starting with a fresh vim configuration. If not I""  recommend you backup all your config files and then follow carefully the""  instructions in this file. At the end you will have a powerful vim""  configuration that you can then further modify to fit your tastes.""""  - Install vim and some additional support packages:""""    sudo aptitude install vim-gtk vim-ruby vim-common""    sudo aptitude install git-core wget sed  ack-grep exuberant-ctags""""    Even if you do not plan to use the GUI version of vim it is better to""    install it since it adds some additional support like +xterm_clipboard""    that allows copy/paste to the window manager clipboard (KDE, Gnome, Xfce)""""  - Remove all your vim configurations if you have:""""    rm -rf $HOME/.vim*""""  - Create a clean $HOME/.vim folder""""    mkdir -p $HOME/.vim""""  - Copy this configuration file inside the .vim folder:""""    cp -f vimrc $HOME/.vim""""  - Create a symbolic link so vim can find this configuration file:""""    ln -s $HOME/.vim/vimrc $HOME/.vimrc""""  - Initialize the git repo on the .vimrc folder:""""    cd $HOME/.vim""    git init""""  Now make sure you read this file section by section since there are some""  additional steps needed to get a fully functional vimrc configuration.""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" General Settings"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""set nocompatible                      " Disable vi compatibility.set fileformats=unix,dos              " Use unix file format.set number                            " Show line number column.set nobackup                          " Stop vim from creating ~ files.set showcmd                           " Display commands as they are typed.set ttyfast                           " Smoother screen redraws.set hlsearch                          " Highlight search results.set showmatch                         " Show briefly matching bracket when closing it.autocmd InsertEnter * se cul          " Highlight current line in Insert Mode. autocmd InsertLeave * se nocul        " Don't highlight current line in other modes." Set search path for gf commandset path=/usr/include,/usr/local/include,**;$HOME""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" Pathogen Plugin"""" Description:""  This vim plugin allows easy management of other plugins in bundles that ""  is cleaner that mixing all plugin files inside the .vim folder."""" Installation:""  mkdir -p $HOME/.vim/autoload""  wget --no-check-certificate \""     https://github.com/tpope/vim-pathogen/raw/master/autoload/pathogen.vim \""     -O $HOME/.vim/autolad/pathogen.vim"""" Resources:""   http://vimcasts.org/episodes/synchronizing-plugins-with-git-submodules-and-pathogen/"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""filetype off " Temporarily disable so pathogen also loads ftdetect plugins.call pathogen#runtime_append_all_bundles()call pathogen#helptags()filetype plugin indent on " Re-enable after pathogen is loaded.""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" Filetype Settings"""" Description:""  For each filetype we create a ftplugin/&lt;filetype&gt;.vim file with settings""  particular to each filetype. For example we set tabs instead of spaces for""  python and makefile files and enable the different omnifunctions for each""  filetype that supports it."""" Installation:""""  Exectuting the following commands in the terminal would create the different""  file type configuration files:""""  mkdir -p $HOME/.vim/ftdetect  # Folder used to add new filetypes.""  mkdir -p $HOME/.vim/ftplugin  # Folder used to add per filetype settings.""  mkdir -p $HOME/.vim/syntax    # Folder used to add per filetype highlight.""  # Add ragel filetype and syntax:""  echo "au BufRead,BufNewFile *.rl setlocal filetype=ragel" &gt; $HOME/.vim/ftdetect/ragel.vim""  wget http://www.complang.org/ragel/ragel.vim -O $HOME/.vim/syntax/ragel.vim""  # Set omnifunctions for each filetype:""  echo "setlocal omnifunc=csscomplete#CompleteCSS" &gt; $HOME/.vim/ftplugin/css.vim""  echo "setlocal omnifunc=ccomplete#Complete" &gt; $HOME/.vim/ftplugin/c.vim""  echo "let c_no_comment_fold = 1" &gt;&gt; $HOME/.vim/ftplugin/c.vim""  echo "setlocal foldmethod=syntax" &gt;&gt; $HOME/.vim/ftplugin/c.vim""  echo "let g:rubycomplete_buffer_loading = 1" &gt; $HOME/.vim/ftplugin/eruby.vim""  echo "let g:rubycomplete_rails = 1" &gt;&gt; $HOME/.vim/ftplugin/eruby.vim""  echo "let g:rubycomplete_classes_in_global = 1" &gt;&gt; $HOME/.vim/ftplugin/eruby.vim""  echo "let ruby_fold = 1" &gt;&gt; $HOME/.vim/ftplugin/eruby.vim""  echo "let ruby_no_comment_fold = 1" &gt;&gt; $HOME/.vim/ftplugin/eruby.vim""  echo "setlocal omnifunc=rubycomplete#Complete" &gt;&gt; $HOME/.vim/ftplugin/eruby.vim""  echo "setlocal foldmethod=syntax" &gt;&gt; $HOME/.vim/ftplugin/eruby.vim""  cp -f $HOME/.vim/ftplugin/eruby.vim $HOME/.vim/ftplugin/ruby.vim""  echo "setlocal omnifunc=htmlcomplete#CompleteTags" &gt; $HOME/.vim/ftplugin/html.vim""  cp -f $HOME/.vim/ftplugin/html.vim $HOME/.vim/ftplugin/markdown.vim""  echo "setlocal omnifunc=javacomplete#Complete" &gt; $HOME/.vim/ftplugin/java.vim""  echo "setlocal completefunc=javacomplete#CompleteParamsInfo" &gt;&gt; $HOME/.vim/ftplugin/java.vim""  echo "setlocal foldmethod=syntax" &gt;&gt; $HOME/.vim/ftplugin/java.vim""  echo "setlocal omnifunc=javascriptcomplete#CompleteJS" &gt; $HOME/.vim/ftplugin/javascript.vim""  echo "setlocal noexpandtab" &gt; $HOME/.vim/ftplugin/make.vim""  echo "setlocal omnifunc=phpcomplete#CompletePHP" &gt; $HOME/.vim/ftplugin/php.vim""  echo "setlocal noexpandtab" &gt; $HOME/.vim/ftplugin/python.vim""  echo "setlocal omnifunc=pythoncomplete#Complete" &gt;&gt; $HOME/.vim/ftplugin/python.vim""  # type /ref{fig: and press &lt;C-n&gt; to autocomplete references""  echo "setlocal iskeyword+=:" &gt; $HOME/.vim/ftplugin/tex.vim""  echp "let g:tex_fold_enabled=1" &gt;&gt; $HOME/.vim/ftplugin/tex.vim""  echo "setlocal foldmethod=syntax" &gt;&gt; $HOME/.vim/ftplugin/tex.vim""  echo "setlocal omnifunc=xmlcomplete#CompleteTags" &gt; $HOME/.vim/ftplugin/xml.vim""  echo "let g:xml_syntax_folding=1" &gt;&gt; $HOME/.vim/ftplugin/xml.vim""  echo "setlocal foldmethod=syntax" &gt;&gt; $HOME/.vim/ftplugin/xml.vim""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" Coffee Script Filetype and syntax"""" Description:""   Add coffee script configuration files:"""" Installation:""   mkdir -p $HOME/.vim/bundle""   cd $HOME/.vim""   git submodule add https://github.com/kchmck/vim-coffee-script.git bundle/vim-coffee-script""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" HAML and SCSS Filetype and syntax"""" Description:""  Add syntax higliting to the powerfull HAML templating systema and SCSS CSS""  generator."""" Installation:""  mkdir -p $HOME/.vim/bundle""  cd $HOME/.vim""  git submodule add https://github.com/tpope/vim-haml.git bundle/vim-haml""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" Look and Feel Settings"""" Description:""  Add the vividchalk color scheme and enable syntax highligthing in 256 color""  terminals."""" Prerequisites:""  - Make sure your terminal supports 256 colors. Konsole does but you must set""    the TERM variable to xterm-256color in the schema properties."""" Installation:""  mkdir -p $HOME/.vim/bundle""  cd $HOME/.vim""  git submodule add https://github.com/tpope/vim-vividchalk.git bundle/vividchalksyntax on                             " Enable syntax highlighting.set t_Co=256                          " Enable 256 color mode in terminal.set background=dark                   " I like dark backgrounds.colors vividchalk                     " My current favorite color scheme." Show tabs and tailing spaces." Note: to insert the middle point press ctrl+k .M in insert mode:set list:set listchars=tab:»·,trail:·,nbsp:·" By default insert spaces instead of tabs. This may be overriden by the" configuration inside ftplugin directory." Note: If you want a real tab use "ctrl-v, tab" in insert mode.set expandtab" Number of spaces to insert for a tabset shiftwidth=2set tabstop=2set softtabstop=2" Don't screw up folds when inserting text that might affect them, until" leaving insert mode. Foldmethod is local to the window. Protect against" screwing up folding when switching between windows." http://vim.wikia.com/wiki/Keep_folds_closed_while_inserting_textautocmd InsertEnter * if !exists('w:last_fdm') | let w:last_fdm=&amp;foldmethod | setlocal foldmethod=manual | endifautocmd InsertLeave,WinLeave * if exists('w:last_fdm') | let &amp;l:foldmethod=w:last_fdm | unlet w:last_fdm | endif" Unfold new opened buffers" http://vim.wikia.com/wiki/All_folds_open_when_open_a_fileautocmd Syntax c,cpp,vim,xml,html,xhtml,perl,java normal zR"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" Improve Vim's Command Line Autocompletionset wildmode=full wildmenu              " Command-line tab completionset infercase                           " AutoComplete in Vimset completeopt=longest,menu,menuoneset wildignore+=*.o,*.obj,*.pyc,*.DS_STORE,*.db,*.swc"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" Improve TOhtml outputlet html_use_css = 1let html_ignore_folding = 1let html_number_lines = 0"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" Word Wrap"" Auto formatting options. These determine where lines will be broken when" auto wrapping. The last to (m/M) are needed for multi byte characters (e.g." Japanese)set formatoptions=tcqmM" There are two word wrap methods, one with line breaks that adds an actual" '\n' character at the break place and without line breaks that only displays" text as wrapped but there is no actual break added to the text." To enable word wrap with line breaks use the textwidth option below." Note: Use "gq}" to wrap the current paragraph if it is not well formatted.set textwidth=80    " Force wrap for lines longer than 80 characters" To enable word wrap without actual line breaks comment textwidth option above" and enable the four options below (Vim Tip #989):"set wrap           " Force wrap for lines linger than the vim window"set lbr            " Force wrap at word boundaries not chars"nnoremap k gk      " Enable navigation within long lines (up)"nnoremap j gj      " Enable navigation within long lines (down)" Mark the textwidth column with a white color to know when we passed the limit.set colorcolumn=+0,+1,+2,+3highlight ColorColumn ctermbg=darkgrey guibg=darkgrey""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" Character encoding settings"" By manipulating this variables it is possible to edit all files in one "" encoding while using the terminal in a different encoding and writing/reading"" the file in another encoding. Here we set all three variables to UTF-8." Default file encoding for new filessetglobal fenc=utf-8" Auto detect file encoding when opening a file. To check what file encoding was" selected run ":set fenc" and if you know the auto detection failed and want to" force another one run ":edit ++enc=&lt;your_enc&gt;".set fencs=utf-8,euc-jp,sjis" Internal encoding used by vim buffers, help and commandsset encoding=utf-8" Terminal encoding used for input and terminal display" Make sure your terminal is configured with the same encoding.set tenc=utf-8""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" Map make for easy accessmap &lt;f5&gt; &lt;esc&gt;:make&lt;cr&gt;""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" Improve QuickFix Window" Always open the quickfix window when running make, grep, grepadd and vimgrepautocmd QuickfixCmdPost make,grep,grepadd,vimgrep :botright cwindowmap &lt;f6&gt; &lt;esc&gt;:cN&lt;cr&gt;                " Jump to prev error or warnmap &lt;f7&gt; &lt;esc&gt;:cn&lt;cr&gt;                " Jump to next error or warn""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" Ack Plugin"""" Description:""  This plugin allows vim to use the faster and easier ack-grep tool for""  searching inside files."""""" Installation:""  sudo aptitude install ack-grep""  mkdir -p $HOME/.vim/bundle""  cd $HOME/.vim""  git submodule add https://github.com/mileszs/ack.vim.git bundle/ack"""" Usage:""  - :Ack [options] {pattern} [{directory}]"""" Resources:""   http://betterthangrep.com/""   http://amaslov.wordpress.com/2009/04/23/vim-ack-instead-of-grep/let g:ackprg="ack-grep -a -R -H --nocolor --nogroup --column"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" NERDTree Plugin"""" Description:""  The all powerful file explorer plugin for vim."""" Usage:""  :NERDTreeToggle"""" Installation:""  mkdir -p $HOME/.vim/bundle""  cd $HOME/.vim""  git submodule add https://github.com/scrooloose/nerdtree.git bundle/nerdtree" Set the window widthlet g:NERDTreeWinSize = 35" Set the window positionlet g:NERDTreeWinPos = "left"" Colorfullet g:NERDChristmasTree = 1let g:NERDTreeHighlightCursorline = 1" Auto centrelet g:NERDTreeAutoCenter = 0" Not Highlight the cursor linelet g:NERDTreeHighlightCursorline = 0" Don't change working directory when opening filesset noautochdirlet g:NERDTreeChDirMode = 2" Show bookmarks listlet g:NERDTreeShowBookmarks = 1""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" NERDTree Commenter"""" Description:""  Easy commenting of source code."""" Usage:""  - cl - Comment line or visual block""  - cn - Comment line or visual block forcing nesting""  - cs - Comment line or visual block sexily""  - cA - Add commend at the end of line and enter insert mode.""  - ca - Change comment delimiter"""" Installation:""  mkdir -p $HOME/.vim/bundle""  cd $HOME/.vim""  git submodule add https://github.com/scrooloose/nerdcommenter.git \""                                   bundle/nerdcommenter""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" Vim Fugitive"""" Description:""  Best git wrapper for vim."""" Installation:""  mkdir -p $HOME/.vim/bundle""  cd $HOME/.vim""  git submodule add git://github.com/tpope/vim-fugitive.git bundle/fugitive"""" Resources:""  https://github.com/tpope/vim-fugitiveset laststatus=2set statusline=%{fugitive#statusline()}[%f]%=0x%B\ \ \ [%(%l/%L,%c%V%)]\ \ (%p%%)""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" Vim Rails"""" Description:""  Enables a lot of goodies for Rails developers. Make sure to check the""  plugin page for details on how to use this."""" Installation:""  mkdir -p $HOME/.vim/bundle""  cd $HOME/.vim""  git submodule add git://github.com/tpope/vim-rails.git bundle/vim-rails""  git submodule add git://github.com/tpope/vim-endwise.git bundle/endwise"""" Resources:""  https://github.com/tpope/vim-rails""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" OmniCppComplete"""" Description:""  Vim comes with several omnifunctions to enable autocomplete of serveral""  laguages but it lacks a omnifunction for C++. This plugin add this ""  omnifunction to enable autocompletion of C++ code."""" Installation:""  wget http://www.vim.org/scripts/download_script.php?src_id=7722 -O \""                                               /tmp/omnicppcomplete-0.41.zip""  mkdir -p $HOME/.vim/bundle/omnicppcomplete""  unzip -d $HOME/.vim/bundle/omnicppcomplete  /tmp/omnicppcomplete-0.41.zip"""" Resources:""  http://www.vim.org/scripts/script.php?script_id=1520""  http://vim.wikia.com/wiki/C%2B%2B_code_completion""  http://design.liberta.co.za/articles/code-completion-intellisense-for-cpp-in-vim-with-omnicppcomplete/let OmniCpp_NamespaceSearch = 1let OmniCpp_GlobalScopeSearch = 1let OmniCpp_ShowAccess = 1let OmniCpp_ShowPrototypeInAbbr = 1       " show function parameterslet OmniCpp_MayCompleteDot = 1            " autocomplete after .let OmniCpp_MayCompleteArrow = 1          " autocomplete after -&gt;let OmniCpp_MayCompleteScope = 1          " autocomplete after ::let OmniCpp_DefaultNamespaces = ["std", "_GLIBCXX_STD"]""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" Neocomplcache Plugin"""" Description:""  A auto-complete plugin that actually works!"""" Notes:""  - The plugin works very well but can be very slow. This is specially true""    when opening a file for the first time as the plugin will parse and cache""    the file keywords, tags, etc."""" Installation:""  mkdir -p $HOME/.vim/bundle""  cd $HOME/.vim""  git submodule add https://github.com/Shougo/neocomplcache.git \""                                                        bundle/neocomplcachelet g:neocomplcache_enable_at_startup = 1             "Enable neocomplcachelet g:neocomplcache_enable_smart_case = 1             "Use smart caselet g:neocomplcache_enable_camel_case_completion = 1  "Use camelcase completionlet g:neocomplcache_enable_underbar_completion = 1    "Use underbar completionlet g:neocomplcache_min_syntax_length = 3""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" Easy Notes Plugin"""" Description:""""  Very nice plugin to take plain text notes in vim. Better than vim outliner."""" Installation:""  mkdir -p $HOME/.vim/bundle""  cd $HOME/.vim""  mkdir -p $HOME/Notes""  git submodule add https://github.com/xolox/vim-notes.git bundle/notes"""" Usage:""  In vim use :NewNote to create a new note and :SearchNotes to search existing""  notes."""" Notes:""  You may create a Nerdtree Bookmark to the g:notes_directory folder to""  have quick access to your notes." This plugin assumes it is intalled directly in ~/.vim dir but we use pathogen" plugin so we must update the paths accordingly.let g:notes_suffix = '.txt'let g:notes_directory = '~/Notes'             " Were to store notes"let g:notes_shadowdir = '~/Notes/.shadow'    " Changing this breaks all.let g:notes_indexfile = '~/Notes/.index.sqlite3'let g:notes_indexscript = '~/.vim/bundle/notes/misc/notes/scanner.py'""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" tGPG Plugin"""" Description:""  tGPG Plugin for transparent editing of encrypted files. This is the only""  plugin for handling encrypted GPG files that worked out of the box."""" Installation:""  mkdir -p $HOME/.vim/bundle""  cd .vim/bundle""  git submodule add https://github.com/tomtom/tgpg_vim.git bundle/tgpg""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" TagBar Plugin and Ruby omnicomplete plugin"""" Description:""  Tlist replacement with scoping."""" Installation:""  cd $HOME/.vim""  mkdir -p bundle""  git submodule add git://github.com/majutsushi/tagbar bundle/tagbar""  git submodule add https://github.com/vim-scripts/rubycomplete.vim.git \""                                                   bundle/rubycomplete"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""set complete=.,w,b,u,tset tags=./.tags;$HOME""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" Matchit Plugin"""" Description:""  Allows you to configure % to match more than just single characters."""" Installation:""  mkdir -p $HOME/.vim/bundle/matchit""  wget http://www.vim.org/scripts/download_script.php?src_id=8196 \""                                        --output-document=/tmp/matchit.zip""  unzip -d $HOME/.vim/bundle/matchit /tmp/matchit.zip""  rm -f /tmp/matchit.zip""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" Surround Plugin"""" Description:""  Plugin for deleting, changing, and adding surroundings."""" Installation:""  mkdir -p $HOME/.vim/bundle""  cd $HOME/.vim""  git submodule add https://github.com/tpope/vim-surround.git bundle/surround"""" Usage:""  Old text                  Command     New text ~""  Hello *world!"            ds"         Hello world!""  [123+4*56]/2              cs])        (123+456)/2""  "Look ma, I'm *HTML!"     cs"&lt;q&gt;      &lt;q&gt;Look ma, I'm HTML!&lt;/q&gt;""  if *x&gt;3 {                 ysW(        if ( x&gt;3 ) {""  my $str = *whee!;         vlllls'     my $str = 'whee!';""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" Vim-preview Plugin"""" Description:""  Allows to generate and preview HTML documents in a browser."""" Installation:""  sudo gem install RedCloth github-markup bluecloth""  mkdir -p $HOME/.vim/bundle""  cd $HOME/.vim""  git submodule add https://github.com/greyblake/vim-preview.git bundle/preview"""" Usage:""  &lt;leader&gt;P will process markdown, textile, rdoc and html files and load them""  in a browser.""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" Command-T Plugin"""" Description:""  Implements TextMate command-T file search functionality."""" Installation:""  sudo aptitude install ruby ruby-dev rake""  mkdir -p $HOME/.vim/bundle""  cd $HOME/.vim""  git submodule add git://git.wincent.com/command-t.git bundle/command-t""  cd bundle/command-t""  /var/lib/gems/1.8/bin/rake make"""" Usage:""  &lt;leader&gt;P will process markdown, textile, rdoc and html files and load them""  in a browser."""" Notes:""  This plugin maps &lt;C-s&gt; to open files in split windows. Unfortunately in""  Konsole this key combination is set to handle terminal flow control.let g:CommandTAcceptSelectionSplitMap = '&lt;C-b&gt;'  " Remap the split open key.""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" Initial Git Commit"""" Description:""  After installing all the plugins and setting all filetype configurations we""  can make sure to commit the configuration to git versioning."""" Installation:""  $ cd $HOME/.vim""  $ git add .""  $ git commit -m "Initial vim configuration"]]&gt;&lt;/script&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/34829202-4789823821190679895?l=piao-tech.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://piao-tech.blogspot.com/feeds/4789823821190679895/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://piao-tech.blogspot.com/2010/11/2010-vim-configuration.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/34829202/posts/default/4789823821190679895'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/34829202/posts/default/4789823821190679895'/><link rel='alternate' type='text/html' href='http://piao-tech.blogspot.com/2010/11/2010-vim-configuration.html' title='2010 Vim Configuration'/><author><name>龍神</name><uri>http://www.blogger.com/profile/16648963337079496096</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-34829202.post-4352065507438790915</id><published>2010-05-10T23:40:00.018+09:00</published><updated>2011-11-27T18:30:01.673+09:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='japanese'/><category scheme='http://www.blogger.com/atom/ns#' term='ibus'/><category scheme='http://www.blogger.com/atom/ns#' term='Kubuntu'/><title type='text'>Japanese Input in Lucid Lynx (Kubuntu 10.04)</title><content type='html'>&lt;h2&gt;Introduction&lt;/h2&gt;Since Kubuntu 9.10 there is a movement to replace skim &lt;a href="#resources"&gt;[1]&lt;/a&gt; with ibus &lt;a href="#resources"&gt;[2]&lt;/a&gt; that seems to be a better alternative. Unfortunately after my latest upgrade to Kubuntu 10.04 this movement caused my Japanese input to stop working. &lt;br /&gt;&lt;br /&gt;To get Japanese working again using ibus was actually very easy and here Iexplain the steps to do it.&lt;br /&gt;                                                                                                                                                                                                                                                                         &lt;br /&gt;&lt;h2&gt;Uninstall SCIM/SKIM packages&lt;/h2&gt;First we uninstall all SCIM and SKIM related packages to avoid any kinds of conflicts with the new iBus system.&lt;br /&gt;&lt;script type="syntaxhighlighter" class="brush:bash"&gt;&lt;![CDATA[                                                                                                                                                                                                                                                          sudo aptitude purge scim scim-anthy scim-bridge-agent \     scim-bridge-client-gtk scim-bridge-client-qt \     scim-bridge-client-qt4 scim-gtk2-immodule \     scim-hangul scim-qtimm scim-modules-table \     scim-tables-zh scim-uim                                                                                                                                                                                                                       ]]&gt;&lt;/script&gt;                                                                                                                                                                                                                                                                           &lt;br /&gt;&lt;br /&gt;&lt;h2&gt;Install iBus required packages&lt;/h2&gt;                                                                                                                                                                                                                                                                               &lt;br /&gt;Second we install the iBus packages needed to support different language input methods.&lt;br /&gt;&lt;script type="syntaxhighlighter" class="brush:bash"&gt;&lt;![CDATA[sudo aptitude install ibus ibus-qt4 ibus-gtk ibus-anthy]]&gt;&lt;/script&gt;&lt;br /&gt;&lt;br /&gt;&lt;h2&gt;Configure the system to auto-select the input method.&lt;/h2&gt;The im-switch utility is used to select input methods. For better results make sure you select auto.&lt;br /&gt;&lt;script type="syntaxhighlighter" class="brush:bash"&gt;&lt;![CDATA[sudo im-switch -c]]&gt;&lt;/script&gt;&lt;br /&gt;&lt;br /&gt;&lt;h2&gt;Trouble Shooting&lt;/h2&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Japanese/Chinese/Korean/etc does not work in any applications.&lt;/li&gt;                                                                                                                                                                                                         Make sure you have all scim/skim related packages uninstalled and all required ibus packages installed. Also make sure you ran the im-switch command (with sudo) and set ibus in auto mode.&lt;li&gt;Japanese/Chinese/Korean/etc input work in KDE apps but no in GTK (Firefox, Chrome, Skype) apps!&lt;/li&gt;This happens if you do not have the ibus-gtk module installed or do not set the im-switch to auto.&lt;li&gt;Japanese/Chinese/Korean/etc input work in GTK (Firefox, Chrome, Skype) apps but no in KDE apps!&lt;/li&gt;This happens if you do not have the ibus-qt4 module installed or do not set the im-switch to auto.&lt;/ul&gt;&lt;br /&gt;&lt;h2&gt;Resources&lt;/h2&gt;[1] &lt;a name="resources" href="http://www.scim-im.org"&gt;http://www.scim-im.org&lt;/a&gt; scim/skim&lt;br /&gt;[2] &lt;a href="http://code.google.com/p/ibus"&gt;http://code.google.com/p/ibus&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/34829202-4352065507438790915?l=piao-tech.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://piao-tech.blogspot.com/feeds/4352065507438790915/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://piao-tech.blogspot.com/2010/05/japanese-input-in-karmic-koala-kubuntu.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/34829202/posts/default/4352065507438790915'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/34829202/posts/default/4352065507438790915'/><link rel='alternate' type='text/html' href='http://piao-tech.blogspot.com/2010/05/japanese-input-in-karmic-koala-kubuntu.html' title='Japanese Input in Lucid Lynx (Kubuntu 10.04)'/><author><name>龍神</name><uri>http://www.blogger.com/profile/16648963337079496096</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-34829202.post-4087343766515445501</id><published>2010-03-21T17:15:00.011+09:00</published><updated>2011-11-27T18:43:30.339+09:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='offlineimap'/><category scheme='http://www.blogger.com/atom/ns#' term='japanese'/><category scheme='http://www.blogger.com/atom/ns#' term='unicode'/><title type='text'>Get offlineimap working with non ASCII characters.</title><content type='html'>&lt;h2&gt;Introduction&lt;/h2&gt;I recently started using offlineimap &lt;a href="#resources"&gt;[1]&lt;/a&gt; to manage my GMail accounts locally on my machine.&lt;br /&gt;&lt;br /&gt;With offlineimap all my email is local so the navigation is very fast and also I am a little more relieved that I have a local copy of all my email.&lt;br /&gt;&lt;br /&gt;The only problem is that offlineimap does not work well with non english characters. This makes it difficult to use for those with labels in Russian, Chinese, Japanese etc &lt;a href="#resources"&gt;[2]&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;Fortunately offlineimap offers some nice options that allows us to modify it's behavior. Using the "pythonfile" and "nametrans" options I was able to get Japanese working flawlessly.&lt;br /&gt;&lt;br /&gt;&lt;h2&gt;Problem Description&lt;/h2&gt;&lt;br /&gt;IMAP4 uses a modified UTF-7 coding for all folder names but offlineimap does not convert the folder names to UTF-8 or something readable before creating local repositories that results in very cryptic folder names like "&amp;MMYwuTDI-".&lt;br /&gt;&lt;br /&gt;Some research (googling) on the topic resulted in a very nice code to add IMAP4 UTF-7 encoding capabilities to Python &lt;a href="#resources"&gt;[3]&lt;/a&gt;. So with a little time and some copy/paste skills I added this code to offlineimap and ban! I got Japanese working correctly in my folders.&lt;br /&gt;&lt;br /&gt;&lt;h2&gt;Fixing unicode issues in offlineimap&lt;/h2&gt;&lt;br /&gt;First we must add the code to convert from IMAP4 UTF7 encoding support to offlineimap. Thanks to Dominic LoBue (offlineimap developer) I learned that we can add our own python code to offlineimap. To do this we created a simple python script (e.g. ~/.utf7.py) that contains the following code (copy/paste from &lt;a href="#resources"&gt;[3]&lt;/a&gt;:&lt;br /&gt;&lt;br /&gt;&lt;script type="syntaxhighlighter" class="brush:python"&gt;&lt;![CDATA[# -*- coding: latin-1 -*-"""Imap folder names are encoded using a special version of utf-7 as defined in RFC 2060 section 5.1.3.5.1.3.  Mailbox International Naming Convention   By convention, international mailbox names are specified using a   modified version of the UTF-7 encoding described in [UTF-7].  The   purpose of these modifications is to correct the following problems   with UTF-7:      1) UTF-7 uses the "+" character for shifting; this conflicts with         the common use of "+" in mailbox names, in particular USENET         newsgroup names.      2) UTF-7's encoding is BASE64 which uses the "/" character; this         conflicts with the use of "/" as a popular hierarchy delimiter.      3) UTF-7 prohibits the unencoded usage of "\"; this conflicts with         the use of "\" as a popular hierarchy delimiter.      4) UTF-7 prohibits the unencoded usage of "~"; this conflicts with         the use of "~" in some servers as a home directory indicator.      5) UTF-7 permits multiple alternate forms to represent the same         string; in particular, printable US-ASCII chararacters can be         represented in encoded form.   In modified UTF-7, printable US-ASCII characters except for "&amp;"   represent themselves; that is, characters with octet values 0x20-0x25   and 0x27-0x7e.  The character "&amp;" (0x26) is represented by the two-   octet sequence "&amp;-".   All other characters (octet values 0x00-0x1f, 0x7f-0xff, and all   Unicode 16-bit octets) are represented in modified BASE64, with a   further modification from [UTF-7] that "," is used instead of "/".   Modified BASE64 MUST NOT be used to represent any printing US-ASCII   character which can represent itself.   "&amp;" is used to shift to modified BASE64 and "-" to shift back to US-   ASCII.  All names start in US-ASCII, and MUST end in US-ASCII (that   is, a name that ends with a Unicode 16-bit octet MUST end with a "-   ").      For example, here is a mailbox name which mixes English, Japanese,      and Chinese text: ~peter/mail/&amp;ZeVnLIqe-/&amp;U,BTFw-"""import binasciiimport codecs# encodingdef modified_base64(s):    s = s.encode('utf-16be')    return binascii.b2a_base64(s).rstrip('\n=').replace('/', ',')def doB64(_in, r):    if _in:        r.append('&amp;%s-' % modified_base64(''.join(_in)))        del _in[:]def encoder(s):    r = []    _in = []    for c in s:        ordC = ord(c)        if 0x20 &lt;= ordC &lt;= 0x25 or 0x27 &lt;= ordC &lt;= 0x7e:            doB64(_in, r)            r.append(c)        elif c == '&amp;':            doB64(_in, r)            r.append('&amp;-')        else:            _in.append(c)    doB64(_in, r)    return (str(''.join(r)), len(s))# decodingdef modified_unbase64(s):    b = binascii.a2b_base64(s.replace(',', '/') + '===')    return unicode(b, 'utf-16be')def decoder(s):    r = []    decode = []    for c in s:        if c == '&amp;' and not decode:            decode.append('&amp;')        elif c == '-' and decode:            if len(decode) == 1:                r.append('&amp;')            else:                r.append(modified_unbase64(''.join(decode[1:])))            decode = []        elif decode:            decode.append(c)        else:            r.append(c)    if decode:        r.append(modified_unbase64(''.join(decode[1:])))    bin_str = ''.join(r)    return (bin_str, len(s))class StreamReader(codecs.StreamReader):    def decode(self, s, errors='strict'):        return decoder(s)class StreamWriter(codecs.StreamWriter):    def decode(self, s, errors='strict'):        return encoder(s)def imap4_utf_7(name):    if name == 'imap4-utf-7':        return (encoder, decoder, StreamReader, StreamWriter)codecs.register(imap4_utf_7)]]&gt;&lt;/script&gt;&lt;br /&gt;&lt;br /&gt;Then in our offlineimap configuration file, in the "[general]" section we add a line to load this python script like:&lt;br /&gt;&lt;br /&gt;&lt;script type="syntaxhighlighter" class="brush:plain"&gt;&lt;![CDATA[pythonfile = ~/.utf7.py]]&gt;&lt;/script&gt;&lt;br /&gt;&lt;br /&gt;Finally in our remote repository configuration add a nametrans option to convert all foldernames from "imap4-utf-7" encoding to your encoding of preference. My Ubuntu installation is all UTF-8 so I convert all folder names to this encoding:&lt;br /&gt;&lt;br /&gt;&lt;script type="syntaxhighlighter" class="brush:plain"&gt;&lt;![CDATA[nametrans = lambda foldername: foldername.decode('imap4-utf-7').encode('utf-8')]]&gt;&lt;/script&gt;&lt;br /&gt;&lt;br /&gt;The "imap4-utf-7" encoding is added by our "utf7.py" script. With this configuration I can now see the correct Japanese names for all the folders (labels) in my GMail accounts inside Mutt &lt;a href="#resources"&gt;[4]&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;&lt;h2&gt;Resources&lt;/h2&gt;&lt;br /&gt;[1] &lt;a name="resources" href="http://software.complete.org/software/wiki/offlineimap"&gt;http://software.complete.org/software/wiki/offlineimap&lt;/a&gt;&lt;br /&gt;[2] &lt;a href="http://software.complete.org/software/issues/show/102"&gt;http://software.complete.org/software/issues/show/102&lt;/a&gt;&lt;br /&gt;[3] &lt;a href="http://www.koders.com/python/fid744B4E448B1689C0963942A7928FA049084FAC86.aspx?s=search"&gt;IMAP4 UTF-7 Encoding/Decoding&lt;/a&gt;&lt;br /&gt;[4] &lt;a href="http://www.mutt.org/"&gt;Best email client&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/34829202-4087343766515445501?l=piao-tech.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://piao-tech.blogspot.com/feeds/4087343766515445501/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://piao-tech.blogspot.com/2010/03/get-offlineimap-working-with-non-ascii.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/34829202/posts/default/4087343766515445501'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/34829202/posts/default/4087343766515445501'/><link rel='alternate' type='text/html' href='http://piao-tech.blogspot.com/2010/03/get-offlineimap-working-with-non-ascii.html' title='Get offlineimap working with non ASCII characters.'/><author><name>龍神</name><uri>http://www.blogger.com/profile/16648963337079496096</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-34829202.post-9023623019842423646</id><published>2010-01-26T22:35:00.039+09:00</published><updated>2011-09-06T09:27:26.980+09:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Mutt'/><category scheme='http://www.blogger.com/atom/ns#' term='Tips'/><title type='text'>Google Contacts in Mutt</title><content type='html'>&lt;h1&gt;Introduction&lt;/h1&gt;&lt;br /&gt;&lt;br /&gt;For some time now I have managing all my contact information (a.k.a address book) in GMail because this allows me for easy synchronization of contacts with my cell phone that is a Google Phone HTC Hero.&lt;br /&gt;&lt;br /&gt;What I was missing was the ability to query the GMail contacts from within my favorite email client: &lt;a href="http://www.mutt.org/"&gt;Mutt&lt;/a&gt; and the solutions I found in Google were not working for me.&lt;br /&gt;&lt;br /&gt;The first solution I found [&lt;a href="http://antonyjepson.wordpress.com/2009/06/27/using-your-gmail-contacts-in-mutt/"&gt;1&lt;/a&gt;] was to export all my GMail contacts to vcards and then import these to abook [&lt;a href="http://abook.sourceforge.net/"&gt;2&lt;/a&gt;] that is an address book compatible with Mutt. Not really a solution should I say.&lt;br /&gt;&lt;br /&gt;The second solution [&lt;a href="http://castrojo.wordpress.com/2009/01/28/gmail-contacts-with-mutt/"&gt;3&lt;/a&gt;] I found is actually pretty good. Is a small python script that can be used within mutt using the "query_command" [&lt;a href="http://wiki.mutt.org/?QueryCommand"&gt;4&lt;/a&gt;] and actually queries GMail contacts web service API. Also supports caching so you do not need to connect every time to GMail service speeding up the query time.&lt;br /&gt;&lt;br /&gt;Unfortunately this solution did not work very well for me. Some contacts would not be auto completed when composing an email and some other would not even appear. For example contacts with non ASCII characters (e.g. Japanese Kanji) would never get autocompleted, even thought they appeared when listing all contacts.&lt;br /&gt;&lt;br /&gt;So after some time I implemented my own solution, in Ruby, that works perfectly for me and also has some additional features for groups and mailing lists.&lt;br /&gt;&lt;br /&gt;&lt;h1&gt;Query GMail Contacts within Mutt&lt;/h1&gt;&lt;br /&gt;&lt;br /&gt;Using the gdata gem [&lt;a href="http://code.google.com/intl/ja/apis/gdata/articles/gdata_on_rails.html"&gt;5&lt;/a&gt;] and some knowledge of the Google contacts web API [&lt;a href="http://code.google.com/intl/ja/apis/contacts/docs/3.0/reference.html"&gt;6&lt;/a&gt;] it was relatively easy to implement a Ruby script that could be used with Mutt to query my contacts directly from GMail:&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;&lt;pre&gt;&lt;span class="PreProc"&gt;#!/usr/bin/env ruby1.8&lt;/span&gt;&lt;br /&gt;&lt;span class="Comment"&gt;##&lt;/span&gt;&lt;br /&gt;&lt;span class="Comment"&gt;# File:   contactos.rb&lt;/span&gt;&lt;br /&gt;&lt;span class="Comment"&gt;# Author: Horacio Sanson (hsanson at gmail)&lt;/span&gt;&lt;br /&gt;&lt;span class="Comment"&gt;# Date:   2010/01/22&lt;/span&gt;&lt;br /&gt;&lt;span class="Comment"&gt;#&lt;/span&gt;&lt;br /&gt;&lt;span class="Comment"&gt;# Descr:&lt;/span&gt;&lt;br /&gt;&lt;span class="Comment"&gt;#    Small script to facilitate use of GMail contacts within mutt email client.&lt;/span&gt;&lt;br /&gt;&lt;span class="Comment"&gt;#&lt;/span&gt;&lt;br /&gt;&lt;span class="Comment"&gt;# Features:&lt;/span&gt;&lt;br /&gt;&lt;span class="Comment"&gt;#    - Generates a list of group and subscribe commands generated from your&lt;/span&gt;&lt;br /&gt;&lt;span class="Comment"&gt;#      GMail contacts groups that can be sourced from your muttrc file.&lt;/span&gt;&lt;br /&gt;&lt;span class="Comment"&gt;#    - Can be used to search for contacts within mutt using the query_command&lt;/span&gt;&lt;br /&gt;&lt;span class="Comment"&gt;#      option in the same way abook or ldbd are used.&lt;/span&gt;&lt;br /&gt;&lt;span class="Comment"&gt;#    - Results are cached for a period of time (configurable) to speed up&lt;/span&gt;&lt;br /&gt;&lt;span class="Comment"&gt;#      queries.&lt;/span&gt;&lt;br /&gt;&lt;span class="Comment"&gt;#&lt;/span&gt;&lt;br /&gt;&lt;span class="Comment"&gt;# Installation:&lt;/span&gt;&lt;br /&gt;&lt;span class="Comment"&gt;#    To use this script you need ruby and rubygems 1.8 and the gdata gem. To&lt;/span&gt;&lt;br /&gt;&lt;span class="Comment"&gt;#    install these in Ubuntu/Kubuntu use the following commands.&lt;/span&gt;&lt;br /&gt;&lt;span class="Comment"&gt;#&lt;/span&gt;&lt;br /&gt;&lt;span class="Comment"&gt;#      sudo aptitude install ruby1.8 rubygems-1.8 libopenssl-ruby1.8&lt;/span&gt;&lt;br /&gt;&lt;span class="Comment"&gt;#      sudo gem1.8 install gdata &lt;/span&gt;&lt;br /&gt;&lt;span class="Comment"&gt;#&lt;/span&gt;&lt;br /&gt;&lt;span class="Comment"&gt;#    Make sure to read the comments below to learn how to configure this script&lt;/span&gt;&lt;br /&gt;&lt;span class="Comment"&gt;#    to work with your GMail account.&lt;/span&gt;&lt;br /&gt;&lt;span class="Comment"&gt;#&lt;/span&gt;&lt;br /&gt;&lt;span class="Comment"&gt;#    Then in your muttrc file add these lines:&lt;/span&gt;&lt;br /&gt;&lt;span class="Comment"&gt;#&lt;/span&gt;&lt;br /&gt;&lt;span class="Comment"&gt;#       source '/PATH_TO_SCRIPT/contactos.rb --groups|'&lt;/span&gt;&lt;br /&gt;&lt;span class="Comment"&gt;#       source '/PATH_TO_SCRIPT/contactos.rb --subscribes|'&lt;/span&gt;&lt;br /&gt;&lt;span class="Comment"&gt;#       set query_command =&amp;quot;/PATH_TO_SCRIPT/contactos.rb --mutt %s&amp;quot;&lt;/span&gt;&lt;br /&gt;&lt;span class="Comment"&gt;#       set query_format=&amp;quot;%4c %t %-40.40a %-40.40n %?e?(%e)?&amp;quot;&lt;/span&gt;&lt;br /&gt;&lt;span class="Comment"&gt;#       bind editor &amp;lt;Tab&amp;gt; complete-query&lt;/span&gt;&lt;br /&gt;&lt;span class="Comment"&gt;#       bind editor ^T complete&lt;/span&gt;&lt;br /&gt;&lt;span class="Comment"&gt;#&lt;/span&gt;&lt;br /&gt;&lt;span class="Comment"&gt;#    with this configuration you will be able to use your GMail groups in all&lt;/span&gt;&lt;br /&gt;&lt;span class="Comment"&gt;#    regexp's and create hooks for them. Pressing &amp;lt;tab&amp;gt; when filling a To: or&lt;/span&gt;&lt;br /&gt;&lt;span class="Comment"&gt;#    From: header will give you a list of options to choose or auto complete the&lt;/span&gt;&lt;br /&gt;&lt;span class="Comment"&gt;#    address if only one matches.&lt;/span&gt;&lt;br /&gt;&lt;span class="Comment"&gt;#&lt;/span&gt;&lt;br /&gt;&lt;span class="Comment"&gt;# Resources:&lt;/span&gt;&lt;br /&gt;&lt;span class="Comment"&gt;#    - &lt;a href="http://antonyjepson.wordpress.com/2009/06/27/using-your-gmail-contacts-in-mutt/"&gt;http://antonyjepson.wordpress.com/2009/06/27/using-your-gmail-contacts-in-mutt/&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Comment"&gt;#    - &lt;a href="http://www.chizang.net/alex/blog/code/mutt-query-gmail/"&gt;http://www.chizang.net/alex/blog/code/mutt-query-gmail/&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Comment"&gt;#    - &lt;a href="http://castrojo.wordpress.com/2009/01/28/gmail-contacts-with-mutt/"&gt;http://castrojo.wordpress.com/2009/01/28/gmail-contacts-with-mutt/&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Comment"&gt;#    - &lt;a href="http://wiki.mutt.org/?QueryCommand"&gt;http://wiki.mutt.org/?QueryCommand&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Comment"&gt;#    - &lt;a href="http://code.google.com/apis/contacts/docs/3.0/reference.html#Feeds"&gt;http://code.google.com/apis/contacts/docs/3.0/reference.html#Feeds&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Comment"&gt;#    - &lt;a href="http://code.google.com/apis/gdata/articles/gdata_on_rails.html#GettingStarted"&gt;http://code.google.com/apis/gdata/articles/gdata_on_rails.html#GettingStarted&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Comment"&gt;#&lt;/span&gt;&lt;br /&gt;&lt;span class="Comment"&gt;# &lt;/span&gt;&lt;span class="Todo"&gt;TODO&lt;/span&gt;&lt;span class="Comment"&gt;:&lt;/span&gt;&lt;br /&gt;&lt;span class="Comment"&gt;#   - Mutt only sources the group list once on startup. If we add new groups or&lt;/span&gt;&lt;br /&gt;&lt;span class="Comment"&gt;#     add contacts to a group these won't be reflected in mutt until we restart&lt;/span&gt;&lt;br /&gt;&lt;span class="Comment"&gt;#     it. Not really a problem because mutt has the fastest start up time.&lt;/span&gt;&lt;br /&gt;&lt;span class="Comment"&gt;#   - Create a script to add contacts from within mutt.&lt;/span&gt;&lt;br /&gt;&lt;span class="Comment"&gt;#      - Find if create-alias can accept a script as parameter.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="rubyMethod"&gt;require&lt;/span&gt; &lt;span class="String"&gt;&amp;quot;&lt;/span&gt;&lt;span class="String"&gt;rubygems&lt;/span&gt;&lt;span class="String"&gt;&amp;quot;&lt;/span&gt;&lt;br /&gt;&lt;span class="rubyMethod"&gt;require&lt;/span&gt; &lt;span class="String"&gt;&amp;quot;&lt;/span&gt;&lt;span class="String"&gt;gdata&lt;/span&gt;&lt;span class="String"&gt;&amp;quot;&lt;/span&gt;&lt;br /&gt;&lt;span class="rubyMethod"&gt;require&lt;/span&gt; &lt;span class="String"&gt;&amp;quot;&lt;/span&gt;&lt;span class="String"&gt;fileutils&lt;/span&gt;&lt;span class="String"&gt;&amp;quot;&lt;/span&gt;&lt;br /&gt;&lt;span class="rubyMethod"&gt;require&lt;/span&gt; &lt;span class="String"&gt;&amp;quot;&lt;/span&gt;&lt;span class="String"&gt;pp&lt;/span&gt;&lt;span class="String"&gt;&amp;quot;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="Comment"&gt;## Set up here your GMail account username and password&lt;/span&gt;&lt;br /&gt;&lt;span class="Type"&gt;USERNAME&lt;/span&gt;=&lt;span class="String"&gt;&amp;quot;&lt;/span&gt;&lt;span class="String"&gt;user&lt;/span&gt;&lt;span class="String"&gt;&amp;quot;&lt;/span&gt;&lt;br /&gt;&lt;span class="Type"&gt;PASSWORD&lt;/span&gt;=&lt;span class="String"&gt;&amp;quot;&lt;/span&gt;&lt;span class="String"&gt;secret&lt;/span&gt;&lt;span class="String"&gt;&amp;quot;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="Comment"&gt;# You may create a group in you GMail contacts and add all the mailing lists&lt;/span&gt;&lt;br /&gt;&lt;span class="Comment"&gt;# you are subscribed into that group. This script will generate a bunch of&lt;/span&gt;&lt;br /&gt;&lt;span class="Comment"&gt;# subscribe commands for all addresses in that group.&lt;/span&gt;&lt;br /&gt;&lt;span class="Type"&gt;MAILISTGROUP&lt;/span&gt;=&lt;span class="String"&gt;&amp;quot;&lt;/span&gt;&lt;span class="String"&gt;Mailing Lists&lt;/span&gt;&lt;span class="String"&gt;&amp;quot;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="Comment"&gt;# Make sure this value is larger than the total number of contacts you have.&lt;/span&gt;&lt;br /&gt;&lt;span class="Type"&gt;MAXRESULTS&lt;/span&gt;=&lt;span class="Constant"&gt;999&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="Comment"&gt;# How much time before the local cache expires in seconds.&lt;/span&gt;&lt;br /&gt;&lt;span class="Type"&gt;UPDATE_INTERVAL&lt;/span&gt;=&lt;span class="Constant"&gt;3600&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="Comment"&gt;# Where to store the local cache for faster query times.&lt;/span&gt;&lt;br /&gt;&lt;span class="Type"&gt;CACHEFILE&lt;/span&gt;=&lt;span class="String"&gt;&amp;quot;&lt;/span&gt;&lt;span class="String"&gt;~/.mutt/cache/gcontacts&lt;/span&gt;&lt;span class="String"&gt;&amp;quot;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="Comment"&gt;###############################################################################&lt;/span&gt;&lt;br /&gt;&lt;span class="Comment"&gt;## DON'T CHANGE ANYTHING BELOW THIS POINT&lt;/span&gt;&lt;br /&gt;&lt;span class="Comment"&gt;##   unless you know what your are doing&lt;/span&gt;&lt;br /&gt;&lt;span class="Comment"&gt;###############################################################################&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="Statement"&gt;class&lt;/span&gt; &lt;span class="Type"&gt;Contact&lt;/span&gt;&lt;br /&gt;  &lt;span class="rubyMethod"&gt;attr_accessor&lt;/span&gt; &lt;span class="Constant"&gt;:emails&lt;/span&gt;, &lt;span class="Constant"&gt;:groups&lt;/span&gt;&lt;br /&gt;  &lt;span class="rubyMethod"&gt;attr_reader&lt;/span&gt; &lt;span class="Constant"&gt;:name&lt;/span&gt;, &lt;span class="Constant"&gt;:id&lt;/span&gt;&lt;br /&gt;  &lt;span class="Statement"&gt;def&lt;/span&gt; &lt;span class="Identifier"&gt;initialize&lt;/span&gt;(id, name=&lt;span class="String"&gt;&amp;quot;&amp;quot;&lt;/span&gt;)&lt;br /&gt;    &lt;span class="Identifier"&gt;@id&lt;/span&gt; = id&lt;br /&gt;    &lt;span class="Identifier"&gt;@name&lt;/span&gt; = name&lt;br /&gt;    &lt;span class="Identifier"&gt;@emails&lt;/span&gt; = []&lt;br /&gt;    &lt;span class="Identifier"&gt;@groups&lt;/span&gt; = []&lt;br /&gt;  &lt;span class="Statement"&gt;end&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;  &lt;span class="Statement"&gt;def&lt;/span&gt; &lt;span class="Identifier"&gt;mutt_match&lt;/span&gt;(pattern)&lt;br /&gt;    &lt;span class="Statement"&gt;return&lt;/span&gt; mutt_fmt &lt;span class="Statement"&gt;if&lt;/span&gt; &lt;span class="Identifier"&gt;@name&lt;/span&gt; &lt;span class="Statement"&gt;and&lt;/span&gt; &lt;span class="Identifier"&gt;@name&lt;/span&gt; =~ &lt;span class="Type"&gt;Regexp&lt;/span&gt;.new(pattern,&lt;span class="Type"&gt;Regexp&lt;/span&gt;::&lt;span class="Type"&gt;IGNORECASE&lt;/span&gt;)&lt;br /&gt;&lt;br /&gt;    str = &lt;span class="String"&gt;&amp;quot;&amp;quot;&lt;/span&gt;&lt;br /&gt;    &lt;span class="Identifier"&gt;@emails&lt;/span&gt;.each { |&lt;span class="Identifier"&gt;email&lt;/span&gt;|&lt;br /&gt;      str &amp;lt;&amp;lt; &lt;span class="String"&gt;&amp;quot;&lt;/span&gt;&lt;span class="Special"&gt;#{&lt;/span&gt;email&lt;span class="Special"&gt;}&lt;/span&gt;&lt;span class="Special"&gt;\t&lt;/span&gt;&lt;span class="Special"&gt;#{&lt;/span&gt;&lt;span class="Identifier"&gt;@name&lt;/span&gt;||email&lt;span class="Special"&gt;}&lt;/span&gt;&lt;span class="Special"&gt;\t&lt;/span&gt;&lt;span class="Special"&gt;#{&lt;/span&gt;&lt;span class="Identifier"&gt;@groups&lt;/span&gt;.first&lt;span class="Special"&gt;}&lt;/span&gt;&lt;span class="Special"&gt;\n&lt;/span&gt;&lt;span class="String"&gt;&amp;quot;&lt;/span&gt; &lt;span class="Statement"&gt;if&lt;/span&gt; email =~ &lt;span class="Type"&gt;Regexp&lt;/span&gt;.new(pattern,&lt;span class="Type"&gt;Regexp&lt;/span&gt;::&lt;span class="Type"&gt;IGNORECASE&lt;/span&gt;)&lt;br /&gt;    }&lt;br /&gt;    str&lt;br /&gt;  &lt;span class="Statement"&gt;end&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;  &lt;span class="Statement"&gt;def&lt;/span&gt; &lt;span class="Identifier"&gt;mutt_fmt&lt;/span&gt;&lt;br /&gt;    str = &lt;span class="String"&gt;&amp;quot;&amp;quot;&lt;/span&gt;&lt;br /&gt;    &lt;span class="Identifier"&gt;@emails&lt;/span&gt;.each { |&lt;span class="Identifier"&gt;email&lt;/span&gt;|&lt;br /&gt;       str &amp;lt;&amp;lt; &lt;span class="String"&gt;&amp;quot;&lt;/span&gt;&lt;span class="Special"&gt;#{&lt;/span&gt;email&lt;span class="Special"&gt;}&lt;/span&gt;&lt;span class="Special"&gt;\t&lt;/span&gt;&lt;span class="Special"&gt;#{&lt;/span&gt;&lt;span class="Identifier"&gt;@name&lt;/span&gt;||email&lt;span class="Special"&gt;}&lt;/span&gt;&lt;span class="Special"&gt;\t&lt;/span&gt;&lt;span class="Special"&gt;#{&lt;/span&gt;&lt;span class="Identifier"&gt;@groups&lt;/span&gt;.first&lt;span class="Special"&gt;}&lt;/span&gt;&lt;span class="Special"&gt;\n&lt;/span&gt;&lt;span class="String"&gt;&amp;quot;&lt;/span&gt;&lt;br /&gt;    }&lt;br /&gt;    str&lt;br /&gt;  &lt;span class="Statement"&gt;end&lt;/span&gt;&lt;br /&gt;&lt;span class="Statement"&gt;end&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="Comment"&gt;# This method updates the local cache if the cache file is not present or if the&lt;/span&gt;&lt;br /&gt;&lt;span class="Comment"&gt;# UPDATE_INTERVAL has expired.&lt;/span&gt;&lt;br /&gt;&lt;span class="Statement"&gt;def&lt;/span&gt; &lt;span class="Identifier"&gt;update_cache&lt;/span&gt;&lt;br /&gt;  user_hash = &lt;span class="Constant"&gt;nil&lt;/span&gt;&lt;br /&gt;  &lt;span class="Statement"&gt;if&lt;/span&gt; ! &lt;span class="Type"&gt;File&lt;/span&gt;.exists?(&lt;span class="Type"&gt;File&lt;/span&gt;.expand_path(&lt;span class="Type"&gt;CACHEFILE&lt;/span&gt;)) &lt;span class="Statement"&gt;or&lt;/span&gt; &lt;span class="Type"&gt;Time&lt;/span&gt;.now - &lt;span class="Type"&gt;File&lt;/span&gt;.stat(&lt;span class="Type"&gt;File&lt;/span&gt;.expand_path(&lt;span class="Type"&gt;CACHEFILE&lt;/span&gt;)).mtime &amp;gt; &lt;span class="Type"&gt;UPDATE_INTERVAL&lt;/span&gt;&lt;br /&gt;    &lt;span class="Comment"&gt;#STDERR &amp;lt;&amp;lt; &amp;quot;Updating from gmail\n&amp;quot;&lt;/span&gt;&lt;br /&gt;    user_hash = {}&lt;br /&gt;    client = &lt;span class="Type"&gt;GData&lt;/span&gt;::&lt;span class="Type"&gt;Client&lt;/span&gt;::&lt;span class="Type"&gt;Contacts&lt;/span&gt;.new&lt;br /&gt;&lt;br /&gt;    &lt;span class="Statement"&gt;begin&lt;/span&gt;&lt;br /&gt;      client.clientlogin(&lt;span class="String"&gt;&amp;quot;&lt;/span&gt;&lt;span class="Special"&gt;#{&lt;/span&gt;&lt;span class="Type"&gt;USERNAME&lt;/span&gt;&lt;span class="Special"&gt;}&lt;/span&gt;&lt;span class="String"&gt;@gmail.com&lt;/span&gt;&lt;span class="String"&gt;&amp;quot;&lt;/span&gt;, &lt;span class="Type"&gt;PASSWORD&lt;/span&gt;)&lt;br /&gt;    &lt;span class="Statement"&gt;rescue&lt;/span&gt; &lt;span class="Type"&gt;GData&lt;/span&gt;::&lt;span class="Type"&gt;Client&lt;/span&gt;::&lt;span class="Type"&gt;AuthorizationError&lt;/span&gt;&lt;br /&gt;      &lt;span class="Identifier"&gt;STDERR&lt;/span&gt; &amp;lt;&amp;lt; &lt;span class="String"&gt;&amp;quot;&lt;/span&gt;&lt;span class="String"&gt;Failed to authenticate&lt;/span&gt;&lt;span class="Special"&gt;\n&lt;/span&gt;&lt;span class="String"&gt;&amp;quot;&lt;/span&gt;&lt;br /&gt;      &lt;span class="Statement"&gt;return&lt;/span&gt; &lt;span class="Constant"&gt;nil&lt;/span&gt;&lt;br /&gt;    &lt;span class="Statement"&gt;rescue&lt;/span&gt; =&amp;gt; e&lt;br /&gt;      &lt;span class="Identifier"&gt;STDERR&lt;/span&gt; &amp;lt;&amp;lt; &lt;span class="String"&gt;&amp;quot;&lt;/span&gt;&lt;span class="String"&gt;Failed to log into Gmail: &lt;/span&gt;&lt;span class="Special"&gt;#{&lt;/span&gt;e&lt;span class="Special"&gt;}&lt;/span&gt;&lt;span class="Special"&gt;\n&lt;/span&gt;&lt;span class="String"&gt;&amp;quot;&lt;/span&gt;&lt;br /&gt;    &lt;span class="Statement"&gt;end&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;    &lt;span class="Comment"&gt;# Create a hash list of all groups&lt;/span&gt;&lt;br /&gt;    group_hash = {}&lt;br /&gt;    groups = client.get(&lt;span class="String"&gt;&amp;quot;&lt;/span&gt;&lt;span class="String"&gt;&lt;a href="http://www.google.com/m8/feeds/groups/"&gt;http://www.google.com/m8/feeds/groups/&lt;/a&gt;&lt;/span&gt;&lt;span class="Special"&gt;#{&lt;/span&gt;&lt;span class="Type"&gt;USERNAME&lt;/span&gt;&lt;span class="Special"&gt;}&lt;/span&gt;&lt;span class="String"&gt;%40gmail.com/full?max-results=&lt;/span&gt;&lt;span class="Special"&gt;#{&lt;/span&gt;&lt;span class="Type"&gt;MAXRESULTS&lt;/span&gt;&lt;span class="Special"&gt;}&lt;/span&gt;&lt;span class="String"&gt;&amp;quot;&lt;/span&gt;).to_xml&lt;br /&gt;    groups.elements.each(&lt;span class="String"&gt;'&lt;/span&gt;&lt;span class="String"&gt;entry&lt;/span&gt;&lt;span class="String"&gt;'&lt;/span&gt;) { |&lt;span class="Identifier"&gt;entry&lt;/span&gt;|&lt;br /&gt;      name = entry.elements[&lt;span class="String"&gt;'&lt;/span&gt;&lt;span class="String"&gt;title&lt;/span&gt;&lt;span class="String"&gt;'&lt;/span&gt;].text.gsub(&lt;span class="String"&gt;&amp;quot;&lt;/span&gt;&lt;span class="String"&gt;System Group: &lt;/span&gt;&lt;span class="String"&gt;&amp;quot;&lt;/span&gt;,&lt;span class="String"&gt;&amp;quot;&amp;quot;&lt;/span&gt;)&lt;br /&gt;      id = entry.elements[&lt;span class="String"&gt;'&lt;/span&gt;&lt;span class="String"&gt;id&lt;/span&gt;&lt;span class="String"&gt;'&lt;/span&gt;].text&lt;br /&gt;      group_hash[id] = name&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    &lt;span class="Comment"&gt;# Create a hash list of all users&lt;/span&gt;&lt;br /&gt;    feeds = client.get(&lt;span class="String"&gt;&amp;quot;&lt;/span&gt;&lt;span class="String"&gt;&lt;a href="http://www.google.com/m8/feeds/contacts/"&gt;http://www.google.com/m8/feeds/contacts/&lt;/a&gt;&lt;/span&gt;&lt;span class="Special"&gt;#{&lt;/span&gt;&lt;span class="Type"&gt;USERNAME&lt;/span&gt;&lt;span class="Special"&gt;}&lt;/span&gt;&lt;span class="String"&gt;%40gmail.com/full?max-results=&lt;/span&gt;&lt;span class="Special"&gt;#{&lt;/span&gt;&lt;span class="Type"&gt;MAXRESULTS&lt;/span&gt;&lt;span class="Special"&gt;}&lt;/span&gt;&lt;span class="String"&gt;&amp;quot;&lt;/span&gt;).to_xml&lt;br /&gt;    feeds.elements.each(&lt;span class="String"&gt;'&lt;/span&gt;&lt;span class="String"&gt;entry&lt;/span&gt;&lt;span class="String"&gt;'&lt;/span&gt;) { |&lt;span class="Identifier"&gt;entry&lt;/span&gt;|&lt;br /&gt;      name = entry.elements[&lt;span class="String"&gt;'&lt;/span&gt;&lt;span class="String"&gt;title&lt;/span&gt;&lt;span class="String"&gt;'&lt;/span&gt;].text&lt;br /&gt;      id = entry.elements[&lt;span class="String"&gt;'&lt;/span&gt;&lt;span class="String"&gt;id&lt;/span&gt;&lt;span class="String"&gt;'&lt;/span&gt;].text&lt;br /&gt;      new_contact = &lt;span class="Type"&gt;Contact&lt;/span&gt;.new(id, name)&lt;br /&gt;&lt;br /&gt;      entry.elements.each(&lt;span class="String"&gt;'&lt;/span&gt;&lt;span class="String"&gt;gd:email&lt;/span&gt;&lt;span class="String"&gt;'&lt;/span&gt;) { |&lt;span class="Identifier"&gt;email&lt;/span&gt;|&lt;br /&gt;        new_contact.emails &amp;lt;&amp;lt; email.attribute(&lt;span class="String"&gt;'&lt;/span&gt;&lt;span class="String"&gt;address&lt;/span&gt;&lt;span class="String"&gt;'&lt;/span&gt;).value&lt;br /&gt;      }&lt;br /&gt;      entry.elements.each(&lt;span class="String"&gt;'&lt;/span&gt;&lt;span class="String"&gt;gContact:groupMembershipInfo&lt;/span&gt;&lt;span class="String"&gt;'&lt;/span&gt;) { |&lt;span class="Identifier"&gt;group&lt;/span&gt;|&lt;br /&gt;        new_contact.groups &amp;lt;&amp;lt; group_hash[group.attribute(&lt;span class="String"&gt;'&lt;/span&gt;&lt;span class="String"&gt;href&lt;/span&gt;&lt;span class="String"&gt;'&lt;/span&gt;).to_s]&lt;br /&gt;      }&lt;br /&gt;      user_hash[id] = new_contact&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    &lt;span class="Type"&gt;File&lt;/span&gt;.open(&lt;span class="Type"&gt;File&lt;/span&gt;.expand_path(&lt;span class="Type"&gt;CACHEFILE&lt;/span&gt;),&lt;span class="String"&gt;&amp;quot;&lt;/span&gt;&lt;span class="String"&gt;wb&lt;/span&gt;&lt;span class="String"&gt;&amp;quot;&lt;/span&gt;) { |&lt;span class="Identifier"&gt;fd&lt;/span&gt;|&lt;br /&gt;      fd &amp;lt;&amp;lt; &lt;span class="Type"&gt;Marshal&lt;/span&gt;.dump(user_hash)&lt;br /&gt;    }&lt;br /&gt;  &lt;span class="Statement"&gt;end&lt;/span&gt;&lt;br /&gt;&lt;span class="Statement"&gt;end&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="Statement"&gt;def&lt;/span&gt; &lt;span class="Identifier"&gt;load_cache&lt;/span&gt;&lt;br /&gt;  &lt;span class="Comment"&gt;#STDERR &amp;lt;&amp;lt; &amp;quot;Updating from local cache\n&amp;quot;&lt;/span&gt;&lt;br /&gt;  user_hash = {}&lt;br /&gt;  &lt;span class="Statement"&gt;if&lt;/span&gt; &lt;span class="Type"&gt;File&lt;/span&gt;.exists?(&lt;span class="Type"&gt;File&lt;/span&gt;.expand_path(&lt;span class="Type"&gt;CACHEFILE&lt;/span&gt;))&lt;br /&gt;    &lt;span class="Type"&gt;File&lt;/span&gt;.open(&lt;span class="Type"&gt;File&lt;/span&gt;.expand_path(&lt;span class="Type"&gt;CACHEFILE&lt;/span&gt;),&lt;span class="String"&gt;&amp;quot;&lt;/span&gt;&lt;span class="String"&gt;rb&lt;/span&gt;&lt;span class="String"&gt;&amp;quot;&lt;/span&gt;) { |&lt;span class="Identifier"&gt;fd&lt;/span&gt;|&lt;br /&gt;      user_hash = &lt;span class="Type"&gt;Marshal&lt;/span&gt;.load(fd.read)&lt;br /&gt;    }&lt;br /&gt;  &lt;span class="Statement"&gt;end&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;  &lt;span class="Statement"&gt;return&lt;/span&gt; user_hash&lt;br /&gt;&lt;span class="Statement"&gt;end&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="Statement"&gt;def&lt;/span&gt; &lt;span class="Identifier"&gt;print_help&lt;/span&gt;&lt;br /&gt; puts &lt;span class="String"&gt;&amp;quot;&lt;/span&gt;&lt;span class="String"&gt;usage: &lt;/span&gt;&lt;span class="String"&gt;&amp;quot;&lt;/span&gt;&lt;br /&gt; puts &lt;span class="String"&gt;&amp;quot;&lt;/span&gt;&lt;span class="String"&gt;  contactos.rb --mutt [pattern]&lt;/span&gt;&lt;span class="String"&gt;&amp;quot;&lt;/span&gt;&lt;br /&gt; puts &lt;span class="String"&gt;&amp;quot;&lt;/span&gt;&lt;span class="String"&gt;  contactos.rb --groups&lt;/span&gt;&lt;span class="String"&gt;&amp;quot;&lt;/span&gt;&lt;br /&gt; puts &lt;span class="String"&gt;&amp;quot;&lt;/span&gt;&lt;span class="String"&gt;  contactos.rb --subscribes&lt;/span&gt;&lt;span class="String"&gt;&amp;quot;&lt;/span&gt;&lt;br /&gt; puts &lt;span class="String"&gt;&amp;quot;&lt;/span&gt;&lt;span class="String"&gt;  contactos.rb --aliases&lt;/span&gt;&lt;span class="String"&gt;&amp;quot;&lt;/span&gt;&lt;br /&gt;&lt;span class="Statement"&gt;end&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="Statement"&gt;if&lt;/span&gt; &lt;span class="Identifier"&gt;ARGV&lt;/span&gt;.empty?&lt;br /&gt;  print_help&lt;br /&gt;&lt;span class="Statement"&gt;else&lt;/span&gt;&lt;br /&gt;  update_cache&lt;br /&gt;  contacts = load_cache&lt;br /&gt;  &lt;span class="Statement"&gt;case&lt;/span&gt; &lt;span class="Identifier"&gt;ARGV&lt;/span&gt;[&lt;span class="Constant"&gt;0&lt;/span&gt;]&lt;br /&gt;    &lt;span class="Statement"&gt;when&lt;/span&gt; &lt;span class="String"&gt;&amp;quot;&lt;/span&gt;&lt;span class="String"&gt;--mutt&lt;/span&gt;&lt;span class="String"&gt;&amp;quot;&lt;/span&gt;&lt;br /&gt;      puts &lt;span class="String"&gt;&amp;quot;&amp;quot;&lt;/span&gt;   &lt;span class="Comment"&gt;# Mutt ignores the first line &lt;/span&gt;&lt;br /&gt;      &lt;span class="Statement"&gt;if&lt;/span&gt; &lt;span class="Identifier"&gt;ARGV&lt;/span&gt;[&lt;span class="Constant"&gt;1&lt;/span&gt;]&lt;br /&gt;        contacts.each { |&lt;span class="Identifier"&gt;k&lt;/span&gt;, &lt;span class="Identifier"&gt;contact&lt;/span&gt;|&lt;br /&gt;          &lt;span class="Identifier"&gt;STDOUT&lt;/span&gt; &amp;lt;&amp;lt; contact.mutt_match(&lt;span class="Identifier"&gt;ARGV&lt;/span&gt;[&lt;span class="Constant"&gt;1&lt;/span&gt;])&lt;br /&gt;        }&lt;br /&gt;      &lt;span class="Statement"&gt;else&lt;/span&gt;&lt;br /&gt;        contacts.each { |&lt;span class="Identifier"&gt;k&lt;/span&gt;, &lt;span class="Identifier"&gt;contact&lt;/span&gt;|&lt;br /&gt;          &lt;span class="Identifier"&gt;STDOUT&lt;/span&gt; &amp;lt;&amp;lt; contact.mutt_fmt&lt;br /&gt;        }&lt;br /&gt;      &lt;span class="Statement"&gt;end&lt;/span&gt;&lt;br /&gt;    &lt;span class="Statement"&gt;when&lt;/span&gt; &lt;span class="String"&gt;&amp;quot;&lt;/span&gt;&lt;span class="String"&gt;--groups&lt;/span&gt;&lt;span class="String"&gt;&amp;quot;&lt;/span&gt;&lt;br /&gt;      contacts.each { |&lt;span class="Identifier"&gt;k&lt;/span&gt;,&lt;span class="Identifier"&gt;contact&lt;/span&gt;|&lt;br /&gt;        contact.groups.each { |&lt;span class="Identifier"&gt;g&lt;/span&gt;|&lt;br /&gt;          puts &lt;span class="String"&gt;&amp;quot;&lt;/span&gt;&lt;span class="String"&gt;group -group \&amp;quot;&lt;/span&gt;&lt;span class="Special"&gt;#{&lt;/span&gt;g&lt;span class="Special"&gt;}&lt;/span&gt;&lt;span class="String"&gt;\&amp;quot; -addr &lt;/span&gt;&lt;span class="Special"&gt;#{&lt;/span&gt;contact.emails.join(&lt;span class="String"&gt;'&lt;/span&gt;&lt;span class="String"&gt;, &lt;/span&gt;&lt;span class="String"&gt;'&lt;/span&gt;)&lt;span class="Special"&gt;}&lt;/span&gt;&lt;span class="String"&gt;&amp;quot;&lt;/span&gt; &lt;span class="Statement"&gt;if&lt;/span&gt; ! contact.emails.empty?&lt;br /&gt;        }&lt;br /&gt;      }&lt;br /&gt;    &lt;span class="Statement"&gt;when&lt;/span&gt; &lt;span class="String"&gt;&amp;quot;&lt;/span&gt;&lt;span class="String"&gt;--subscribes&lt;/span&gt;&lt;span class="String"&gt;&amp;quot;&lt;/span&gt;&lt;br /&gt;      contacts.each { |&lt;span class="Identifier"&gt;k&lt;/span&gt;,&lt;span class="Identifier"&gt;contact&lt;/span&gt;|&lt;br /&gt;        contact.groups.each { |&lt;span class="Identifier"&gt;g&lt;/span&gt;|&lt;br /&gt;          &lt;span class="Statement"&gt;if&lt;/span&gt; g == &lt;span class="Type"&gt;MAILISTGROUP&lt;/span&gt; &lt;span class="Statement"&gt;and&lt;/span&gt; contact.emails.size &amp;gt; &lt;span class="Constant"&gt;0&lt;/span&gt;&lt;br /&gt;            puts &lt;span class="String"&gt;&amp;quot;&lt;/span&gt;&lt;span class="String"&gt;subscribe &lt;/span&gt;&lt;span class="Special"&gt;#{&lt;/span&gt;contact.emails.join(&lt;span class="String"&gt;'&lt;/span&gt;&lt;span class="String"&gt; &lt;/span&gt;&lt;span class="String"&gt;'&lt;/span&gt;)&lt;span class="Special"&gt;}&lt;/span&gt;&lt;span class="String"&gt;&amp;quot;&lt;/span&gt;&lt;br /&gt;          &lt;span class="Statement"&gt;end&lt;/span&gt;&lt;br /&gt;        }&lt;br /&gt;      }&lt;br /&gt;    &lt;span class="Statement"&gt;when&lt;/span&gt; &lt;span class="String"&gt;&amp;quot;&lt;/span&gt;&lt;span class="String"&gt;--aliases&lt;/span&gt;&lt;span class="String"&gt;&amp;quot;&lt;/span&gt;&lt;br /&gt;      contacts.each { |&lt;span class="Identifier"&gt;k&lt;/span&gt;,&lt;span class="Identifier"&gt;contact&lt;/span&gt;|&lt;br /&gt;        contact.emails.each { |&lt;span class="Identifier"&gt;e&lt;/span&gt;|&lt;br /&gt;          &lt;span class="Statement"&gt;if&lt;/span&gt; contact.name&lt;br /&gt;            puts &lt;span class="String"&gt;&amp;quot;&lt;/span&gt;&lt;span class="String"&gt;alias \&amp;quot;&lt;/span&gt;&lt;span class="Special"&gt;#{&lt;/span&gt;contact.name&lt;span class="Special"&gt;}&lt;/span&gt;&lt;span class="String"&gt;\&amp;quot; &lt;/span&gt;&lt;span class="Special"&gt;#{&lt;/span&gt;contact.name&lt;span class="Special"&gt;}&lt;/span&gt;&lt;span class="String"&gt; &amp;lt;&lt;/span&gt;&lt;span class="Special"&gt;#{&lt;/span&gt;e&lt;span class="Special"&gt;}&lt;/span&gt;&lt;span class="String"&gt;&amp;gt;&lt;/span&gt;&lt;span class="String"&gt;&amp;quot;&lt;/span&gt;&lt;br /&gt;          &lt;span class="Statement"&gt;else&lt;/span&gt;&lt;br /&gt;            puts &lt;span class="String"&gt;&amp;quot;&lt;/span&gt;&lt;span class="String"&gt;alias \&amp;quot;&lt;/span&gt;&lt;span class="Special"&gt;#{&lt;/span&gt;e&lt;span class="Special"&gt;}&lt;/span&gt;&lt;span class="String"&gt;\&amp;quot; &lt;/span&gt;&lt;span class="Special"&gt;#{&lt;/span&gt;e&lt;span class="Special"&gt;}&lt;/span&gt;&lt;span class="String"&gt;&amp;quot;&lt;/span&gt;&lt;br /&gt;          &lt;span class="Statement"&gt;end&lt;/span&gt;&lt;br /&gt;        }&lt;br /&gt;      }&lt;br /&gt;    &lt;span class="Statement"&gt;when&lt;/span&gt; &lt;span class="String"&gt;&amp;quot;&lt;/span&gt;&lt;span class="String"&gt;-v&lt;/span&gt;&lt;span class="String"&gt;&amp;quot;&lt;/span&gt;&lt;br /&gt;    &lt;span class="Statement"&gt;when&lt;/span&gt; &lt;span class="String"&gt;&amp;quot;&lt;/span&gt;&lt;span class="String"&gt;--version&lt;/span&gt;&lt;span class="String"&gt;&amp;quot;&lt;/span&gt;&lt;br /&gt;      puts &lt;span class="String"&gt;&amp;quot;&lt;/span&gt;&lt;span class="String"&gt;Contactos.rb version 0.2.0, Copyright 2010 Horacio Sanson&lt;/span&gt;&lt;span class="String"&gt;&amp;quot;&lt;/span&gt;&lt;br /&gt;    &lt;span class="Statement"&gt;when&lt;/span&gt; &lt;span class="String"&gt;&amp;quot;&lt;/span&gt;&lt;span class="String"&gt;-h&lt;/span&gt;&lt;span class="String"&gt;&amp;quot;&lt;/span&gt;&lt;br /&gt;    &lt;span class="Statement"&gt;when&lt;/span&gt; &lt;span class="String"&gt;&amp;quot;&lt;/span&gt;&lt;span class="String"&gt;--help&lt;/span&gt;&lt;span class="String"&gt;&amp;quot;&lt;/span&gt;&lt;br /&gt;      print_help&lt;br /&gt;    &lt;span class="Statement"&gt;else&lt;/span&gt;&lt;br /&gt;      print_help&lt;br /&gt;  &lt;span class="Statement"&gt;end&lt;/span&gt;&lt;br /&gt;&lt;span class="Statement"&gt;end&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;Simply copy the above script somewhere in your machine (e.g. ~/.mutt/contactos.rb) and change the USERNAME and PASSWORD variables. Give the script execution property and some secure permissions:&lt;br /&gt;&lt;br /&gt;&lt;div class="code"&gt;chmod 700 ~/.mutt/contactos.rb&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;You may also change the MAXRESULTS, UPDATE_INTERVAL and CACHEFILE variables to fit your needs. Just make sure MAXRESULTS is larger than the total number of contacts you have and that you have write access to the CACHEFILE you set. If you set UPDATE_INTERVAL to zero then the scripts queries GMail directly every time that can be slow depending on you network connection.&lt;br /&gt;&lt;br /&gt;Also make sure you have installed Ruby and the gdata gem. In Ubuntu/Kubuntu this can be accomplished with the following commands:&lt;br /&gt;&lt;br /&gt;&lt;div class="code"&gt;&lt;br /&gt;sudo aptitude install ruby1.8 rubygems-1.8 libopenssl-ruby1.8&lt;br /&gt;sudo gem1.8 install gdata &lt;br /&gt;&lt;/div&gt;&lt;br /&gt;Finally configure Mutt to use this script to query contacts when you are filling the To: and From: headers of emails. To do this add these commands in your muttrc file:&lt;br /&gt;&lt;div class="code"&gt;&lt;br /&gt;set query_command ="~/mutt/contactos.rb --mutt %s"&lt;br /&gt;set query_format="%4c %t %-40.40a %-40.40n %?e?(%e)?"&lt;br /&gt;bind editor &lt;tab&gt; complete-query&lt;br /&gt;bind editor ^T complete&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;After this you can press &lt;tab&gt; to autocomplete contacts using you GMail contact list and all without leaving the comfort of Mutt.&lt;br /&gt;&lt;br /&gt;&lt;h1&gt;Integrating GMail contact groups within Mutt&lt;/h1&gt;&lt;br /&gt;After finishing my contacts script I realized that I could make even more things thanks to the rich Google contacts API and the scripting power and simplicity of ruby.&lt;br /&gt;&lt;br /&gt;To integrate Mutt with you Google contact groups simply add this to your muttrc file:&lt;br /&gt;&lt;div class="code"&gt;source '~/.mutt/contactos.rb --groups|'&lt;br /&gt;&lt;/div&gt;This command generates a list of "group" commands that map all GMail contact groups with Mut groups. Once this command is inserted in your muttrc file you may search, tag, delete and create hooks based on your GMail groups and manage the groups within GMail itself.&lt;br /&gt;&lt;br /&gt;&lt;h1&gt;Managing Mutt  mailing lists within GMail&lt;/h1&gt;&lt;br /&gt;One anoying thing about Mutt mailing lists is that you have to add a subscribe command for each mailing list you read in order to get all the features Mutt offers to handle mailing lists.&lt;br /&gt;&lt;br /&gt;With my script you can create a special group for mailing lists (e.g. Mailing Lists) and add all the addresses of all mailing lists you are subscribed into that group. Then you can add this command to your muttrc file:&lt;br /&gt;&lt;br /&gt;&lt;div class="code"&gt;source './~mutt/contactos.rb --subscribes|'&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;and magically you get all the subscribe commands automagically generated for you from you GMail contacts. If you prefer to use a different name for you mailing list group you have to change the MAILISTGROUP variable in the ruby script to match the name you have in you GMail contacts.&lt;br /&gt;&lt;br /&gt;&lt;h1&gt;Resources&lt;/h1&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;[1] &lt;a href="http://antonyjepson.wordpress.com/2009/06/27/using-your-gmail-contacts-in-mutt/"&gt;http://antonyjepson.wordpress.com/2009/06/27/using-your-gmail-contacts-in-mutt/&lt;/a&gt;&lt;/li&gt;&lt;li&gt;[2] &lt;a href="http://abook.sourceforge.net/"&gt;aBook&lt;/a&gt;&lt;/li&gt;&lt;li&gt;[3] &lt;a href="http://castrojo.wordpress.com/2009/01/28/gmail-contacts-with-mutt/"&gt;http://castrojo.wordpress.com/2009/01/28/gmail-contacts-with-mutt/&lt;/a&gt;&lt;/li&gt;&lt;li&gt;[4] &lt;a href="http://wiki.mutt.org/?QueryCommand"&gt; Mutt QueryCommand&lt;/a&gt;&lt;/li&gt;&lt;li&gt;[5] &lt;a href="http://code.google.com/intl/ja/apis/gdata/articles/gdata_on_rails.html"&gt;gdata gem&lt;/a&gt;&lt;/li&gt;&lt;li&gt;[6] &lt;a href="http://code.google.com/intl/ja/apis/contacts/docs/3.0/reference.html"&gt;Google Contacts Data API&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/34829202-9023623019842423646?l=piao-tech.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://piao-tech.blogspot.com/feeds/9023623019842423646/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://piao-tech.blogspot.com/2010/01/google-contacts-in-mutt.html#comment-form' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/34829202/posts/default/9023623019842423646'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/34829202/posts/default/9023623019842423646'/><link rel='alternate' type='text/html' href='http://piao-tech.blogspot.com/2010/01/google-contacts-in-mutt.html' title='Google Contacts in Mutt'/><author><name>龍神</name><uri>http://www.blogger.com/profile/16648963337079496096</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-34829202.post-9095519741254558315</id><published>2010-01-03T11:30:00.010+09:00</published><updated>2011-05-05T23:29:18.822+09:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Printer'/><category scheme='http://www.blogger.com/atom/ns#' term='Kubuntu'/><title type='text'>Brother DCP-595CN Printer In Ubuntu/Kubuntu</title><content type='html'>&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_99Fzui5MBLY/S0AJyxuSN7I/AAAAAAAAAOQ/Xjy53uNnTL4/s1600-h/4977766669511l.jpg"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 250px; height: 250px;" src="http://4.bp.blogspot.com/_99Fzui5MBLY/S0AJyxuSN7I/AAAAAAAAAOQ/Xjy53uNnTL4/s400/4977766669511l.jpg" border="0" alt=""id="BLOGGER_PHOTO_ID_5422344719299655602" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;This little machine is a printer, scanner and copy machine all in one. It has USB and ethernet ports but even better a wireless 802.11a/b/g port. This means I can have the printer anywhere in the house and print from my desktop or lapton freely. In &lt;a href="http://www.biccamera.com/bicbic/jsp/w/catalog/detail.jsp?JAN_CODE=4977766669511"&gt;Japan&lt;/a&gt; it costs around ￥15,000 (USD 150) that is pretty cheap for all the features packaged in.&lt;br /&gt;&lt;br /&gt;And the most important thing for me is that is 100% compatible with linux (Kubuntu). Here I will show the steps to get this little beast working with my Kubuntu machine. &lt;br /&gt;&lt;br /&gt;&lt;h2&gt;Prerequisites&lt;/h2&gt;&lt;br /&gt;&lt;br /&gt;I use the wireless interface to connect to the printer/scanner so before you follow these instructions make sure the printer has an IP configured. The wireless configuration is done using the printer control panel and is already covered in the printer manual so I will skip it.&lt;br /&gt;&lt;br /&gt;You may ping the printer IP address to check that you can reach it from your computer. If you cannot ping it then it is not well configured or you have problems with your LAN network.&lt;br /&gt;&lt;br /&gt;&lt;h2&gt;Installation&lt;/h2&gt;&lt;br /&gt;&lt;br /&gt;These instructions are based on the  &lt;a href="http://solutions.brother.co.jp/support/os/linux/cups_printer/install_08a.html"&gt;Brother solution&lt;/a&gt; page instructions.&lt;br /&gt;&lt;br /&gt;First we need to download both the LPR driver and the CUPS wrapper driver by going to the following URLs. Inside you will find RPM and DEB packages for the different printer models.&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;a href="http://solutions.brother.co.jp/support/os/linux/lpr_printer/driver.html"&gt;LPR Driver&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://solutions.brother.co.jp/support/os/linux/cups_printer/driver_cupswrapper.html"&gt;CUPS Wrapper Driver&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;If you have the same printer as me (DCP-595CN) then look for the DEB packages of this printer and click the link. You will be directed to a GPL license page where you must agree to the GPL terms (Left Button) after which the download will start.&lt;br /&gt;&lt;br /&gt;Once the DEB packages are downloaded we install them using the following commands:&lt;br /&gt;&lt;div class="code"&gt;&lt;br /&gt;sudo mkdir /usr/share/cups/model&lt;br /&gt;sudo mkdir /var/spool/lpd&lt;br /&gt;sudo mkdir -p /usr/lib/cups/filter&lt;br /&gt;sudo dpkg -i dcp595cnlpr-1.1.2-1.i386.deb &lt;br /&gt;sudo dpkg -i dcp595cncupswrapper-1.1.2-2.i386.deb&lt;br /&gt;&lt;/div&gt;note that there are only packages for i386 architectures but if you see the Q&amp;A link they explain how to install on amd64 architectures. All you have to do is add the --force-arquitecture switch to the dpkg command like:&lt;br /&gt;&lt;div class="code"&gt;sudo dpkg --force-arquitecture -i dcp595cnlpr-1.1.2-1.i386.deb &lt;br /&gt;sudo dpkg --force-arquitecture -i dcp595cncupswrapper-1.1.2-2.i386.deb&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;Now with the drivers installed we can use the CUPS administration page to add the printer. To do this we open our favorite Internet browser and access the following URL: &lt;a href="http://localhost:631"&gt;http://localhost:631&lt;/a&gt;. &lt;br /&gt;&lt;br /&gt;Enter the printer administration tab and add a new printer. If your printer is already configured with an IP address in your LAN it should appear in the list of detected printers (see screenshot below):&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_99Fzui5MBLY/S0AHr8Wi8lI/AAAAAAAAAOA/Njr6ZTNZLPs/s1600-h/DCP595cn01.png"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 400px; height: 314px;" src="http://4.bp.blogspot.com/_99Fzui5MBLY/S0AHr8Wi8lI/AAAAAAAAAOA/Njr6ZTNZLPs/s400/DCP595cn01.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5422342402870538834" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Select the printer and in the next window you will be asked to add some details about the printer like the place, description and name. You may add anything you like or leave the defaults and go to the next screen.&lt;br /&gt;&lt;br /&gt;In the next screen (see screenshot below) we select the printer driver to use. If you installed the DEB packages correctly then the correct driver should be selected here by default:&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_99Fzui5MBLY/S0AIuWCg-QI/AAAAAAAAAOI/L1BTFHppyC4/s1600-h/DCP595cn02.png"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 400px; height: 314px;" src="http://4.bp.blogspot.com/_99Fzui5MBLY/S0AIuWCg-QI/AAAAAAAAAOI/L1BTFHppyC4/s400/DCP595cn02.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5422343543637211394" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Simply press the "add printer" button to finish. Now your printer should be ready for printing. Go ahead the print something.&lt;br /&gt;&lt;br /&gt;&lt;h2&gt;Brother DCP-595CN Scanner In Ubuntu/Kubuntu&lt;/h2&gt;&lt;br /&gt;&lt;br /&gt;Getting the scanner working in Kubuntu is even easier. First we need to download the SANE driver from &lt;a href="http://solutions.brother.co.jp/support/os/linux/scanner/driver.html"&gt;Brothers home page&lt;/a&gt;. Which driver to download depends on the scanner model you have. In my case (DCP-595CN) I need the brscan3 driver. There are 32 and 64bit versions and RPM and DEB packages. For my configuration I need the brscan3 32bit DEB pacakge. Download the package for your configuration and install it using this command:&lt;br /&gt;&lt;div class="code"&gt;&lt;br /&gt;sudo aptitude install xsane sane-utils brscan3-0.2.8-1.i386.deb&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;In the command above I am installing some SANE packages and the brscan3 driver. Next we need to configure the scanner with the following command:&lt;br /&gt;&lt;div class="code"&gt;&lt;br /&gt;sudo brsaneconfig3 -a name=DCP-595CN model=DCP-595CN ip=192.168.11.4&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;Depending on the driver you installed the configuration command changes. For brscan3 we use the "brsaneconfig3" command. The name can be anything you want as long as it has no white spaces but the model and the ip must be set to the correct values. The ip of course is the IP address the printer has configured and the model is the model name of the printer. If you are not sure about the model or IP you can use the following command to query the network:&lt;br /&gt;&lt;div class="code"&gt;&lt;br /&gt;sudo brsaneconfig3  -q&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;This command gives a list of supported models and at the end a list of detected scanners. In my configuration at the end I get:&lt;br /&gt;&lt;div class="code"&gt;&lt;br /&gt;&lt;pre&gt;Devices on network&lt;br /&gt;0 DCP-595CN           "DCP-595CN"         I:192.168.11.4&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;If you do not see this list then your machine is not able to reach the scanner on the IP level so make sure it has the IP address configured and that you can ping it.&lt;br /&gt;&lt;br /&gt;After you have configured the scanner with the brscanconfig3 tool you are ready to scan. To test it you can run xsane and the scanner should be listed like in the screenshot below:&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_99Fzui5MBLY/S0AUbF3-P2I/AAAAAAAAAOY/gZQkRgA0Wl8/s1600-h/DCP595cn03.png"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 400px; height: 392px;" src="http://1.bp.blogspot.com/_99Fzui5MBLY/S0AUbF3-P2I/AAAAAAAAAOY/gZQkRgA0Wl8/s400/DCP595cn03.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5422356407020044130" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Select the scanner and scan something. Now you have a fully functional printer, scanner and copy machine in you Kubuntu installation.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/34829202-9095519741254558315?l=piao-tech.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://piao-tech.blogspot.com/feeds/9095519741254558315/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://piao-tech.blogspot.com/2010/01/brother-dcp-595cn-printer-in.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/34829202/posts/default/9095519741254558315'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/34829202/posts/default/9095519741254558315'/><link rel='alternate' type='text/html' href='http://piao-tech.blogspot.com/2010/01/brother-dcp-595cn-printer-in.html' title='Brother DCP-595CN Printer In Ubuntu/Kubuntu'/><author><name>龍神</name><uri>http://www.blogger.com/profile/16648963337079496096</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/_99Fzui5MBLY/S0AJyxuSN7I/AAAAAAAAAOQ/Xjy53uNnTL4/s72-c/4977766669511l.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-34829202.post-3262443831190196540</id><published>2009-12-27T13:37:00.004+09:00</published><updated>2011-01-17T01:19:54.820+09:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Tips'/><category scheme='http://www.blogger.com/atom/ns#' term='backup'/><category scheme='http://www.blogger.com/atom/ns#' term='incron'/><category scheme='http://www.blogger.com/atom/ns#' term='unison'/><category scheme='http://www.blogger.com/atom/ns#' term='Kubuntu'/><title type='text'>Synchronizing two machines</title><content type='html'>&lt;div class="outliner"&gt;&lt;pre&gt;&lt;span class="Statement"&gt;Synchronizing two machines&lt;/span&gt;                                                                                                                                                                                                                      &lt;br /&gt;                                                                                                                                                                                                                                                                               &lt;br /&gt;&lt;span class="Identifier"&gt;  Introduction&lt;/span&gt;                                                                                                                                                                                                                                 &lt;br /&gt;                                                                                                                                                                                                                                                                               &lt;br /&gt;&lt;span class="Constant"&gt;    The method I document here shows how I use unison in combination with&lt;/span&gt;                                                                                                                                                                        &lt;br /&gt;&lt;span class="Constant"&gt;    incrontab to keep some folders shared between my work and home machines in&lt;/span&gt;                                                                                                                                                                   &lt;br /&gt;&lt;span class="Constant"&gt;    sync almost in real time.&lt;/span&gt;                                                                                                                                                                                                                    &lt;br /&gt;                                                                                                                                                                                                                                                                               &lt;br /&gt;&lt;span class="Identifier"&gt;  Background&lt;/span&gt;                                                                                                                                                                                                                                   &lt;br /&gt;                                                                                                                                                                                                                                                                               &lt;br /&gt;&lt;span class="Constant"&gt;    This is only a rant so you can skip this if you are in a hurry.&lt;/span&gt;                                                                                                                                                                              &lt;br /&gt;                                                                                                                                                                                                                                                                               &lt;br /&gt;&lt;span class="Constant"&gt;    Before this setup I had a cron job with a rsync task to sync my shared&lt;/span&gt;                                                                                                                                                                       &lt;br /&gt;&lt;span class="Constant"&gt;    folders. The problem is that rsync is one-way sync tool and works well&lt;/span&gt;                                                                                                                                                                       &lt;br /&gt;&lt;span class="Constant"&gt;    when you have a master machine where you add/modify/delete files and then&lt;/span&gt;                                                                                                                                                                    &lt;br /&gt;&lt;span class="Constant"&gt;    rsync one or more slave machines to the master. In my case I have two&lt;/span&gt;                                                                                                                                                                        &lt;br /&gt;&lt;span class="Constant"&gt;    machines that are both master and changes on any of them have to be&lt;/span&gt;                                                                                                                                                                          &lt;br /&gt;&lt;span class="Constant"&gt;    propagated to the other.  Of course this master-master configuration can&lt;/span&gt;                                                                                                                                                                     &lt;br /&gt;&lt;span class="Constant"&gt;    be done with rsync but you really MUST be very careful on what order you&lt;/span&gt;                                                                                                                                                                     &lt;br /&gt;&lt;span class="Constant"&gt;    sync (e.g.  from A to B or from B to A) when you use the --delete switch&lt;/span&gt;                                                                                                                                                                     &lt;br /&gt;&lt;span class="Constant"&gt;    (see [1] and [2] fpr details). Not using the --delete switch means that no&lt;/span&gt;                                                                                                                                                                   &lt;br /&gt;&lt;span class="Constant"&gt;    file in those machines will ever be deleted unless you manually delete the&lt;/span&gt;                                                                                                                                                                   &lt;br /&gt;&lt;span class="Constant"&gt;    file from both sides.  I have been using rsync with a crob job for years&lt;/span&gt;                                                                                                                                                                     &lt;br /&gt;&lt;span class="Constant"&gt;    but a few months ago I was victim of the --delete switch. Looking for&lt;/span&gt;                                                                                                                                                                        &lt;br /&gt;&lt;span class="Constant"&gt;    alternatives I found unison that does the master-master configuration&lt;/span&gt;                                                                                                                                                                        &lt;br /&gt;&lt;span class="Constant"&gt;    amazingly well and at the same time I found about incrontab. Both unison&lt;/span&gt;                                                                                                                                                                     &lt;br /&gt;&lt;span class="Constant"&gt;    and incrontab together resulted in a very good setup that I will now&lt;/span&gt;                                                                                                                                                                         &lt;br /&gt;&lt;span class="Constant"&gt;    document in the rest of this post.&lt;/span&gt;                                                                                                                                                                                                           &lt;br /&gt;                                                                                                                                                                                                                                                                               &lt;br /&gt;&lt;span class="Identifier"&gt;  Two way sync of two machines (master-master backup)&lt;/span&gt;                                                                                                                                                                                          &lt;br /&gt;                                                                                                                                                                                                                                                                               &lt;br /&gt;&lt;span class="Constant"&gt;    Unison will keep two machines in sync taking care of the --delete flag for&lt;/span&gt;                                                                                                                                                                   &lt;br /&gt;&lt;span class="Constant"&gt;    us and even has an option to keep several days of backups of any file it&lt;/span&gt;                                                                                                                                                                     &lt;br /&gt;&lt;span class="Constant"&gt;    deletes so you can check once a week if it deleted a file you did not want&lt;/span&gt;                                                                                                                                                                   &lt;br /&gt;&lt;span class="Constant"&gt;    deleted.&lt;/span&gt;                                                                                                                                                                                                                                     &lt;br /&gt;                                                                                                                                                                                                                                                                               &lt;br /&gt;&lt;span class="Constant"&gt;    To install unison in (K)Ubuntu we simply do:&lt;/span&gt;                                                                                                                                                                                                 &lt;br /&gt;                                                                                                                                                                                                                                                                               &lt;br /&gt;&lt;span class="Special"&gt;    ; sudo aptitude install unison&lt;/span&gt;                                                                                                                                                                                                                &lt;br /&gt;                                                                                                                                                                                                                                                                               &lt;br /&gt;&lt;span class="Constant"&gt;    Note that unison MUST be installed in the two machines you want to keep in&lt;/span&gt;                                                                                                                                                                   &lt;br /&gt;&lt;span class="Constant"&gt;    sync. As additional bonus this tool works in all major operating systems&lt;/span&gt;                                                                                                                                                                     &lt;br /&gt;&lt;span class="Constant"&gt;    so you can sync your work and home machines even if you use Windows at&lt;/span&gt;                                                                                                                                                                       &lt;br /&gt;&lt;span class="Constant"&gt;    work and Linux at home.&lt;/span&gt;                                                                                                                                                                                                                      &lt;br /&gt;                                                                                                                                                                                                                                                                               &lt;br /&gt;&lt;span class="Constant"&gt;    Now to sync some folders between machines you issue a simple command:&lt;/span&gt;                                                                                                                                                                        &lt;br /&gt;                                                                                                                                                                                                                                                                               &lt;br /&gt;&lt;span class="Special"&gt;    ; unison /home/user ssh://&amp;lt;ipaddress&amp;gt;//home/user      \&lt;/span&gt;                                                                                                                                                                                 &lt;br /&gt;&lt;span class="Special"&gt;    ; -path .vim -path .vimrc -path .muttrc -path .mutt   \&lt;/span&gt;                                                                                                                                                                                       &lt;br /&gt;&lt;span class="Special"&gt;    ; -path Music -path Photos -path Docs&lt;/span&gt;                                                                                                                                                                                                         &lt;br /&gt;                                                                                                                                                                                                                                                                               &lt;br /&gt;&lt;span class="Constant"&gt;    In the above example I sync my vim, mutt configuration files and my Music,&lt;/span&gt;                                                                                                                                                                   &lt;br /&gt;&lt;span class="Constant"&gt;    Photos and Docs folders in my home directory. Replace the ipaddress with&lt;/span&gt;                                                                                                                                                                     &lt;br /&gt;&lt;span class="Constant"&gt;    the address of the remote machine and note that the double slash (//)&lt;/span&gt;                                                                                                                                                                        &lt;br /&gt;&lt;span class="Constant"&gt;    after the ipaddress is not a typo, you MUST have two slashes there when&lt;/span&gt;                                                                                                                                                                      &lt;br /&gt;&lt;span class="Constant"&gt;    using absolute paths in the remote side.&lt;/span&gt;                                                                                                                                                                                                     &lt;br /&gt;                                                                                                                                                                                                                                                                               &lt;br /&gt;&lt;span class="Constant"&gt;    This command can be executed in any of the two machines and the result&lt;/span&gt;                                                                                                                                                                       &lt;br /&gt;&lt;span class="Constant"&gt;    will be the same. Both of them will have the directories selected (-path)&lt;/span&gt;                                                                                                                                                                    &lt;br /&gt;&lt;span class="Constant"&gt;    syncrhonized to the last detail.&lt;/span&gt;                                                                                                                                                                                                             &lt;br /&gt;                                                                                                                                                                                                                                                                               &lt;br /&gt;&lt;span class="Constant"&gt;    Since I use ssh as transport I also set up my machines to authenticate&lt;/span&gt;                                                                                                                                                                       &lt;br /&gt;&lt;span class="Constant"&gt;    using ssh keys and configure Kwallet [3] as my ssh passphrase manager.&lt;/span&gt;                                                                                                                                                                       &lt;br /&gt;&lt;span class="Constant"&gt;    This is very important if we want to automate the task via cron or incron&lt;/span&gt;                                                                                                                                                                    &lt;br /&gt;&lt;span class="Constant"&gt;    jobs as I show later in this post.&lt;/span&gt;                                                                                                                                                                                                           &lt;br /&gt;                                                                                                                                                                                                                                                                               &lt;br /&gt;&lt;span class="Constant"&gt;    To simplify the synchronization task I created a small bash script that&lt;/span&gt;                                                                                                                                                                      &lt;br /&gt;&lt;span class="Constant"&gt;    loads my ssh key manager (keychain), executes unison to synchronize my&lt;/span&gt;                                                                                                                                                                       &lt;br /&gt;&lt;span class="Constant"&gt;    machines while logging everything to /tmp/unison.log.&lt;/span&gt; &lt;br /&gt;&lt;span class="Underlined"&gt;    &amp;lt;SCRIPT&lt;/span&gt;                                                                                                                                                                                                                                 &lt;br /&gt;&lt;span class="Underlined"&gt;    &amp;lt; #!/usr/bin/env bash&lt;/span&gt;                                                                                                                                                                                                                   &lt;br /&gt;&lt;span class="Underlined"&gt;    &amp;lt; LOGGER=/usr/bin/logger&lt;/span&gt;                                                                                                                                                                                                                &lt;br /&gt;&lt;span class="Underlined"&gt;    &amp;lt; UNISON=/usr/bin/unison&lt;/span&gt;                                                                                                                                                                                                                &lt;br /&gt;&lt;span class="Underlined"&gt;    &amp;lt; KEYCHAIN=/usr/bin/keychain&lt;/span&gt;                                                                                                                                                                                                            &lt;br /&gt;&lt;span class="Underlined"&gt;    &amp;lt; $LOGGER -t unison -p cron.info &amp;quot;Unison started for user $HOME&amp;quot;&lt;/span&gt;                                                                                                                                                              &lt;br /&gt;&lt;span class="Underlined"&gt;    &amp;lt; if [ -e /tmp/unison.lock ]&lt;/span&gt;                                                                                                                                                                                                            &lt;br /&gt;&lt;span class="Underlined"&gt;    &amp;lt; then&lt;/span&gt;                                                                                                                                                                                                                                  &lt;br /&gt;&lt;span class="Underlined"&gt;    &amp;lt;   $LOGGER -t unison -p cron.info &amp;quot;Unison already running... abort&amp;quot;&lt;/span&gt;                                                                                                                                                          &lt;br /&gt;&lt;span class="Underlined"&gt;    &amp;lt; else&lt;/span&gt;                                                                                                                                                                                                                                  &lt;br /&gt;&lt;span class="Underlined"&gt;    &amp;lt;   echo &amp;quot;running&amp;quot; &amp;gt; /tmp/unison.lock&lt;/span&gt;                                                                                                                                                                                      &lt;br /&gt;&lt;span class="Underlined"&gt;    &amp;lt;   $KEYCHAIN id_rsa&lt;/span&gt;                                                                                                                                                                                                                    &lt;br /&gt;&lt;span class="Underlined"&gt;    &amp;lt;   source $HOME/.keychain/$HOSTNAME-sh&lt;/span&gt;                                                                                                                                                                                                 &lt;br /&gt;&lt;span class="Underlined"&gt;    &amp;lt;   $UNISON $HOME ssh://192.168.1.10/$HOME -batch -log -logfile /tmp/unison.log \&lt;/span&gt;                                                                                                                                                       &lt;br /&gt;&lt;span class="Underlined"&gt;    &amp;lt;                           -path .vim -path .vimrc -path .muttrc -path .mutt   \&lt;/span&gt;                                                                                                                                                       &lt;br /&gt;&lt;span class="Underlined"&gt;    &amp;lt;                           -path Music -path Photos -path Docs&lt;/span&gt;                                                                                                                                                                         &lt;br /&gt;&lt;span class="Underlined"&gt;    &amp;lt;   [ $? -eq 0 ] &amp;amp;&amp;amp; $LOGGER -t unison -p cron.info &amp;quot;Unison finished&amp;quot; || $LOGGER -t unison -p cron.info &amp;quot;Unison failed with error $?&amp;quot;&lt;/span&gt;                                                                        &lt;br /&gt;&lt;span class="Underlined"&gt;    &amp;lt;   rm -f /tmp/unison.lock&lt;/span&gt;                                                                                                                                                                                                              &lt;br /&gt;&lt;span class="Underlined"&gt;    &amp;lt; fi&lt;/span&gt;                                                                                                                                                                                                                                    &lt;br /&gt;                                                                                                                                                                                                                                                                               &lt;br /&gt;&lt;span class="Identifier"&gt;  Using incrontab for almost real time two way file sync&lt;/span&gt;                                                                                                                                                                                       &lt;br /&gt;                                                                                                                                                                                                                                                                               &lt;br /&gt;&lt;span class="Constant"&gt;    Now that I can sync my two machines with a simple script I wanted this to be&lt;/span&gt;                                                                                                                                                                 &lt;br /&gt;&lt;span class="Constant"&gt;    automated. The normal way would be using a cron job but a problem I always&lt;/span&gt;                                                                                                                                                                   &lt;br /&gt;&lt;span class="Constant"&gt;    had with cron was how to set the time period. Once an hour or a day or a&lt;/span&gt;                                                                                                                                                                     &lt;br /&gt;&lt;span class="Constant"&gt;    minute? While researching I found incrontab that is like cron but it reacts&lt;/span&gt;                                                                                                                                                                  &lt;br /&gt;&lt;span class="Constant"&gt;    to file system events. With it I could invoke my unison script every time a&lt;/span&gt;                                                                                                                                                                  &lt;br /&gt;&lt;span class="Constant"&gt;    file is created or edited that would result in almost real time sync between&lt;/span&gt;                                                                                                                                                                 &lt;br /&gt;&lt;span class="Constant"&gt;    my machines.&lt;/span&gt;                                                                                                                                                                                                                                 &lt;br /&gt;                                                                                                                                                                                                                                                                               &lt;br /&gt;&lt;span class="Constant"&gt;    To install incrontab in (K)Ubuntu simply do:&lt;/span&gt;                                                                                                                                                                                                 &lt;br /&gt;                                                                                                                                                                                                                                                                               &lt;br /&gt;&lt;span class="Special"&gt;    ; sudo aptitude install incron&lt;/span&gt;                                                                                                                                                                                                                &lt;br /&gt;&lt;span class="Special"&gt;    ; echo &amp;quot;username&amp;quot; &amp;gt;&amp;gt; /etc/incron.allow&lt;/span&gt;                                                                                                                                                                                        &lt;br /&gt;                                                                                                                                                                                                                                                                               &lt;br /&gt;&lt;span class="Constant"&gt;    The first command installs incron and the second one adds your user name&lt;/span&gt;                                                                                                                                                                     &lt;br /&gt;&lt;span class="Constant"&gt;    to the list of allowed incron users. If your username is not in the&lt;/span&gt;                                                                                                                                                                          &lt;br /&gt;&lt;span class="Constant"&gt;    &amp;quot;incron.allow&amp;quot; file then you wont be able to use incrontab.&lt;/span&gt;                                                                                                                                                                        &lt;br /&gt;                                                                                                                                                                                                                                                                               &lt;br /&gt;&lt;span class="Constant"&gt;    A common problem that happens when using rsync or unison from within cron&lt;/span&gt;                                                                                                                                                                    &lt;br /&gt;&lt;span class="Constant"&gt;    and incron is how to handle the authentication of the ssh session.&lt;/span&gt;                                                                                                                                                                           &lt;br /&gt;&lt;span class="Constant"&gt;    Remember that the cron and incron processes are running in a different&lt;/span&gt;                                                                                                                                                                       &lt;br /&gt;&lt;span class="Constant"&gt;    environment as your user so setting a key manager like ssh-agent or&lt;/span&gt;                                                                                                                                                                          &lt;br /&gt;&lt;span class="Constant"&gt;    keychain in the current user termial wont work. If you have ever had rsync&lt;/span&gt;                                                                                                                                                                   &lt;br /&gt;&lt;span class="Constant"&gt;    work perfectly from a terminal but fail with an error like: unexplained&lt;/span&gt;                                                                                                                                                                      &lt;br /&gt;&lt;span class="Constant"&gt;    error (code 255) then you know what I am talking about.&lt;/span&gt;                                                                                                                                                                                      &lt;br /&gt;                                                                                                                                                                                                                                                                               &lt;br /&gt;&lt;span class="Constant"&gt;    To solve this problem you first need to set your machines to use&lt;/span&gt;                                                                                                                                                                             &lt;br /&gt;&lt;span class="Constant"&gt;    password-less ssh key authentication. This way you can execute remote&lt;/span&gt;                                                                                                                                                                        &lt;br /&gt;&lt;span class="Constant"&gt;    commands via ssh without need to input a password.&lt;/span&gt;                                                                                                                                                                                           &lt;br /&gt;                                                                                                                                                                                                                                                                               &lt;br /&gt;&lt;span class="Constant"&gt;    Second you need to setup a keymanager like ssh-agent or keychain. I found&lt;/span&gt;                                                                                                                                                                    &lt;br /&gt;&lt;span class="Constant"&gt;    that keychain does a better job in keeping a single instance of itself to&lt;/span&gt;                                                                                                                                                                    &lt;br /&gt;&lt;span class="Constant"&gt;    handle the keys on multiple processes. So I setup keychain and configure&lt;/span&gt;                                                                                                                                                                     &lt;br /&gt;&lt;span class="Constant"&gt;    Kwallet [3] as the interface that asks and stores the ssh pashphrases.&lt;/span&gt;                                                                                                                                                                       &lt;br /&gt;&lt;span class="Constant"&gt;    With this setup Kwallet asks me to unlock it at KDE startup and from that&lt;/span&gt;                                                                                                                                                                    &lt;br /&gt;&lt;span class="Constant"&gt;    point on it takes care of providing authentication to all processes that&lt;/span&gt;                                                                                                                                                                     &lt;br /&gt;&lt;span class="Constant"&gt;    require ssh loging (incrontab included).&lt;/span&gt;                                                                                                                                                                                                     &lt;br /&gt;                                                                                                                                                                                                                                                                               &lt;br /&gt;&lt;span class="Constant"&gt;    Once you have setup the key manager you can create an incrontab rule to&lt;/span&gt;                                                                                                                                                                      &lt;br /&gt;&lt;span class="Constant"&gt;    invoke the unison script (from the previous section) every time a file is&lt;/span&gt;                                                                                                                                                                    &lt;br /&gt;&lt;span class="Constant"&gt;    changed:&lt;/span&gt;                                                                                                                                                                                                                                     &lt;br /&gt;                                                                                                                                                                                                                                                                               &lt;br /&gt;&lt;span class="Special"&gt;    ; incrontab -e&lt;/span&gt;                                                                                                                                                                                                                                &lt;br /&gt;                                                                                                                                                                                                                                                                               &lt;br /&gt;&lt;span class="Constant"&gt;    This command will open you text editor (vim) with your user's incrontab&lt;/span&gt;                                                                                                                                                                      &lt;br /&gt;&lt;span class="Constant"&gt;    configuration file. All you have to do is to input the following line and&lt;/span&gt;                                                                                                                                                                    &lt;br /&gt;&lt;span class="Constant"&gt;    save/close the editor:&lt;/span&gt;                                                                                                                                                                                                                       &lt;br /&gt;                                                                                                                                                                                                                                                                               &lt;br /&gt;&lt;span class="Special"&gt;    ; /home/user IN_ATTRIB,IN_DONT_FOLLOW,IN_NO_LOOP /home/user/unison.sh&lt;/span&gt;                                                                                                                                                                         &lt;br /&gt;                                                                                                                                                                                                                                                                               &lt;br /&gt;&lt;span class="Constant"&gt;    This incrontab rule invokes &amp;quot;unison.sh&amp;quot; every time an attribute changes in&lt;/span&gt;                                                                                                                                                         &lt;br /&gt;&lt;span class="Constant"&gt;    a file or folder inside my home directory. The IN_ATTRIB switch may be&lt;/span&gt;                                                                                                                                                                       &lt;br /&gt;&lt;span class="Constant"&gt;    overkill and you may prefer to use IN_CREATE or IN_CLOSE_WRITE. For&lt;/span&gt;                                                                                                                                                                          &lt;br /&gt;&lt;span class="Constant"&gt;    details on incrontab switches you may read the man page:&lt;/span&gt;                                                                                                                                                                                     &lt;br /&gt;                                                                                                                                                                                                                                                                               &lt;br /&gt;&lt;span class="Special"&gt;    ; man 5 incrontab&lt;/span&gt; &lt;br /&gt;&lt;br /&gt;&lt;span class="Constant"&gt;    This command will open you text editor (vim) with your user's incrontab&lt;/span&gt;                                                                                                                                                                      &lt;br /&gt;&lt;span class="Constant"&gt;    configuration file. All you have to do is to input the following line and&lt;/span&gt;                                                                                                                                                                    &lt;br /&gt;&lt;span class="Constant"&gt;    save/close the editor:&lt;/span&gt;                                                                                                                                                                                                                       &lt;br /&gt;                                                                                                                                                                                                                                                                               &lt;br /&gt;&lt;span class="Special"&gt;    ; /home/user IN_ATTRIB,IN_DONT_FOLLOW,IN_NO_LOOP /home/user/unison.sh&lt;/span&gt;                                                                                                                                                                         &lt;br /&gt;                                                                                                                                                                                                                                                                               &lt;br /&gt;&lt;span class="Constant"&gt;    This incrontab rule invokes &amp;quot;unison.sh&amp;quot; every time an attribute changes in&lt;/span&gt;                                                                                                                                                         &lt;br /&gt;&lt;span class="Constant"&gt;    a file or folder inside my home directory. The IN_ATTRIB switch may be&lt;/span&gt;                                                                                                                                                                       &lt;br /&gt;&lt;span class="Constant"&gt;    overkill and you may prefer to use IN_CREATE or IN_CLOSE_WRITE. For&lt;/span&gt;                                                                                                                                                                          &lt;br /&gt;&lt;span class="Constant"&gt;    details on incrontab switches you may read the man page:&lt;/span&gt;                                                                                                                                                                                     &lt;br /&gt;                                                                                                                                                                                                                                                                               &lt;br /&gt;&lt;span class="Special"&gt;    ; man 5 incrontab&lt;/span&gt;                                                                                                                                                                                                                             &lt;br /&gt;                                                                                                                                                                                                                                                                               &lt;br /&gt;&lt;span class="Constant"&gt;    The IN_NO_LOOP avoids the script from being invoked several times when&lt;/span&gt;                                                                                                                                                                       &lt;br /&gt;&lt;span class="Constant"&gt;    more than one file changes at a time. Also the script I provided uses a&lt;/span&gt;                                                                                                                                                                      &lt;br /&gt;&lt;span class="Constant"&gt;    simple lock mechanism to avoid it from running several times in parallel.&lt;/span&gt;                                                                                                                                                                    &lt;br /&gt;                                                                                                                                                                                                                                                                               &lt;br /&gt;&lt;span class="Constant"&gt;    As a final note you can open /var/log/syslog and search for all entries&lt;/span&gt;                                                                                                                                                                      &lt;br /&gt;&lt;span class="Constant"&gt;    with the unison tag to see if the script is running correctly or failing.&lt;/span&gt;                                                                                                                                                                    &lt;br /&gt;&lt;span class="Constant"&gt;    If it is failing you can further chech the /tmp/unison.log file to see why&lt;/span&gt;                                                                                                                                                                   &lt;br /&gt;&lt;span class="Constant"&gt;    it is failing. Note that an abort is not an error, it means that then&lt;/span&gt;                                                                                                                                                                        &lt;br /&gt;&lt;span class="Constant"&gt;    unison script was invoked several times in succession and we only allow&lt;/span&gt;                                                                                                                                                                      &lt;br /&gt;&lt;span class="Constant"&gt;    one instance at any given time. &lt;/span&gt;                                                                                                                                                                                                             &lt;br /&gt;                                                                                                                                                                                                                                                                               &lt;br /&gt;&lt;span class="Identifier"&gt;  Resources&lt;/span&gt;                                                                                                                                                                                                                                    &lt;br /&gt;                                                                                                                                                                                                                                                                               &lt;br /&gt;&lt;span class="Constant"&gt;    [1] &lt;a href="http://www.darcynorman.net/2006/10/03/be-careful-with-rsync-delete/"&gt;http://www.darcynorman.net/2006/10/03/be-careful-with-rsync-delete/&lt;/a&gt;&lt;/span&gt;                                                                                    &lt;br /&gt;&lt;span class="Constant"&gt;    [2] &lt;a href="http://www.davidgrant.ca/rsync_delete_dangerous"&gt;http://www.davidgrant.ca/rsync_delete_dangerous&lt;/a&gt;&lt;/span&gt;                                                                                                                            &lt;br /&gt;&lt;span class="Constant"&gt;    [3] &lt;a href="http://piao-tech.blogspot.com/2009/12/manage-ssh-and-gpg-keys-efficiently-in.html"&gt;http://piao-tech.blogspot.com/2009/12/manage-ssh-and-gpg-keys-efficiently-in.html&lt;/a&gt;&lt;/span&gt;                                                        &lt;br /&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/34829202-3262443831190196540?l=piao-tech.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://piao-tech.blogspot.com/feeds/3262443831190196540/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://piao-tech.blogspot.com/2009/12/synchronizing-two-machines.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/34829202/posts/default/3262443831190196540'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/34829202/posts/default/3262443831190196540'/><link rel='alternate' type='text/html' href='http://piao-tech.blogspot.com/2009/12/synchronizing-two-machines.html' title='Synchronizing two machines'/><author><name>龍神</name><uri>http://www.blogger.com/profile/16648963337079496096</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-34829202.post-4024172964918082761</id><published>2009-12-17T17:02:00.010+09:00</published><updated>2011-01-17T00:54:42.203+09:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Tips'/><category scheme='http://www.blogger.com/atom/ns#' term='OpenSSH'/><title type='text'>Manage SSH and GPG keys efficiently in KDE</title><content type='html'>&lt;div class="outline"&gt;&lt;pre&gt;&lt;span class="Statement"&gt;Manage SSH and GPG keys efficiently in KDE&lt;/span&gt;                                                                                                                                                                                                      &lt;br /&gt;                                                                                                                                                                                                                                                                               &lt;br /&gt;&lt;span class="Identifier"&gt;  Introduction&lt;/span&gt;                                                                                                                                                                                                                                 &lt;br /&gt;&lt;span class="Constant"&gt;    Here I present a simple way to handle SSH and GPG keys easily in KDE4.&lt;/span&gt;                                                                                                                                                                       &lt;br /&gt;&lt;span class="Constant"&gt;    These method presents several advantages:&lt;/span&gt;                                                                                                                                                                                                    &lt;br /&gt;                                                                                                                                                                                                                                                                               &lt;br /&gt;&lt;span class="PreProc"&gt;      * Works great with KDE4 that ships with Kubuntu Maverick Meerkat and may&lt;/span&gt;                                                                                                                                                                    &lt;br /&gt;&lt;span class="PreProc"&gt;        work in other KDE distributions without too much trouble.&lt;/span&gt;                                                                                                                                                                                 &lt;br /&gt;&lt;span class="PreProc"&gt;      * Use Kwallet as the passphrase manager so you unlock Kwallet once on&lt;/span&gt;                                                                                                                                                                       &lt;br /&gt;&lt;span class="PreProc"&gt;        login and from there it will handle all passphrase requests.&lt;/span&gt;                                                                                                                                                                              &lt;br /&gt;&lt;span class="PreProc"&gt;      * Works great with automated tasks (via cron or incron) that use SSH key&lt;/span&gt;                                                                                                                                                                    &lt;br /&gt;&lt;span class="PreProc"&gt;        authentication (e.g. famous rsync unexplained error 255).&lt;/span&gt;                                                                                                                                                                                 &lt;br /&gt;                                                                                                                                                                                                                                                                               &lt;br /&gt;&lt;span class="Identifier"&gt;  Pre-requisities&lt;/span&gt;                                                                                                                                                                                                                              &lt;br /&gt;                                                                                                                                                                                                                                                                               &lt;br /&gt;&lt;span class="Constant"&gt;    Considering that you are reading this post because you need a better way&lt;/span&gt;                                                                                                                                                                     &lt;br /&gt;&lt;span class="Constant"&gt;    to manage you ssh and gpg keys then it is safe to assume you have already&lt;/span&gt;                                                                                                                                                                    &lt;br /&gt;&lt;span class="Constant"&gt;    generated your ssh/gpg keys and that you know how to use them.&lt;/span&gt;                                                                                                                                                                               &lt;br /&gt;                                                                                                                                                                                                                                                                               &lt;br /&gt;&lt;span class="Identifier"&gt;  Disable KDE4 from starting ssh-agent and gpp-agent&lt;/span&gt;                                                                                                                                                                                           &lt;br /&gt;                                                                                                                                                                                                                                                                               &lt;br /&gt;&lt;span class="Constant"&gt;    Kubuntu 10.10 by default starts the ssh-agent and gpg-agent causing some&lt;/span&gt;                                                                                                                                                                     &lt;br /&gt;&lt;span class="Constant"&gt;    conflicts with this setup based on keychain. Using the default&lt;/span&gt;                                                                                                                                                                               &lt;br /&gt;&lt;span class="Constant"&gt;    configuration does not seem to use kwallet and certainly does not work&lt;/span&gt;                                                                                                                                                                       &lt;br /&gt;&lt;span class="Constant"&gt;    with kmail/mutt so I prefer to disable these and enable keychain instead.&lt;/span&gt;                                                                                                                                                                    &lt;br /&gt;                                                                                                                                                                                                                                                                               &lt;br /&gt;&lt;span class="Constant"&gt;    To disable the default ssh-agent edit the &amp;quot;/etc/X11/Xsession.options&amp;quot; file&lt;/span&gt;                                                                                                                                                         &lt;br /&gt;&lt;span class="Constant"&gt;    and comment out the line that says use-ssh-agent. &lt;/span&gt;                                                                                                                                                                                           &lt;br /&gt;&lt;span class="Constant"&gt;    &lt;/span&gt;                                                                                                                                                                                                                                             &lt;br /&gt;&lt;span class="Constant"&gt;    To disable the default gpg-agent edit the &amp;quot;~/.gnupg/gpg.conf&amp;quot; file and&lt;/span&gt;                                                                                                                                                             &lt;br /&gt;&lt;span class="Constant"&gt;    comment out the line that says use-agent.&lt;/span&gt;                                                                                                                                                                                                    &lt;br /&gt;                                                                                                                                                                                                                                                                               &lt;br /&gt;&lt;span class="Constant"&gt;    With these default agent's disabled now we can configure KDE to use&lt;/span&gt;                                                                                                                                                                          &lt;br /&gt;&lt;span class="Constant"&gt;    keychain that I consider a superior tool to handle ssh/gpg keys.&lt;/span&gt;                                                                                                                                                                             &lt;br /&gt;                                                                                                                                                                                                                                                                               &lt;br /&gt;&lt;span class="Identifier"&gt;  SSH/GPG Key management with KWallet&lt;/span&gt;                                                                                                                                                                                                          &lt;br /&gt;                                                                                                                                                                                                                                                                               &lt;br /&gt;&lt;span class="Constant"&gt;    First we install the needed software packages:&lt;/span&gt;                                                                                                                                                                                               &lt;br /&gt;                                                                                                                                                                                                                                                                               &lt;br /&gt;&lt;span class="Special"&gt;    ; sudo aptitude install keychain ksshaskpass kwalletcli&lt;/span&gt;                                                                                                                                                                                       &lt;br /&gt;                                                                                                                                                                                                                                                                               &lt;br /&gt;&lt;span class="Constant"&gt;    configure the &amp;quot;~/.gnupg/gpg-agent.conf&amp;quot; file so it uses the kwallet&lt;/span&gt;                                                                                                                                                                &lt;br /&gt;&lt;span class="Constant"&gt;    pinentry program to manage gpg keys. Simply add the pinentry-program line&lt;/span&gt;                                                                                                                                                                    &lt;br /&gt;&lt;span class="Constant"&gt;    or replace it if it already exists with:&lt;/span&gt;                                                                                                                                                                                                     &lt;br /&gt;                                                                                                                                                                                                                                                                               &lt;br /&gt;&lt;span class="Special"&gt;    ; pinentry-program /usr/bin/pinentry-kwallet&lt;/span&gt;                                                                                                                                                                                                  &lt;br /&gt;                                                                                                                                                                                                                                                                               &lt;br /&gt;&lt;span class="Constant"&gt;    Now we need to load keychain and all the environment variables it sets&lt;/span&gt;                                                                                                                                                                       &lt;br /&gt;&lt;span class="Constant"&gt;    when KDE starts. To do this we simply create a small script, say&lt;/span&gt;                                                                                                                                                                             &lt;br /&gt;&lt;span class="Constant"&gt;    &amp;quot;keychain.sh&amp;quot; and put it inside out &amp;quot;.kde/env&amp;quot; directory. The script&lt;/span&gt;                                                                                                                                                     &lt;br /&gt;&lt;span class="Constant"&gt;    contains these lines:&lt;/span&gt;                                                                                                                                                                                                                        &lt;br /&gt;                                                                                                                                                                                                                                                                               &lt;br /&gt;&lt;span class="Underlined"&gt;    &amp;lt;SCRIPT&lt;/span&gt;                                                                                                                                                                                                                                 &lt;br /&gt;&lt;span class="Underlined"&gt;    &amp;lt; #!/bin/sh&lt;/span&gt;                                                                                                                                                                                                                             &lt;br /&gt;&lt;span class="Underlined"&gt;    &amp;lt; ################################################################################&lt;/span&gt;                                                                                                                                                      &lt;br /&gt;&lt;span class="Underlined"&gt;    &amp;lt; # Load keychain to handle ssh and gpg keys&lt;/span&gt;                                                                                                                                                                                            &lt;br /&gt;&lt;span class="Underlined"&gt;    &amp;lt; ################################################################################&lt;/span&gt;                                                                                                                                                      &lt;br /&gt;&lt;span class="Underlined"&gt;    &amp;lt; if [ -f /usr/bin/keychain ]; then&lt;/span&gt;                                                                                                                                                                                                     &lt;br /&gt;&lt;span class="Underlined"&gt;    &amp;lt;   if [ -f /usr/bin/ksshaskpass ]; then&lt;/span&gt;                                                                                                                                                                                                &lt;br /&gt;&lt;span class="Underlined"&gt;    &amp;lt;     export SSH_ASKPASS=/usr/bin/ksshaskpass&lt;/span&gt;                                                                                                                                                                                           &lt;br /&gt;&lt;span class="Underlined"&gt;    &amp;lt;   else&lt;/span&gt;                                                                                                                                                                                                                                &lt;br /&gt;&lt;span class="Underlined"&gt;    &amp;lt;     export SSH_ASKPASS=/usr/bin/askpass&lt;/span&gt;                                                                                                                                                                                               &lt;br /&gt;&lt;span class="Underlined"&gt;    &amp;lt;   fi&lt;/span&gt;                                                                                                                                                                                                                                  &lt;br /&gt;&lt;span class="Underlined"&gt;    &amp;lt;   /usr/bin/keychain&lt;/span&gt;                                                                                                                                                                                                                   &lt;br /&gt;&lt;span class="Underlined"&gt;    &amp;lt;   $HOME/.keychain/`hostname`-sh&lt;/span&gt;                                                                                                                                                                                                       &lt;br /&gt;&lt;span class="Underlined"&gt;    &amp;lt;   $HOME/.keychain/`hostname`-sh-gpg&lt;/span&gt;                                                                                                                                                                                                   &lt;br /&gt;&lt;span class="Underlined"&gt;    &amp;lt; fi&lt;/span&gt;                                                                                                                                                                                                                                    &lt;br /&gt;                                                                                                                                                                                                                                                                               &lt;br /&gt;&lt;span class="Constant"&gt;    what this does is to setup the SSH_ASKPASS environment variable to use the&lt;/span&gt;                                                                                                                                                                   &lt;br /&gt;&lt;span class="Constant"&gt;    ksshaskpass program that handles ssh keys inside KWallet. Then invokes&lt;/span&gt;                                                                                                                                                                       &lt;br /&gt;&lt;span class="Constant"&gt;    keychain which starts the ssh-agent and gpg-agent daemons and sets some&lt;/span&gt;                                                                                                                                                                      &lt;br /&gt;&lt;span class="Constant"&gt;    environment variables so all KDE applications can see them.&lt;/span&gt;                                                                                                                                                                                  &lt;br /&gt;                                                                                                                                                                                                                                                                               &lt;br /&gt;&lt;span class="Constant"&gt;    Finally we must load our ssh/gpg keys into keychain. The best place to do&lt;/span&gt;                                                                                                                                                                    &lt;br /&gt;&lt;span class="Constant"&gt;    this is with the KDE Autostart scripts. Simply create a script, say&lt;/span&gt;                                                                                                                                                                          &lt;br /&gt;&lt;span class="Constant"&gt;    add_keys.sh, into you &amp;quot;.kde/Autostart&amp;quot; folder that contains something&lt;/span&gt;                                                                                                                                                              &lt;br /&gt;&lt;span class="Constant"&gt;    like:&lt;/span&gt; &lt;br /&gt;                                                                                                                                                                                                                                                                               &lt;br /&gt;&lt;span class="Underlined"&gt;    &amp;lt;SCRIPT&lt;/span&gt;                                                                                                                                                                                                                                 &lt;br /&gt;&lt;span class="Underlined"&gt;    &amp;lt; #!/bin/sh&lt;/span&gt;                                                                                                                                                                                                                             &lt;br /&gt;&lt;span class="Underlined"&gt;    &amp;lt; ################################################################################&lt;/span&gt;                                                                                                                                                      &lt;br /&gt;&lt;span class="Underlined"&gt;    &amp;lt; # Load keychain to handle ssh and gpg keys&lt;/span&gt;                                                                                                                                                                                            &lt;br /&gt;&lt;span class="Underlined"&gt;    &amp;lt; ################################################################################&lt;/span&gt;                                                                                                                                                      &lt;br /&gt;&lt;span class="Underlined"&gt;    &amp;lt; if [ -f /usr/bin/keychain ]; then&lt;/span&gt;                                                                                                                                                                                                     &lt;br /&gt;&lt;span class="Underlined"&gt;    &amp;lt;   if [ -f /usr/bin/ksshaskpass ]; then&lt;/span&gt;                                                                                                                                                                                                &lt;br /&gt;&lt;span class="Underlined"&gt;    &amp;lt;     export SSH_ASKPASS=/usr/bin/ksshaskpass&lt;/span&gt;                                                                                                                                                                                           &lt;br /&gt;&lt;span class="Underlined"&gt;    &amp;lt;   else&lt;/span&gt;                                                                                                                                                                                                                                &lt;br /&gt;&lt;span class="Underlined"&gt;    &amp;lt;     export SSH_ASKPASS=/usr/bin/askpass&lt;/span&gt;                                                                                                                                                                                               &lt;br /&gt;&lt;span class="Underlined"&gt;    &amp;lt;   fi&lt;/span&gt;                                                                                                                                                                                                                                  &lt;br /&gt;&lt;span class="Underlined"&gt;    &amp;lt;   /usr/bin/keychain&lt;/span&gt;                                                                                                                                                                                                                   &lt;br /&gt;&lt;span class="Underlined"&gt;    &amp;lt;   $HOME/.keychain/`hostname`-sh&lt;/span&gt;                                                                                                                                                                                                       &lt;br /&gt;&lt;span class="Underlined"&gt;    &amp;lt;   $HOME/.keychain/`hostname`-sh-gpg&lt;/span&gt;                                                                                                                                                                                                   &lt;br /&gt;&lt;span class="Underlined"&gt;    &amp;lt; fi&lt;/span&gt;                                                                                                                                                                                                                                    &lt;br /&gt;                                                                                                                                                                                                                                                                               &lt;br /&gt;&lt;span class="Constant"&gt;    what this does is to setup the SSH_ASKPASS environment variable to use the&lt;/span&gt;                                                                                                                                                                   &lt;br /&gt;&lt;span class="Constant"&gt;    ksshaskpass program that handles ssh keys inside KWallet. Then invokes&lt;/span&gt;                                                                                                                                                                       &lt;br /&gt;&lt;span class="Constant"&gt;    keychain which starts the ssh-agent and gpg-agent daemons and sets some&lt;/span&gt;                                                                                                                                                                      &lt;br /&gt;&lt;span class="Constant"&gt;    environment variables so all KDE applications can see them.&lt;/span&gt;                                                                                                                                                                                  &lt;br /&gt;                                                                                                                                                                                                                                                                               &lt;br /&gt;&lt;span class="Constant"&gt;    Finally we must load our ssh/gpg keys into keychain. The best place to do&lt;/span&gt;                                                                                                                                                                    &lt;br /&gt;&lt;span class="Constant"&gt;    this is with the KDE Autostart scripts. Simply create a script, say&lt;/span&gt;                                                                                                                                                                          &lt;br /&gt;&lt;span class="Constant"&gt;    add_keys.sh, into you &amp;quot;.kde/Autostart&amp;quot; folder that contains something&lt;/span&gt;                                                                                                                                                              &lt;br /&gt;&lt;span class="Constant"&gt;    like:&lt;/span&gt;                                                                                                                                                                                                                                        &lt;br /&gt;                                                                                                                                                                                                                                                                               &lt;br /&gt;&lt;span class="Underlined"&gt;    &amp;lt;SCRIPT&lt;/span&gt;                                                                                                                                                                                                                                 &lt;br /&gt;&lt;span class="Underlined"&gt;    &amp;lt; #!/bin/sh&lt;/span&gt;                                                                                                                                                                                                                             &lt;br /&gt;&lt;span class="Underlined"&gt;    &amp;lt; ################################################################################&lt;/span&gt;                                                                                                                                                      &lt;br /&gt;&lt;span class="Underlined"&gt;    &amp;lt; # Load keychain to handle ssh and gpg keys&lt;/span&gt;                                                                                                                                                                                            &lt;br /&gt;&lt;span class="Underlined"&gt;    &amp;lt; ################################################################################&lt;/span&gt;                                                                                                                                                      &lt;br /&gt;&lt;span class="Underlined"&gt;    &amp;lt; if [ -f /usr/bin/keychain ]; then&lt;/span&gt;                                                                                                                                                                                                     &lt;br /&gt;&lt;span class="Underlined"&gt;    &amp;lt;  /usr/bin/keychain id_rsa 0x12345 0x23456&lt;/span&gt;                                                                                                                                                                                             &lt;br /&gt;&lt;span class="Underlined"&gt;    &amp;lt;  $HOME/.keychain/`hostname`-sh&lt;/span&gt;                                                                                                                                                                                                        &lt;br /&gt;&lt;span class="Underlined"&gt;    &amp;lt;  $HOME/.keychain/`hostname`-sh-gpg&lt;/span&gt;                                                                                                                                                                                                    &lt;br /&gt;&lt;span class="Underlined"&gt;    &amp;lt; fi&lt;/span&gt;                                                                                                                                                                                                                                    &lt;br /&gt;                                                                                                                                                                                                                                                                               &lt;br /&gt;&lt;span class="Constant"&gt;    what this Autostart script does is to load your ssh key (id_rsa) and gpg&lt;/span&gt;                                                                                                                                                                     &lt;br /&gt;&lt;span class="Constant"&gt;    keys (0x12345, 0x23456) into keychain. The next time you log into a KDE&lt;/span&gt;                                                                                                                                                                      &lt;br /&gt;&lt;span class="Constant"&gt;    session this script will ask you if you want to give keychain access to&lt;/span&gt;                                                                                                                                                                      &lt;br /&gt;&lt;span class="Constant"&gt;    Kwallet and then ask all the registered key passphrases. Once registered&lt;/span&gt;                                                                                                                                                                     &lt;br /&gt;&lt;span class="Constant"&gt;    with kwallet all your applications will be able to use these keys without&lt;/span&gt;                                                                                                                                                                    &lt;br /&gt;&lt;span class="Constant"&gt;    asking you for the passphrase each time.&lt;/span&gt;                                                                                                                                                                                                     &lt;br /&gt;                                                                                                                                                                                                                                                                               &lt;br /&gt;&lt;span class="Constant"&gt;    Make sure the env and Autostart scripts have exec privileges:&lt;/span&gt;                                                                                                                                                                                &lt;br /&gt;                                                                                                                                                                                                                                                                               &lt;br /&gt;&lt;span class="Special"&gt;    ; chmod +x ~/.kde/env/keychain.sh&lt;/span&gt;                                                                                                                                                                                                             &lt;br /&gt;&lt;span class="Special"&gt;    ; chmod +x ~/.kde/Autostart/add_key.sh&lt;/span&gt;                                                                                                                                                                                                        &lt;br /&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/34829202-4024172964918082761?l=piao-tech.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://piao-tech.blogspot.com/feeds/4024172964918082761/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://piao-tech.blogspot.com/2009/12/manage-ssh-and-gpg-keys-efficiently-in.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/34829202/posts/default/4024172964918082761'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/34829202/posts/default/4024172964918082761'/><link rel='alternate' type='text/html' href='http://piao-tech.blogspot.com/2009/12/manage-ssh-and-gpg-keys-efficiently-in.html' title='Manage SSH and GPG keys efficiently in KDE'/><author><name>龍神</name><uri>http://www.blogger.com/profile/16648963337079496096</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-34829202.post-3407109061338862233</id><published>2009-10-08T16:51:00.006+09:00</published><updated>2009-10-08T17:43:18.665+09:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Tips'/><category scheme='http://www.blogger.com/atom/ns#' term='Netem'/><title type='text'>How to create Netem distribution tables</title><content type='html'>The &lt;a href="http://www.linuxfoundation.org/en/Net:Netem"&gt;Netem&lt;/a&gt; and &lt;a href="http://info.iet.unipi.it/~luigi/ip_dummynet/"&gt;Dummynet&lt;/a&gt; emulators are widely used in networking research to achieve emulated network environments that can be used to evaluate new protocols and applications under controlled and repeateable conditions. In the case of Netem it is possible to use custom ditribution tables to better approximate the round-trip-time variations in the nework.&lt;br /&gt;&lt;br /&gt;Unfortunately there is little information on how to generate this distribution tables based on real measured data. The only reference available is in the iproute2 source code itself and is a little confusing. After some reading and re-reading I think I finally got the magic formula and here I present it so others can benefit of my work.&lt;br /&gt;&lt;br /&gt;First download the iproute2 source code:&lt;br /&gt;&lt;br /&gt;&lt;div class="code"&gt;&lt;br /&gt;git clone \&lt;br /&gt;git://git.kernel.org/pub/scm/linux/kernel/git/shemminger/iproute2.git&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;Then enter the netem subdirectory and compile the maketable and stats utilities:&lt;br /&gt;&lt;br /&gt;&lt;div clas="code"&gt;&lt;br /&gt;cd iproute2/netem&lt;br /&gt;gcc -lm -o maketable maketable.c&lt;br /&gt;gcc -lm -o stats stats.c&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;Next you need to extract some delay statistics of the channel you want to emulate. Suppose you want to emulate the network between a server in Japan and a client PC in Chile. Then simply run a ping between both machines for some period of time. A whole day of ping data would be enough:&lt;br /&gt;&lt;br /&gt;&lt;div class="code"&gt;&lt;br /&gt;ping 192.168.4.111 &gt; mydata.txt&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;The command above does a ping to the address 192.168.4.111 and stores the output to a file named mydata.txt. The file will contain the round-trip-times between the local machine and the machine with address 192.168.4.111 like shown below:&lt;br /&gt;&lt;br /&gt;&lt;div class="code"&gt;&lt;br /&gt;PING 192.168.4.111 (192.168.4.111) 56(84) bytes of data.&lt;br /&gt;64 bytes from 192.168.4.111: icmp_seq=1 ttl=43 time=306 ms&lt;br /&gt;64 bytes from 192.168.4.111: icmp_seq=2 ttl=43 time=273 ms&lt;br /&gt;64 bytes from 192.168.4.111: icmp_seq=3 ttl=43 time=310 ms&lt;br /&gt;64 bytes from 192.168.4.111: icmp_seq=4 ttl=43 time=300 ms&lt;br /&gt;64 bytes from 192.168.4.111: icmp_seq=5 ttl=43 time=300 ms&lt;br /&gt;64 bytes from 192.168.4.111: icmp_seq=6 ttl=43 time=304 ms&lt;br /&gt;...&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;The more data you have the better so leave the ping running for some long period of time. Next we need to extract the round-trip-time data only:&lt;br /&gt;&lt;br /&gt;&lt;div class="code"&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;cat mydata.txt | grep icmp_seq | cut -d'=' -f4 | cut -d' ' -f1 &gt; myrtt.txt&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;The above command will extract all the round-trip-times from mydata.txt and put them in a single column in a file named myrtt.txt. Finally we can create a distribution table that Netem understands using the maketable utility:&lt;br /&gt;&lt;br /&gt;&lt;div class="code"&gt;&lt;br /&gt;./maketable myrtt.txt &gt; mydist.dist&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;This will create a distribution table and store it in the file mydist.dist that must be copied in a special folder (/usr/lib/tc) so Netem can find it:&lt;br /&gt;&lt;br /&gt;&lt;div class="code"&gt;&lt;br /&gt;sudo cp mydist.dist /usr/lib/tc&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;Additionally we can obtain the mean and standard deviation of the round-trip-time using the stats utility:&lt;br /&gt;&lt;br /&gt;&lt;div class="code"&gt;&lt;br /&gt;./stats myrtt.txt&lt;br /&gt;&gt; mu =      296.636364&lt;br /&gt;&gt; sigma =    12.808378&lt;br /&gt;&gt; rho =      -0.103472&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;This command gives use the mean (mu) the deviation (sigma) and the correlation (rho) of the round-trip-time. And at last we can now use Netem to emulate the channel's round-trip-time using the following command:&lt;br /&gt;&lt;br /&gt;&lt;div class="code"&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;sudo tc  qdisc add dev eth0 root netem delay 296.636364ms 12.808378ms distribution mydist&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;Note the the distribution name is the same as that of the file we copied inside the /usr/lib/tc folder but without the .dist extension. Now Netem will provide you with a channel that has similar round-trip-time characteristics as those of the real channel.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/34829202-3407109061338862233?l=piao-tech.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://piao-tech.blogspot.com/feeds/3407109061338862233/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://piao-tech.blogspot.com/2009/10/how-to-create-netem-distribution-tables.html#comment-form' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/34829202/posts/default/3407109061338862233'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/34829202/posts/default/3407109061338862233'/><link rel='alternate' type='text/html' href='http://piao-tech.blogspot.com/2009/10/how-to-create-netem-distribution-tables.html' title='How to create Netem distribution tables'/><author><name>龍神</name><uri>http://www.blogger.com/profile/16648963337079496096</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-34829202.post-9128808992734066300</id><published>2009-09-03T11:51:00.010+09:00</published><updated>2011-11-27T19:07:09.612+09:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Tips'/><category scheme='http://www.blogger.com/atom/ns#' term='Gadget'/><category scheme='http://www.blogger.com/atom/ns#' term='Android'/><title type='text'>Embbed cover art in MP3 files with command line</title><content type='html'>&lt;h2&gt;Introduction&lt;/h2&gt;I needed a command line (cli) application that would allow me to embed cover art to my MP3 collection in order to get the covers diplay correctly in my wife's iPhone and my own gPhone (HTC-Hero). After looking around I finally found the ideal tool: eyed3.&lt;br /&gt;&lt;br /&gt;&lt;h2&gt;Embedding cover art in MP3 files&lt;/h2&gt;In Ubuntu/Kubuntu install ImageMagick and Eyed3 with the following command:&lt;br /&gt;&lt;script type="syntaxhighlighter" class="brush:bash"&gt;&lt;![CDATA[sudo aptitude install imagemagick eyed3]]&gt;&lt;/script&gt;&lt;br /&gt;then you can use these tools to embed the image in the MP3 files:&lt;br /&gt;&lt;script type="syntaxhighlighter" class="brush:bash"&gt;&lt;![CDATA[convert AlbumArt.jpg -resize 300x300\&amp;gt; AlbumArt.jpgeyeD3 --add-image AlbumArt.jpg:FRONT_COVER *.mp3]]&gt;&lt;/script&gt;&lt;br /&gt;The first command uses ImageMagick to resize the image if any dimension is larger than 300px and the second command adds the cover art to all the MP3 files present in the current directory.&lt;br /&gt;&lt;br /&gt;Note that the cover image is called AlbumArt.jpg and that the resize operation overwrites it. If you prefer to keep the original change the name of the output to something else. Also you can embed more than one image to each MP3 and assign it different types like FRONT_COVER, BACK_COVER, MEDIA, etc. Check eyeD3 help for more information.&lt;br /&gt;&lt;br /&gt;The embedded cover art will display correctly in iTunes, iPhone and Android without problems.&lt;br /&gt;&lt;br /&gt;&lt;h2&gt;Android cover art for Ogg/Vorbis and MP3 files&lt;/h2&gt;&lt;br /&gt;All my Japanese music is in Ogg/Vorbis format mostly because MP3 players cannot agree in the metadata encoding for Japanese characters. Each MP3 player I have tried (including Amarok) use a custom (i.e. no standard) way to save non ASCII characters making it impossible to display Japanese correctly in all devices/players I own.&lt;br /&gt;&lt;br /&gt;In the other hand Ogg/Vorbis displays the Japanese correctly in all players I use (Amarok/gPhone/ffmpeg/mplayer) but it does not support embedded cover art. Fortunately in Android phones if there is a file named AlbumArt.jpg the same folder the Ogg/Vorbis file is located then it will use that file as cover art.&lt;br /&gt;&lt;script type="syntaxhighlighter" class="brush:plain"&gt;&lt;![CDATA[ |--Aerosmith                                                                                                                                                                                                                                 |    |-- Armageddon                                                                                                                                                                                                                            |            |-- AlbumArt.jpg                                                                                                                                                                                                                  |            |-- I Dont Want To Miss A Thing.ogg                                                                                                                                                                                               |--Shakira                                                                                                                                                                 |-- Laundry Service                                                                                                                                                                                                              |--AlbumArt.jpg                                                                                                                                                                                                                              |--Eyes Like Yours.ogg                                                                                                                                                                                                        ]]&gt;&lt;/script&gt;&lt;br /&gt;With this layout both Amarok and my Android Phone display the AlbumArt.jpg for all the ogg/mp3 files contained inside the same folder.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/34829202-9128808992734066300?l=piao-tech.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://piao-tech.blogspot.com/feeds/9128808992734066300/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://piao-tech.blogspot.com/2009/09/embbed-cover-art-in-mp3-files-with.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/34829202/posts/default/9128808992734066300'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/34829202/posts/default/9128808992734066300'/><link rel='alternate' type='text/html' href='http://piao-tech.blogspot.com/2009/09/embbed-cover-art-in-mp3-files-with.html' title='Embbed cover art in MP3 files with command line'/><author><name>龍神</name><uri>http://www.blogger.com/profile/16648963337079496096</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-34829202.post-9170664006837978516</id><published>2009-06-12T13:27:00.003+09:00</published><updated>2009-06-12T15:25:51.041+09:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Vim'/><category scheme='http://www.blogger.com/atom/ns#' term='Tips'/><title type='text'>Handling multiple encodings in Vim</title><content type='html'>Most people edit, load and save files in a single character encoding (i.e. en_US.UTF-8) but for many this is not the case. For me I need to write documents and emails in japanese UTF-8 (ja_JP.UTF-8), Latex in EUC-JP (ja_JP.EUC-JP) and source code comments in Shift-JIS (ja_JP.SJIS). &lt;br /&gt;&lt;br /&gt;To handle a certain character encoding there are three things you must consider:&lt;br /&gt;&lt;ul&gt;&lt;br /&gt;&lt;li&gt;Your editor character encoding&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Your terminal character encoding&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Your font character encoding support&lt;/li&gt;&lt;br /&gt;&lt;/ul&gt;&lt;br /&gt;&lt;br /&gt;In the prehistoric era editors and terminal could support a single character encoding so you needed a different pair for each encoding you needed. Believe me when I tell you this was not fun at all.&lt;br /&gt;&lt;br /&gt;These days most editors and terminals support a large array of character encodings and a lot of free fonts are available that support all the character sets I need. Still it is necessary to reconfigure each part (editor/terminal) or create different profiles for each character encoding you needed to edit (i.e. &lt;a href="http://www.running-dog.net/2008/08/kde4_konqueror_konsole.html"&gt;link&lt;/a&gt;) for the editor and the console.&lt;br /&gt;&lt;br /&gt;Today I took the time to understand how vim character encoding support works and I found that it has everything I need and a lot more. By carefully manipulating the the fenc, fencs, enc and tenc configuration parameters I can edit any file in any character encoding with little effort. Here are my .vimrc configuration parameters:&lt;br /&gt;&lt;div class="code"&gt;&lt;br /&gt;&lt;font face="monospace"&gt;&lt;br /&gt;&lt;font color="#87af87"&gt;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#87af87"&gt;&amp;quot;&amp;quot; Character encoding settings&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#87af87"&gt;&amp;quot;&amp;quot; By manipulating this variables it is possible to edit all files in one &lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#87af87"&gt;&amp;quot;&amp;quot; encoding while using the terminal in a different encoding and writing/reading&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#87af87"&gt;&amp;quot;&amp;quot; the file in another encoding. Here we set all three variables to UTF-8.&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#87af87"&gt;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#87af87"&gt;&amp;quot; Default file encoding for new files&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;span style="background-color: #3a3a3a"&gt;&lt;font color="#d7d7af"&gt;setglobal&lt;/font&gt;&lt;/span&gt;&amp;nbsp;&lt;font color="#ffd7af"&gt;&lt;b&gt;fenc&lt;/b&gt;&lt;/font&gt;=utf-8&lt;br&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#87af87"&gt;&amp;quot; Auto detect file encoding when opening a file. To check what file encoding was&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#87af87"&gt;&amp;quot; selected run &lt;/font&gt;&lt;font color="#d78787"&gt;&amp;quot;:set fenc&amp;quot;&lt;/font&gt;&lt;font color="#87af87"&gt;&amp;nbsp;and if you know the auto detection failed and want to&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#87af87"&gt;&amp;quot; force another one run &lt;/font&gt;&lt;font color="#d78787"&gt;&amp;quot;:edit ++enc=&amp;lt;your_enc&amp;gt;&amp;quot;&lt;/font&gt;&lt;font color="#87af87"&gt;.&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;span style="background-color: #3a3a3a"&gt;&lt;font color="#d7d7af"&gt;set&lt;/font&gt;&lt;/span&gt;&amp;nbsp;&lt;font color="#ffd7af"&gt;&lt;b&gt;fencs&lt;/b&gt;&lt;/font&gt;=utf-8&lt;span style="background-color: #3a3a3a"&gt;&lt;font color="#d7d7af"&gt;,&lt;/font&gt;&lt;/span&gt;euc-jp&lt;span style="background-color: #3a3a3a"&gt;&lt;font color="#d7d7af"&gt;,&lt;/font&gt;&lt;/span&gt;sjis&lt;br&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#87af87"&gt;&amp;quot; Internal encoding used by vim buffers, help and commands&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;span style="background-color: #3a3a3a"&gt;&lt;font color="#d7d7af"&gt;set&lt;/font&gt;&lt;/span&gt;&amp;nbsp;&lt;font color="#ffd7af"&gt;&lt;b&gt;enc&lt;/b&gt;&lt;/font&gt;=utf-8&lt;br&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#87af87"&gt;&amp;quot; Terminal encoding used for input and terminal display&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#87af87"&gt;&amp;quot; Make sure your terminal is configured with the same encoding.&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;span style="background-color: #3a3a3a"&gt;&lt;font color="#d7d7af"&gt;set&lt;/font&gt;&lt;/span&gt;&amp;nbsp;&lt;font color="#ffd7af"&gt;&lt;b&gt;tenc&lt;/b&gt;&lt;/font&gt;=utf-8&lt;br&gt;&lt;br /&gt;&lt;/font&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;br /&gt;&lt;li&gt;&lt;h3&gt;tenc:&lt;/h3&gt; This is the character encoding used to display and input text to the terminal. I configure my terminal (Konsole) always in UTF-8 and as far as I know my input method for Japanese (scim/anthy) is also UTF-8 so to avoid visual/input problems I leave this in UTF-8.&lt;br /&gt;&lt;br /&gt;&lt;li&gt;&lt;h3&gt;enc:&lt;/h3&gt; The encoding used internally by vim buffers, help and commands. This does not need to be the same as &lt;span style="font-weight:bold;"&gt;tenc&lt;/span&gt; as vim will convert from one encoding to the other if they differ. This way you can use your native language encoding in your terminal and input method and let vim handle everything internally using UTF-8.&lt;/li&gt;&lt;br /&gt;&lt;br /&gt;&lt;li&gt;&lt;h3&gt;fenc:&lt;/h3&gt; Is the character encoding used for reading/writing files. Again this can differ from &lt;span style="font-weight:bold;"&gt;enc&lt;/span&gt; and &lt;span style="font-weight:bold;"&gt;tenc&lt;/span&gt; because vim will convert between them if they differ. This way you can have your terminal configured with your native language (i.e. Japanese, Russian, Chinese...), let vim work internally in UTF-8 and finally save your files in any coding you want by setting fenc.&lt;/li&gt;&lt;br /&gt;&lt;br /&gt;&lt;li&gt;&lt;h3&gt;fencs:&lt;/h3&gt; This is used by vim to try to auto detect the character encoding when opening an already existing file. The order in which you put the options is important so read the help &lt;span style="font-weight:bold;"&gt;":h fencs"&lt;/span&gt; to learn how to set this correctly. For example if I put euc-jp first in the list all my English documents will be detected as euc-jp instead of utf-8 because all English characters are a subset of euc-jp, the same goes for latin1 and cp1250 encodings so make sure to put these at the end of the list. If the auto detection fails and your document is not displayed correctly you can always reload it forcing an encoding using &lt;span style="font-weight:bold;"&gt;":edit ++enc=euc-jp"&lt;/span&gt; of course replace euc-jp with your desired encoding.&lt;br /&gt;&lt;/ul&gt;&lt;br /&gt;&lt;br /&gt;In my example above I set everything to UTF-8 that is recommended because converting from other encodings may cause loss of information. The only parameter I change is &lt;span style="font-weight:bold;"&gt;fenc&lt;/span&gt; when I need edit/save a file in a different encoding.&lt;br /&gt;&lt;br /&gt;For example if I want to create a new file in euc-jp encoding:&lt;br /&gt;&lt;div class="code"&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;  - Open new file as normal using vim&lt; &lt;filename&gt;&lt;br /&gt;  - Set file encoding using :set fenc=euc-jp&lt;br /&gt;  - Edit/Save as much as you like and rest assured that your file is euc-jp.&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;To edit an existing file simply open it and let vim auto detect the encoding using the options available in &lt;span style="font-weight:bold;"&gt;fencs&lt;/span&gt;. To check what encoding was set by vim you can use the command &lt;span style="font-weight:bold;"&gt;":set fenc"&lt;/span&gt; and it will display the auto detected encoding. If it is not the correct one you can force the encoding by reloading the file using the command &lt;span style="font-weight:bold;"&gt;":edit ++enc=euc-jp"&lt;/span&gt; replacing "euc-jp" with the encoding you desire.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/34829202-9170664006837978516?l=piao-tech.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://piao-tech.blogspot.com/feeds/9170664006837978516/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://piao-tech.blogspot.com/2009/06/handling-multiple-encodings-in-vim.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/34829202/posts/default/9170664006837978516'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/34829202/posts/default/9170664006837978516'/><link rel='alternate' type='text/html' href='http://piao-tech.blogspot.com/2009/06/handling-multiple-encodings-in-vim.html' title='Handling multiple encodings in Vim'/><author><name>龍神</name><uri>http://www.blogger.com/profile/16648963337079496096</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-34829202.post-2776719073031246359</id><published>2009-06-12T13:26:00.008+09:00</published><updated>2009-06-21T15:29:16.374+09:00</updated><title type='text'>Vim tips for Latex editing</title><content type='html'>&lt;h4&gt;Simple Latex Makefile&lt;/h4&gt;&lt;br /&gt;&lt;br /&gt;With this simple Makefile you can compile your latex projects from within vim and use the quickfix window in case of errors to traverse and fix them one by one.&lt;br /&gt;&lt;br /&gt;&lt;div class="code"&gt;&lt;br /&gt;&lt;font face="monospace"&gt;&lt;br /&gt;&lt;font color="#87af87"&gt;# &lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#87af87"&gt;# This makefile generates a PDF of the MAINTEX file.&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#87af87"&gt;# The output can be found inside the build subdirectory.&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#87af87"&gt;#&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#87af87"&gt;# Makefile based on&amp;nbsp;&amp;nbsp;&lt;a href="http://www.wlug.org.nz/LatexMakefiles"&gt;http://www.wlug.org.nz/LatexMakefiles&lt;/a&gt;&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#87af87"&gt;#&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#87af87"&gt;#&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#87af87"&gt;# This makefile has been tested in Kubuntu 9.04&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#87af87"&gt;#&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#87af87"&gt;# Prerequisites:&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#87af87"&gt;#&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#87af87"&gt;# sudo aptitude install ptex-bin ptex-base okumura-clsfiles ptex-jisfonts \&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#87af87"&gt;#&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; xdvik-ja dvipsk-ja dvi2ps gv jbibtex-bin jmpost mendexk okumura-clsfiles \&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#87af87"&gt;#&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; vfdata-morisawa5 dvi2ps-fontdesc-morisawa5 texlive-latex-extra latexmk \&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#87af87"&gt;#&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; dvipng xpdf gs-cjk-resource vfdata-morisawa5 dvi2ps-fontdesc-morisawa5 \ &lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#87af87"&gt;#&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cmap-adobe-japan1 cmap-adobe-japan2 cmap-adobe-cns1 cmap-adobe-gb1&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#87af87"&gt;# sudo jisftconfig add&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#87af87"&gt;#&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#87af87"&gt;# When writing Japanese make sure your editor is saving the tex files&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#87af87"&gt;# in euc-jp encoding. In VIM this can be accomplished by setting the fenc &lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#87af87"&gt;# variable:&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#87af87"&gt;#&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#87af87"&gt;#&amp;nbsp;&amp;nbsp;- Open file as normal using vim &amp;lt;filename&amp;gt;&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#87af87"&gt;#&amp;nbsp;&amp;nbsp;- Type&amp;nbsp;&amp;nbsp;:edit ++enc=euc-jp&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#87af87"&gt;#&amp;nbsp;&amp;nbsp;- Type&amp;nbsp;&amp;nbsp;:set fenc=euc-jp&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#87af87"&gt;#&amp;nbsp;&amp;nbsp;- Type&amp;nbsp;&amp;nbsp;:set enc=utf-8 &lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#87af87"&gt;## &lt;/font&gt;&lt;span style="background-color: #3a3a3a"&gt;&lt;font color="#87af87"&gt;&lt;b&gt;TODO&lt;/b&gt;&lt;/font&gt;&lt;/span&gt;&lt;font color="#87af87"&gt;&amp;nbsp;Add rule to convert images&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#87af87"&gt;## &lt;/font&gt;&lt;span style="background-color: #3a3a3a"&gt;&lt;font color="#87af87"&gt;&lt;b&gt;TODO&lt;/b&gt;&lt;/font&gt;&lt;/span&gt;&lt;font color="#87af87"&gt;&amp;nbsp;Add makeindex to create .toc files&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#87af87"&gt;###########################################################################&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#87af87"&gt;## Put here the file name of the main tex file.&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#ffd7af"&gt;&lt;b&gt;MAINTEX&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/b&gt;&lt;/font&gt;= main&lt;br&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#87af87"&gt;############################################################################&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#87af87"&gt;## Change the followin only if you know what you are doing&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#ffd7af"&gt;&lt;b&gt;LATEXCMD&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/b&gt;&lt;/font&gt;= platex&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;font color="#87af87"&gt;# [latex | platex]&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#ffd7af"&gt;&lt;b&gt;BIBCMD&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/b&gt;&lt;/font&gt;= jbibtex&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;font color="#87af87"&gt;# [bibtex | jbibtex]&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#ffd7af"&gt;&lt;b&gt;DVIPDFCMD&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/b&gt;&lt;/font&gt;= dvipdf&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;font color="#87af87"&gt;# [dvipdf | dvipdfm | dvipdfmx]&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#ffd7af"&gt;&lt;b&gt;PDFVIEWER&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/b&gt;&lt;/font&gt;= xpdf&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;font color="#87af87"&gt;# [okular | xpdf | evince ]&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#ffd7af"&gt;&lt;b&gt;DVIVIEWER&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/b&gt;&lt;/font&gt;= xdvi-ja&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;font color="#87af87"&gt;# [xdvi | xdvi-ja | kdvi ]&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#87af87"&gt;## No need to change anything below this line&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#ffd7af"&gt;&lt;b&gt;TEXFILES&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/b&gt;&lt;/font&gt;= &lt;font color="#ffd7af"&gt;&lt;b&gt;$(&lt;/b&gt;&lt;/font&gt;&lt;span style="background-color: #3a3a3a"&gt;&lt;font color="#d7d7af"&gt;wildcard&lt;/font&gt;&lt;/span&gt;&lt;font color="#ffd7af"&gt;&lt;b&gt;&amp;nbsp;*.tex)&lt;/b&gt;&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#ffd7af"&gt;&lt;b&gt;TEXINPUTS&lt;/b&gt;&lt;/font&gt;=:&lt;font color="#ffd7af"&gt;&lt;b&gt;$(PWD)&lt;/b&gt;&lt;/font&gt;//:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;font color="#87af87"&gt;# Path to search for .tex, .cls and .sty files&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#ffd7af"&gt;&lt;b&gt;BSTINPUTS&lt;/b&gt;&lt;/font&gt;=:&lt;font color="#ffd7af"&gt;&lt;b&gt;$(PWD)&lt;/b&gt;&lt;/font&gt;//:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;font color="#87af87"&gt;# Path to search for .bst files&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#ffd7af"&gt;&lt;b&gt;BIBINPUTS&lt;/b&gt;&lt;/font&gt;=:&lt;font color="#ffd7af"&gt;&lt;b&gt;$(PWD)&lt;/b&gt;&lt;/font&gt;//:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;font color="#87af87"&gt;# Path to search for .bib files&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#ffd7af"&gt;&lt;b&gt;TEXMFOUTPUT&lt;/b&gt;&lt;/font&gt;=&lt;font color="#ffd7af"&gt;&lt;b&gt;$(PWD)&lt;/b&gt;&lt;/font&gt;/build&amp;nbsp;&amp;nbsp;&lt;font color="#87af87"&gt;# Output dir for bibtex and jbibtex&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#ffd7af"&gt;&lt;b&gt;LATEXOPTS&lt;/b&gt;&lt;/font&gt;= -output-directory=build -file-line-error -interaction=nonstopmode&lt;br&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;span style="background-color: #3a3a3a"&gt;&lt;font color="#d7d7af"&gt;export&lt;/font&gt;&lt;/span&gt;&amp;nbsp;TEXFILES TEXINPUTS BSTINPUTS BIBINPUTS TEXMFOUPUT&lt;br&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#ffff87"&gt;.PHONY:&lt;/font&gt;&amp;nbsp;all wordcount charcount pdf dvi&lt;br&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#ffff87"&gt;all:&lt;/font&gt;&amp;nbsp;build/&lt;font color="#ffd7af"&gt;&lt;b&gt;$(MAINTEX)&lt;/b&gt;&lt;/font&gt;.pdf&lt;br&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#ffff87"&gt;build :&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#d7afaf"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;@&lt;/font&gt;&lt;font color="#87d7d7"&gt;echo &lt;/font&gt;&lt;font color="#d78787"&gt;&amp;quot;Creating build directory&amp;quot;&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#d7afaf"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;@&lt;/font&gt;&lt;font color="#87d7d7"&gt;mkdir build&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#ffff87"&gt;build/$(MAINTEX).aux:&lt;/font&gt;&amp;nbsp;&lt;font color="#ffd7af"&gt;&lt;b&gt;$(MAINTEX)&lt;/b&gt;&lt;/font&gt;.tex &lt;font color="#ffd7af"&gt;&lt;b&gt;$(TEXFILES)&lt;/b&gt;&lt;/font&gt;&amp;nbsp;build&lt;br&gt;&lt;br /&gt;&lt;font color="#87d7d7"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/font&gt;&lt;font color="#ffd7af"&gt;&lt;b&gt;$(LATEXCMD)&lt;/b&gt;&lt;/font&gt;&lt;font color="#87d7d7"&gt;&amp;nbsp;&lt;/font&gt;&lt;font color="#ffd7af"&gt;&lt;b&gt;$(LATEXOPTS)&lt;/b&gt;&lt;/font&gt;&lt;font color="#87d7d7"&gt;&amp;nbsp;&lt;/font&gt;&lt;font color="#ffd7af"&gt;&lt;b&gt;$(MAINTEX)&lt;/b&gt;&lt;/font&gt;&lt;font color="#87d7d7"&gt;&amp;nbsp;&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#ffff87"&gt;build/$(MAINTEX).bbl:&lt;/font&gt;&amp;nbsp;build/&lt;font color="#ffd7af"&gt;&lt;b&gt;$(MAINTEX)&lt;/b&gt;&lt;/font&gt;.aux&lt;br&gt;&lt;br /&gt;&lt;font color="#87d7d7"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/font&gt;&lt;font color="#ffd7af"&gt;&lt;b&gt;$(BIBCMD)&lt;/b&gt;&lt;/font&gt;&lt;font color="#87d7d7"&gt;&amp;nbsp;build/&lt;/font&gt;&lt;font color="#ffd7af"&gt;&lt;b&gt;$(MAINTEX)&lt;/b&gt;&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#ffff87"&gt;build/$(MAINTEX).dvi:&lt;/font&gt;&amp;nbsp;build/&lt;font color="#ffd7af"&gt;&lt;b&gt;$(MAINTEX)&lt;/b&gt;&lt;/font&gt;.bbl&lt;br&gt;&lt;br /&gt;&lt;font color="#87d7d7"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/font&gt;&lt;font color="#ffd7af"&gt;&lt;b&gt;$(LATEXCMD)&lt;/b&gt;&lt;/font&gt;&lt;font color="#87d7d7"&gt;&amp;nbsp;&lt;/font&gt;&lt;font color="#ffd7af"&gt;&lt;b&gt;$(LATEXOPTS)&lt;/b&gt;&lt;/font&gt;&lt;font color="#87d7d7"&gt;&amp;nbsp;&lt;/font&gt;&lt;font color="#ffd7af"&gt;&lt;b&gt;$(MAINTEX)&lt;/b&gt;&lt;/font&gt;&lt;font color="#87d7d7"&gt;&amp;nbsp;&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#87d7d7"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/font&gt;&lt;font color="#ffd7af"&gt;&lt;b&gt;$(LATEXCMD)&lt;/b&gt;&lt;/font&gt;&lt;font color="#87d7d7"&gt;&amp;nbsp;&lt;/font&gt;&lt;font color="#ffd7af"&gt;&lt;b&gt;$(LATEXOPTS)&lt;/b&gt;&lt;/font&gt;&lt;font color="#87d7d7"&gt;&amp;nbsp;&lt;/font&gt;&lt;font color="#ffd7af"&gt;&lt;b&gt;$(MAINTEX)&lt;/b&gt;&lt;/font&gt;&lt;font color="#87d7d7"&gt;&amp;nbsp;&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#ffff87"&gt;build/$(MAINTEX).pdf:&lt;/font&gt;&amp;nbsp;build/&lt;font color="#ffd7af"&gt;&lt;b&gt;$(MAINTEX)&lt;/b&gt;&lt;/font&gt;.dvi&lt;br&gt;&lt;br /&gt;&lt;font color="#87d7d7"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/font&gt;&lt;font color="#ffd7af"&gt;&lt;b&gt;$(DVIPDFCMD)&lt;/b&gt;&lt;/font&gt;&lt;font color="#87d7d7"&gt;&amp;nbsp;build/&lt;/font&gt;&lt;font color="#ffd7af"&gt;&lt;b&gt;$(MAINTEX)&lt;/b&gt;&lt;/font&gt;&lt;font color="#87d7d7"&gt;.dvi build/&lt;/font&gt;&lt;font color="#ffd7af"&gt;&lt;b&gt;$(MAINTEX)&lt;/b&gt;&lt;/font&gt;&lt;font color="#87d7d7"&gt;.pdf&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#ffff87"&gt;dvi:&lt;/font&gt;&amp;nbsp;build/&lt;font color="#ffd7af"&gt;&lt;b&gt;$(MAINTEX)&lt;/b&gt;&lt;/font&gt;.dvi&lt;br&gt;&lt;br /&gt;&lt;font color="#87d7d7"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/font&gt;&lt;font color="#ffd7af"&gt;&lt;b&gt;$(DVIVIEWER)&lt;/b&gt;&lt;/font&gt;&lt;font color="#87d7d7"&gt;&amp;nbsp;build/&lt;/font&gt;&lt;font color="#ffd7af"&gt;&lt;b&gt;$(MAINTEX)&lt;/b&gt;&lt;/font&gt;&lt;font color="#87d7d7"&gt;.dvi &lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#ffff87"&gt;pdf:&lt;/font&gt;&amp;nbsp;build/&lt;font color="#ffd7af"&gt;&lt;b&gt;$(MAINTEX)&lt;/b&gt;&lt;/font&gt;.pdf&lt;br&gt;&lt;br /&gt;&lt;font color="#87d7d7"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/font&gt;&lt;font color="#ffd7af"&gt;&lt;b&gt;$(PDFVIEWER)&lt;/b&gt;&lt;/font&gt;&lt;font color="#87d7d7"&gt;&amp;nbsp;build/&lt;/font&gt;&lt;font color="#ffd7af"&gt;&lt;b&gt;$(MAINTEX)&lt;/b&gt;&lt;/font&gt;&lt;font color="#87d7d7"&gt;.pdf &lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#87af87"&gt;# Word counting can be done in VIM usng Ctrl-g g but this command also includes&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#87af87"&gt;# latex commands. This make rule strips the latex and counts what is left&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#ffff87"&gt;wordcount:&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#d7afaf"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;@&lt;/font&gt;&lt;font color="#87d7d7"&gt;echo Approximate word count: `grep -v &lt;/font&gt;&lt;font color="#d78787"&gt;'^\\\\'&lt;/font&gt;&lt;font color="#87d7d7"&gt;&amp;nbsp;&lt;/font&gt;&lt;font color="#ffd7af"&gt;&lt;b&gt;$(TEXFILES)&lt;/b&gt;&lt;/font&gt;&lt;font color="#87d7d7"&gt;|grep -v &lt;/font&gt;&lt;font color="#d78787"&gt;'^&lt;/font&gt;&lt;font color="#ffd7af"&gt;&lt;b&gt;%&lt;/b&gt;&lt;/font&gt;&lt;font color="#d78787"&gt;'&lt;/font&gt;&lt;font color="#87d7d7"&gt;|wc -w`&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#ffff87"&gt;charcount:&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#d7afaf"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;@&lt;/font&gt;&lt;font color="#87d7d7"&gt;echo Approximate char count: `grep -v &lt;/font&gt;&lt;font color="#d78787"&gt;'^\\\\'&lt;/font&gt;&lt;font color="#87d7d7"&gt;&amp;nbsp;&lt;/font&gt;&lt;font color="#ffd7af"&gt;&lt;b&gt;$(TEXFILES)&lt;/b&gt;&lt;/font&gt;&lt;font color="#87d7d7"&gt;|grep -v &lt;/font&gt;&lt;font color="#d78787"&gt;'^&lt;/font&gt;&lt;font color="#ffd7af"&gt;&lt;b&gt;%&lt;/b&gt;&lt;/font&gt;&lt;font color="#d78787"&gt;'&lt;/font&gt;&lt;font color="#87d7d7"&gt;|wc -c`&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;/font&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;Put all your tex files, images, sty, cls, bib, bst files inside a directory with any subfolder tree structure you like. This Makefile sets some environment variables that allow it to find all these files as long as they are below the current directory tree.&lt;br /&gt;&lt;br /&gt;Make sure your main tex file is called &lt;span style="font-weight:bold;"&gt;main.tex&lt;/span&gt; or if you prefer another one replace the &lt;span style="font-weight:bold;"&gt;MAINTEX&lt;/span&gt; variable in the Makefile. Take note that it has no extension!.&lt;br /&gt;&lt;br /&gt;Also note that this Makefile is to compile Japanese EUC-JP tex files (IEICE Trans). If you do not need Japanese replace &lt;span style="font-weight:bold;"&gt;platex&lt;/span&gt; with simple &lt;span style="font-weight:bold;"&gt;latex&lt;/span&gt; and &lt;span style="font-weight:bold;"&gt;jbibtex&lt;/span&gt; with &lt;span style="font-weight:bold;"&gt;bibtex&lt;/span&gt;.&lt;br /&gt;&lt;br /&gt;All output files generated by latex/platex, bibtex/jbibtex are stored inside a build subdirectory. &lt;br /&gt;&lt;br /&gt;Now in your .vimrc you can add the following parameter to compile your latex project:&lt;br /&gt;&lt;br /&gt;&lt;div class="code"&gt;&lt;br /&gt;&lt;font face="monospace"&gt;&lt;br /&gt;&lt;font color="#87af87"&gt;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#87af87"&gt;&amp;quot; Working with Makefiles&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#87af87"&gt;&amp;quot;&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#87af87"&gt;&amp;quot; Press F5 to compile and open the error window if there&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#87af87"&gt;&amp;quot; are errors. If there are errors you can use :cn and :cN to&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#87af87"&gt;&amp;quot; jump foward and backward thru the error list. Press :ccl to&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#87af87"&gt;&amp;quot; close the error list or F5 again to recompile&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;span style="background-color: #3a3a3a"&gt;&lt;font color="#d7d7af"&gt;map&lt;/font&gt;&lt;/span&gt;&amp;nbsp;&lt;font color="#8a8a8a"&gt;&amp;lt;&lt;/font&gt;&lt;font color="#d7afaf"&gt;F5&lt;/font&gt;&lt;font color="#8a8a8a"&gt;&amp;gt;&lt;/font&gt;&amp;nbsp;&lt;font color="#8a8a8a"&gt;&amp;lt;&lt;/font&gt;&lt;font color="#d7afaf"&gt;ESC&lt;/font&gt;&lt;font color="#8a8a8a"&gt;&amp;gt;&lt;/font&gt;:make&lt;font color="#8a8a8a"&gt;&amp;lt;&lt;/font&gt;&lt;font color="#d7afaf"&gt;CR&lt;/font&gt;&lt;font color="#8a8a8a"&gt;&amp;gt;&amp;lt;&lt;/font&gt;&lt;font color="#d7afaf"&gt;ESC&lt;/font&gt;&lt;font color="#8a8a8a"&gt;&amp;gt;&lt;/font&gt;:botright cwindow&lt;font color="#8a8a8a"&gt;&amp;lt;&lt;/font&gt;&lt;font color="#d7afaf"&gt;CR&lt;/font&gt;&lt;font color="#8a8a8a"&gt;&amp;gt;&lt;/font&gt;&amp;nbsp;&amp;quot; Compile and open quick fix list&lt;br&gt;&lt;br /&gt;&lt;span style="background-color: #3a3a3a"&gt;&lt;font color="#d7d7af"&gt;map&lt;/font&gt;&lt;/span&gt;&amp;nbsp;&lt;font color="#8a8a8a"&gt;&amp;lt;&lt;/font&gt;&lt;font color="#d7afaf"&gt;F6&lt;/font&gt;&lt;font color="#8a8a8a"&gt;&amp;gt;&lt;/font&gt;&amp;nbsp;&lt;font color="#8a8a8a"&gt;&amp;lt;&lt;/font&gt;&lt;font color="#d7afaf"&gt;ESC&lt;/font&gt;&lt;font color="#8a8a8a"&gt;&amp;gt;&lt;/font&gt;:cN&lt;font color="#8a8a8a"&gt;&amp;lt;&lt;/font&gt;&lt;font color="#d7afaf"&gt;CR&lt;/font&gt;&lt;font color="#8a8a8a"&gt;&amp;gt;&lt;/font&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;quot; Jump to prev error/warn&lt;br&gt;&lt;br /&gt;&lt;span style="background-color: #3a3a3a"&gt;&lt;font color="#d7d7af"&gt;map&lt;/font&gt;&lt;/span&gt;&amp;nbsp;&lt;font color="#8a8a8a"&gt;&amp;lt;&lt;/font&gt;&lt;font color="#d7afaf"&gt;F7&lt;/font&gt;&lt;font color="#8a8a8a"&gt;&amp;gt;&lt;/font&gt;&amp;nbsp;&lt;font color="#8a8a8a"&gt;&amp;lt;&lt;/font&gt;&lt;font color="#d7afaf"&gt;ESC&lt;/font&gt;&lt;font color="#8a8a8a"&gt;&amp;gt;&lt;/font&gt;:cn&lt;font color="#8a8a8a"&gt;&amp;lt;&lt;/font&gt;&lt;font color="#d7afaf"&gt;CR&lt;/font&gt;&lt;font color="#8a8a8a"&gt;&amp;gt;&lt;/font&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;quot; Jump to next error/warn&lt;br&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;/font&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;Now when editing you latex files press &amp;lt;F5&amp;gt; to compile them and if errors occur you will be presented with a quickfix window where you can use &amp;lt;F6&amp;gt; and &amp;lt;F7&amp;gt; to quickly jump to the previous and next error message.&lt;br /&gt;&lt;br /&gt;Additionally this Makefile also has a few useful commands you can invoke from within vim:&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;br /&gt;&lt;li&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;:!make pdf&lt;/span&gt; to display the pdf file using xpdf or if you prefer a different viewer replace the PDFVIEWER variable in the Makefile.&lt;br /&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;:!make dvi&lt;/span&gt; to display the dvi file using xdvi or if you prefer a different viewer replace the DVIVIEWER variable in the Makefile.&lt;br /&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;:!make wordcount&lt;/span&gt; to display the number of words in all the tex documents. In vim you can also use g&amp;lt;ctrl-g&amp;gt; in normal mode but this also counts latex commands.&lt;br /&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;:!make charcount&lt;/span&gt; same as wordcount but for characters instead of words.&lt;br /&gt;&lt;/li&gt;&lt;br /&gt;&lt;/ul&gt;&lt;br /&gt;&lt;br /&gt;&lt;h4&gt;Latex with Vim TagList plugin&lt;/h4&gt;&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_99Fzui5MBLY/SjIVTAt75II/AAAAAAAAANk/uiwZb7gXVZo/s1600-h/vim-latex01.png"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 320px; height: 247px;" src="http://4.bp.blogspot.com/_99Fzui5MBLY/SjIVTAt75II/AAAAAAAAANk/uiwZb7gXVZo/s320/vim-latex01.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5346359123996566658" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;We can enable TagList to display important keywords like section, labels and references for easy navigation (&lt;a href="http://vim.wikia.com/wiki/Use_Taglist_with_LaTeX_files"&gt;link&lt;/a&gt;).&lt;br /&gt;&lt;br /&gt;First create a ~/.ctags file that contains the following:&lt;br /&gt;&lt;br /&gt;&lt;div class="code"&gt;&lt;br /&gt;--langdef=tex&lt;br /&gt;--langmap=tex:.tex&lt;br /&gt;--regex-tex=/\\subsubsection[ \t]*\*?\{[ \t]*([^}]*)\}/- \1/s,subsubsection/&lt;br /&gt;--regex-tex=/\\subsection[ \t]*\*?\{[ \t]*([^}]*)\}/+\1/s,subsection/&lt;br /&gt;--regex-tex=/\\section[ \t]*\*?\{[ \t]*([^}]*)\}/\1/s,section/&lt;br /&gt;--regex-tex=/\\chapter[ \t]*\*?\{[ \t]*([^}]*)\}/\1/c,chapter/&lt;br /&gt;--regex-tex=/\\label[ \t]*\*?\{[ \t]*([^}]*)\}/\1/l,label/&lt;br /&gt;--regex-tex=/\\ref[ \t]*\*?\{[ \t]*([^}]*)\}/\1/r,ref/&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;Then modify the taflist.vim file and add a new language. To do this search for "yacc language" and add these line before it:&lt;br /&gt;&lt;br /&gt;&lt;div class="code"&gt;&lt;br /&gt;" tex language&lt;br /&gt;let s:tlist_def_tex_settings = 'tex;s:section;c:chapter;l:label;r:ref'&lt;br /&gt;&lt;br /&gt;" yacc language&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;Now when you open the taglist window you will get a nice list of section, subsections, chapters, references, labels, etc... that you can navigate and use to jump quickly to each of them.&lt;br /&gt;&lt;br /&gt;If you do not have the taglist plugin installed you can follow my instructions &lt;a href="http://piao-tech.blogspot.com/2008/10/make-vim-and-ctag-play-nice-together.html"&gt;here&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;&lt;h4&gt;Reference autocompletion&lt;/h4&gt;&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_99Fzui5MBLY/SjIXjzzwlmI/AAAAAAAAANs/srnkrNvvpGY/s1600-h/vim-latex02.png"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 320px; height: 247px;" src="http://4.bp.blogspot.com/_99Fzui5MBLY/SjIXjzzwlmI/AAAAAAAAANs/srnkrNvvpGY/s320/vim-latex02.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5346361611612362338" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;If you write your labels as \label{fig:something}, then put this in your ~/.vimrc file:&lt;br /&gt;&lt;br /&gt;&lt;div class="code"&gt;&lt;br /&gt;&lt;font face="monospace"&gt;&lt;br /&gt;&lt;span style="background-color: #3a3a3a"&gt;&lt;font color="#d7d7af"&gt;set&lt;/font&gt;&lt;/span&gt;&amp;nbsp;&lt;font color="#ffd7af"&gt;&lt;b&gt;iskeyword&lt;/b&gt;&lt;/font&gt;+=&lt;span style="background-color: #3a3a3a"&gt;&lt;font color="#d7d7af"&gt;:&lt;/font&gt;&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;font color="#87af87"&gt;&amp;quot; type /ref{fig: and prec &amp;lt;C-n&amp;gt; to autocomplete references&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;/font&gt;&lt;br /&gt;&lt;br /&gt;With this now you can type \ref{fig: and press &lt;C-n&gt; to get a list of labels you can cycle as shown in the image above.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;h4&gt;Spell checking&lt;/h4&gt;&lt;br /&gt;&lt;br /&gt;This is not only for latex files. Simply put the following in your ~/.vimrc file to enable automatic spell checking. Learn how to use the spell checker to correct, add and/or ignore words.&lt;br /&gt;&lt;br /&gt;&lt;div class="code"&gt;&lt;br /&gt;&lt;font face="monospace"&gt;&lt;br /&gt;&lt;font color="#87af87"&gt;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#87af87"&gt;&amp;quot; Enable spell checking in latex, bib and txt files&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#87af87"&gt;&amp;quot;&lt;/font&gt;&amp;nbsp;&lt;font color="#ffd7af"&gt;&lt;b&gt;Commands:&lt;/b&gt;&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#87af87"&gt;&amp;quot;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;[s&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;-&amp;gt;&amp;nbsp;&amp;nbsp;jump to next bad word&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#87af87"&gt;&amp;quot;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;]s&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;-&amp;gt;&amp;nbsp;&amp;nbsp;jump to prev bad word&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#87af87"&gt;&amp;quot;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;z=&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;-&amp;gt;&amp;nbsp;&amp;nbsp;suggest word&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#87af87"&gt;&amp;quot;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;zg&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;-&amp;gt;&amp;nbsp;&amp;nbsp;mark word as good (add to dictionary)&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#87af87"&gt;&amp;quot;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;zw&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;-&amp;gt;&amp;nbsp;&amp;nbsp;mark word as bad&amp;nbsp;&amp;nbsp;(remove from dictionary)&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#87af87"&gt;&amp;quot;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;:h spell -&amp;gt; get more details about spelling&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#87af87"&gt;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;span style="background-color: #3a3a3a"&gt;&lt;font color="#d7d7af"&gt;au&lt;/font&gt;&lt;/span&gt;&amp;nbsp;&lt;font color="#d7d7af"&gt;&lt;b&gt;BufRead&lt;/b&gt;&lt;/font&gt;,&lt;font color="#d7d7af"&gt;&lt;b&gt;BufNewFile&lt;/b&gt;&lt;/font&gt;&amp;nbsp;*.txt,*.tex,*.bib&amp;nbsp;&amp;nbsp;&lt;span style="background-color: #3a3a3a"&gt;&lt;font color="#d7d7af"&gt;setlocal&lt;/font&gt;&lt;/span&gt;&amp;nbsp;&lt;font color="#ffd7af"&gt;&lt;b&gt;spell&lt;/b&gt;&lt;/font&gt;&amp;nbsp;&lt;font color="#ffd7af"&gt;&lt;b&gt;spelllang&lt;/b&gt;&lt;/font&gt;=en_us&lt;br&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;/font&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/34829202-2776719073031246359?l=piao-tech.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://piao-tech.blogspot.com/feeds/2776719073031246359/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://piao-tech.blogspot.com/2009/06/vim-tips-for-latex-editing.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/34829202/posts/default/2776719073031246359'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/34829202/posts/default/2776719073031246359'/><link rel='alternate' type='text/html' href='http://piao-tech.blogspot.com/2009/06/vim-tips-for-latex-editing.html' title='Vim tips for Latex editing'/><author><name>龍神</name><uri>http://www.blogger.com/profile/16648963337079496096</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/_99Fzui5MBLY/SjIVTAt75II/AAAAAAAAANk/uiwZb7gXVZo/s72-c/vim-latex01.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-34829202.post-6081995091006477032</id><published>2008-11-12T10:53:00.002+09:00</published><updated>2008-12-02T10:11:14.893+09:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Tips'/><category scheme='http://www.blogger.com/atom/ns#' term='Windows'/><title type='text'>Mounting Windows Shares Using CIFS on Ubuntu</title><content type='html'>So you have a cool &lt;a href="http://www.buffalotech.com/products/network-storage/linkstation/linkstation-pro-duo/"&gt;Buffalo LinkStation Pro Duo&lt;/a&gt; or a Windows machine with some shared folders you want to access from your super Linux machine. No problems we have CIFS to the rescue!!&lt;br /&gt;&lt;br /&gt;These instructions were tested in Kubuntu 8.10 (Ibex) but shall work with previous versions and future versions of Kubuntu and/or Ubuntu. Also I assume you want the share to be available to all users in the system so you need root access (i.e. sudo).&lt;br /&gt;&lt;br /&gt;First install smbfs package:&lt;br /&gt;&lt;br /&gt;&lt;div class="code"&gt;&lt;br /&gt;sudo aptitude install smbfs&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;Create a directory were you want to mount the shared folder, any place is ok:&lt;br /&gt;&lt;br /&gt;&lt;div class="code"&gt;&lt;br /&gt;sudo mkdir /media/share&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;If the share requires username and password to access create a password file in you home directory:&lt;br /&gt;&lt;br /&gt;&lt;div class="code"&gt;&lt;br /&gt;sudo echo -e "username=my_username\npassword=my_password" &gt; /root/.share_pass&lt;br /&gt;sudo chown root:root /root&lt;br /&gt;sudo chmod 700 /root/.share_pass&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;Replace "my_username" and "my_password" with the corresponding user and pass to access the remote share.&lt;br /&gt;&lt;br /&gt;Finally create an entry in the "/etc/fstab" file to mount the shared folder in the desired mount point:&lt;br /&gt;&lt;br /&gt;&lt;div class="code"&gt;&lt;br /&gt;//ip-address/share /media/share credentials=/root/.share_pass,iocharset=utf8,file_mode=0777,dir_mode=0777 0 0&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;Here you must replace //ip-address/share with the ip address of the machine with the shared folder and the complete path to the respective folder. &lt;br /&gt;&lt;br /&gt;Finally mount all partitions:&lt;br /&gt;&lt;br /&gt;&lt;div class="code"&gt;&lt;br /&gt;sudo mount -a&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;Now you must be able to access the shared folder at the remote machine by accessing the /media/share directory.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;h1&gt;References&lt;/h1&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://ubuntuforums.org/showthread.php?t=288534"&gt;http://ubuntuforums.org/showthread.php?t=288534&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/34829202-6081995091006477032?l=piao-tech.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://piao-tech.blogspot.com/feeds/6081995091006477032/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://piao-tech.blogspot.com/2008/11/mounting-windows-shares-using-cifs-on.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/34829202/posts/default/6081995091006477032'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/34829202/posts/default/6081995091006477032'/><link rel='alternate' type='text/html' href='http://piao-tech.blogspot.com/2008/11/mounting-windows-shares-using-cifs-on.html' title='Mounting Windows Shares Using CIFS on Ubuntu'/><author><name>龍神</name><uri>http://www.blogger.com/profile/16648963337079496096</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-34829202.post-6473392386252874801</id><published>2008-10-19T13:10:00.002+09:00</published><updated>2008-10-19T13:45:49.096+09:00</updated><title type='text'>NVidia InitialPixmapPlacement=2 really improves KDE speed</title><content type='html'>&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_99Fzui5MBLY/SPq1ikO9cUI/AAAAAAAAAMo/R6wY5vAKe1c/s1600-h/penrose01.png"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;" src="http://4.bp.blogspot.com/_99Fzui5MBLY/SPq1ikO9cUI/AAAAAAAAAMo/R6wY5vAKe1c/s320/penrose01.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5258715120355078466" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Some people say KDE4 rendering speed is slow when using Nvidia cards. I never felt this so I never bothered in applying the proposed solutions. Using firefox (note: this test does not run in konqueror) simply access the &lt;a href="http://intertwingly.net/stories/2006/07/10/penroseTiling.html"&gt;penroseTitling&lt;/a&gt; test page and run both tests. My first tests are in the image above and as you can see not bad as I have read in the Internet that for some people the Canvas test can take up to 30 seconds while it took 3 seconds on my machine.&lt;br /&gt;&lt;br /&gt;Anyway I tried one of the solutions that is simply running this command in the konsole:&lt;br /&gt;&lt;br /&gt;&lt;div class="code"&gt;&lt;br /&gt;nvidia-settings -a InitialPixmapPlacement=2 -a GlyphCache=1&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;And here are the new times:&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_99Fzui5MBLY/SPq2W_BrM0I/AAAAAAAAAMw/kQVWKkUE8Vo/s1600-h/penrose02.png"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;" src="http://3.bp.blogspot.com/_99Fzui5MBLY/SPq2W_BrM0I/AAAAAAAAAMw/kQVWKkUE8Vo/s320/penrose02.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5258716020900311874" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Wow this is a real improvement so now I have a kde startup script that calls this command when KDE starts:&lt;br /&gt;&lt;br /&gt;&lt;div class="code"&gt;&lt;br /&gt;# ~/.kde4/Autostart/nvidia.sh&lt;br /&gt;!#/bin/bash&lt;br /&gt;nvidia-settings -a InitialPixmapPlacement=2 -a GlyphCache=1 &amp;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;Resources:&lt;br /&gt;&lt;a href="http://movingparts.net/2008/10/03/kde-42-trunk-now-rocking-on-my-thinkpad-t61/"&gt;http://movingparts.net/2008/10/03/kde-42-trunk-now-rocking-on-my-thinkpad-t61/&lt;/a&gt;&lt;br /&gt;&lt;a href="http://techbase.kde.org/User:Lemma/KDE4-NVIDIA"&gt;http://techbase.kde.org/User:Lemma/KDE4-NVIDIA&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/34829202-6473392386252874801?l=piao-tech.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://piao-tech.blogspot.com/feeds/6473392386252874801/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://piao-tech.blogspot.com/2008/10/nvidia-initialpixmapplacement2-really.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/34829202/posts/default/6473392386252874801'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/34829202/posts/default/6473392386252874801'/><link rel='alternate' type='text/html' href='http://piao-tech.blogspot.com/2008/10/nvidia-initialpixmapplacement2-really.html' title='NVidia InitialPixmapPlacement=2 really improves KDE speed'/><author><name>龍神</name><uri>http://www.blogger.com/profile/16648963337079496096</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/_99Fzui5MBLY/SPq1ikO9cUI/AAAAAAAAAMo/R6wY5vAKe1c/s72-c/penrose01.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-34829202.post-3753435949176738722</id><published>2008-10-09T22:19:00.000+09:00</published><updated>2008-10-09T22:29:51.675+09:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Vim'/><category scheme='http://www.blogger.com/atom/ns#' term='Tips'/><title type='text'>Use vimdiff as Subversion diff command</title><content type='html'>&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_99Fzui5MBLY/SO4HP94JMfI/AAAAAAAAAMg/S3TbtGtic1E/s1600-h/vimdiff.png"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;" src="http://1.bp.blogspot.com/_99Fzui5MBLY/SO4HP94JMfI/AAAAAAAAAMg/S3TbtGtic1E/s320/vimdiff.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5255145786077426162" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;First create a script svbdiff inside the ~/.vim/scripts/ directory that contains the following&lt;br /&gt;&lt;br /&gt;&lt;div class="code"&gt;&lt;br /&gt;#!/bin/bash&lt;br /&gt;shift 5;/usr/bin/vimdiff -f "$@"&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;and make it executable:&lt;br /&gt;&lt;br /&gt;&lt;div class="code"&gt;&lt;br /&gt;chmod +x ~/.vim/scripts/svndiff&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;Then create an alias in your ~/.bashrc file like:&lt;br /&gt;&lt;br /&gt;&lt;div class="code"&gt;&lt;br /&gt;alias svndiff="svn diff --diff-cmd ~/.vim/scripts/svndiff"&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;Now you can go to any Subversion repository and display file differences with&lt;br /&gt;&lt;br /&gt;&lt;div class="code"&gt;&lt;br /&gt;svndiff h264.c&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;The screenshot above shows the diff output of the h264.c of libavcodec. Make sure you have a color scheme that highlights the file differences. The screenshot above uses the &lt;a href="http://www.vim.org/scripts/script.php?script_id=1143"&gt;inkpot&lt;/a&gt; color scheme.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/34829202-3753435949176738722?l=piao-tech.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://piao-tech.blogspot.com/feeds/3753435949176738722/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://piao-tech.blogspot.com/2008/10/use-vimdiff-as-subversion-diff-command.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/34829202/posts/default/3753435949176738722'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/34829202/posts/default/3753435949176738722'/><link rel='alternate' type='text/html' href='http://piao-tech.blogspot.com/2008/10/use-vimdiff-as-subversion-diff-command.html' title='Use vimdiff as Subversion diff command'/><author><name>龍神</name><uri>http://www.blogger.com/profile/16648963337079496096</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_99Fzui5MBLY/SO4HP94JMfI/AAAAAAAAAMg/S3TbtGtic1E/s72-c/vimdiff.png' height='72' width='72'/><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-34829202.post-1977807154279183961</id><published>2008-10-09T21:22:00.004+09:00</published><updated>2009-06-12T13:18:27.035+09:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Vim'/><category scheme='http://www.blogger.com/atom/ns#' term='Tips'/><category scheme='http://www.blogger.com/atom/ns#' term='Kubuntu'/><title type='text'>Open new files as tabs in current Vim Console</title><content type='html'>When programming I like to have a single Vim editor open with all my files as tabs. Until now I was using the ":tabnew" command to open files in the current Vim window as I knew no other way.&lt;br /&gt;&lt;br /&gt;Some research led me to the --remote-tab switch that allows to open files as tabs in currently open Vim processes but it seemed to work only with the graphical interface (gvim) and not with the console (vim). But as I made some tests I found this can work with the vim in console mode and more over can be nicely integrated with my favorite file managers (Konqueror/Dolphin). &lt;br /&gt;&lt;br /&gt;All I needed to do was configure my bash so it will always start vim in server mode if it is not already and to always use the --remote-tab switch when opening files. To do this I simply added these functions to my ~/.bashrc file:&lt;br /&gt;&lt;br /&gt;&lt;div class="code"&gt;&lt;br /&gt;&lt;font color="#ffff87"&gt;function&lt;/font&gt;&amp;nbsp;v &lt;font color="#8a8a8a"&gt;{&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &lt;font color="#ffd7af"&gt;&lt;b&gt;if&lt;/b&gt;&lt;/font&gt;&amp;nbsp;&lt;font color="#ffffd7"&gt;[&lt;/font&gt;&amp;nbsp;&lt;font color="#ffffd7"&gt;&amp;quot;&lt;/font&gt;&lt;font color="#ffd7af"&gt;&lt;b&gt;$#&lt;/b&gt;&lt;/font&gt;&lt;font color="#ffffd7"&gt;&amp;quot;&lt;/font&gt;&amp;nbsp;&lt;font color="#ffd7af"&gt;&lt;b&gt;-eq&lt;/b&gt;&lt;/font&gt;&amp;nbsp;&lt;font color="#ffffd7"&gt;&amp;quot;&lt;/font&gt;&lt;font color="#d78787"&gt;0&lt;/font&gt;&lt;font color="#ffffd7"&gt;&amp;quot;&lt;/font&gt;&amp;nbsp;&lt;font color="#ffffd7"&gt;]&lt;/font&gt;&lt;font color="#ffffd7"&gt;;&lt;/font&gt;&amp;nbsp;&lt;font color="#ffd7af"&gt;&lt;b&gt;then&lt;/b&gt;&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;/usr/bin/vim --servername VIMLOCAL&lt;br&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &lt;font color="#ffd7af"&gt;&lt;b&gt;else&lt;/b&gt;&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;font color="#ffd7af"&gt;&lt;b&gt;if&lt;/b&gt;&lt;/font&gt;&amp;nbsp;&lt;span style="background-color: #3a3a3a"&gt;&lt;font color="#d7d7af"&gt;echo&lt;/font&gt;&lt;/span&gt;&lt;font color="#d78787"&gt;&amp;nbsp;&lt;/font&gt;&lt;font color="#ffffd7"&gt;&amp;quot;&lt;/font&gt;&lt;font color="#ffd7af"&gt;&lt;b&gt;$*&lt;/b&gt;&lt;/font&gt;&lt;font color="#ffffd7"&gt;&amp;quot;&lt;/font&gt;&lt;font color="#d78787"&gt;&amp;nbsp;&lt;/font&gt;&lt;font color="#ffffd7"&gt;|&lt;/font&gt;&amp;nbsp;&lt;span style="background-color: #3a3a3a"&gt;&lt;font color="#d7d7af"&gt;grep&lt;/font&gt;&lt;/span&gt;&amp;nbsp;&lt;font color="#ffd7af"&gt;&lt;b&gt;-q&lt;/b&gt;&lt;/font&gt;&amp;nbsp;-- &lt;font color="#ffffd7"&gt;&amp;quot;&lt;/font&gt;&lt;font color="#d78787"&gt;--servername&lt;/font&gt;&lt;font color="#ffffd7"&gt;&amp;quot;&lt;/font&gt;&amp;nbsp;&lt;font color="#ffffd7"&gt;;&lt;/font&gt;&amp;nbsp;&lt;font color="#ffd7af"&gt;&lt;b&gt;then&lt;/b&gt;&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;font color="#87af87"&gt;# echo &amp;quot;Command already has --servername use it&amp;quot;&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;/usr/bin/vim &lt;font color="#ffd7af"&gt;&lt;b&gt;$*&lt;/b&gt;&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;font color="#ffd7af"&gt;&lt;b&gt;else&lt;/b&gt;&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;font color="#87af87"&gt;#echo &amp;quot;Use default VIM server VIMLOCAL&amp;quot;&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;/usr/bin/vim --servername VIMLOCAL --remote-tab-silent &lt;font color="#ffd7af"&gt;&lt;b&gt;$*&lt;/b&gt;&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;font color="#ffd7af"&gt;&lt;b&gt;fi&lt;/b&gt;&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &lt;font color="#ffd7af"&gt;&lt;b&gt;fi&lt;/b&gt;&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#8a8a8a"&gt;}&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#ffff87"&gt;function&lt;/font&gt;&amp;nbsp;gv &lt;font color="#8a8a8a"&gt;{&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &lt;font color="#ffd7af"&gt;&lt;b&gt;if&lt;/b&gt;&lt;/font&gt;&amp;nbsp;&lt;font color="#ffffd7"&gt;[&lt;/font&gt;&amp;nbsp;&lt;font color="#ffffd7"&gt;&amp;quot;&lt;/font&gt;&lt;font color="#ffd7af"&gt;&lt;b&gt;$#&lt;/b&gt;&lt;/font&gt;&lt;font color="#ffffd7"&gt;&amp;quot;&lt;/font&gt;&amp;nbsp;&lt;font color="#ffd7af"&gt;&lt;b&gt;-eq&lt;/b&gt;&lt;/font&gt;&amp;nbsp;&lt;font color="#ffffd7"&gt;&amp;quot;&lt;/font&gt;&lt;font color="#d78787"&gt;0&lt;/font&gt;&lt;font color="#ffffd7"&gt;&amp;quot;&lt;/font&gt;&amp;nbsp;&lt;font color="#ffffd7"&gt;]&lt;/font&gt;&lt;font color="#ffffd7"&gt;;&lt;/font&gt;&amp;nbsp;&lt;font color="#ffd7af"&gt;&lt;b&gt;then&lt;/b&gt;&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;/usr/bin/gvim --servername GVIMLOCAL&lt;br&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &lt;font color="#ffd7af"&gt;&lt;b&gt;else&lt;/b&gt;&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;font color="#ffd7af"&gt;&lt;b&gt;if&lt;/b&gt;&lt;/font&gt;&amp;nbsp;&lt;span style="background-color: #3a3a3a"&gt;&lt;font color="#d7d7af"&gt;echo&lt;/font&gt;&lt;/span&gt;&lt;font color="#d78787"&gt;&amp;nbsp;&lt;/font&gt;&lt;font color="#ffffd7"&gt;&amp;quot;&lt;/font&gt;&lt;font color="#ffd7af"&gt;&lt;b&gt;$*&lt;/b&gt;&lt;/font&gt;&lt;font color="#ffffd7"&gt;&amp;quot;&lt;/font&gt;&lt;font color="#d78787"&gt;&amp;nbsp;&lt;/font&gt;&lt;font color="#ffffd7"&gt;|&lt;/font&gt;&amp;nbsp;&lt;span style="background-color: #3a3a3a"&gt;&lt;font color="#d7d7af"&gt;grep&lt;/font&gt;&lt;/span&gt;&amp;nbsp;&lt;font color="#ffd7af"&gt;&lt;b&gt;-q&lt;/b&gt;&lt;/font&gt;&amp;nbsp;-- &lt;font color="#ffffd7"&gt;&amp;quot;&lt;/font&gt;&lt;font color="#d78787"&gt;--servername&lt;/font&gt;&lt;font color="#ffffd7"&gt;&amp;quot;&lt;/font&gt;&amp;nbsp;&lt;font color="#ffffd7"&gt;;&lt;/font&gt;&amp;nbsp;&lt;font color="#ffd7af"&gt;&lt;b&gt;then&lt;/b&gt;&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;font color="#87af87"&gt;# echo &amp;quot;Command already has --servername use it&amp;quot;&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;/usr/bin/gvim &lt;font color="#ffd7af"&gt;&lt;b&gt;$*&lt;/b&gt;&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;font color="#ffd7af"&gt;&lt;b&gt;else&lt;/b&gt;&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;font color="#87af87"&gt;#echo &amp;quot;Use default VIM server VIMLOCAL&amp;quot;&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;/usr/bin/gvim --servername GVIMLOCAL --remote-tab-silent &lt;font color="#ffd7af"&gt;&lt;b&gt;$*&lt;/b&gt;&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;font color="#ffd7af"&gt;&lt;b&gt;fi&lt;/b&gt;&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &lt;font color="#ffd7af"&gt;&lt;b&gt;fi&lt;/b&gt;&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#8a8a8a"&gt;}&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;span style="background-color: #3a3a3a"&gt;&lt;font color="#d7d7af"&gt;alias &lt;/font&gt;&lt;/span&gt;&lt;font color="#ffd7af"&gt;&lt;b&gt;vi&lt;/b&gt;&lt;/font&gt;&lt;span style="background-color: #3a3a3a"&gt;&lt;font color="#d7d7af"&gt;=&lt;/font&gt;&lt;/span&gt;v&lt;br&gt;&lt;br /&gt;&lt;span style="background-color: #3a3a3a"&gt;&lt;font color="#d7d7af"&gt;alias &lt;/font&gt;&lt;/span&gt;&lt;font color="#ffd7af"&gt;&lt;b&gt;vim&lt;/b&gt;&lt;/font&gt;&lt;span style="background-color: #3a3a3a"&gt;&lt;font color="#d7d7af"&gt;=&lt;/font&gt;&lt;/span&gt;v&lt;br&gt;&lt;br /&gt;&lt;span style="background-color: #3a3a3a"&gt;&lt;font color="#d7d7af"&gt;alias &lt;/font&gt;&lt;/span&gt;&lt;font color="#ffd7af"&gt;&lt;b&gt;gvim&lt;/b&gt;&lt;/font&gt;&lt;span style="background-color: #3a3a3a"&gt;&lt;font color="#d7d7af"&gt;=&lt;/font&gt;&lt;/span&gt;gv&lt;br&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;With these functions loaded (i.e. source ~/.bashrc) the first time you execute vim/gvim it will start a new process in server mode. &lt;br /&gt;&lt;br /&gt;&lt;div class="code"&gt;&lt;br /&gt;# this command will open vim in the current console&lt;br /&gt;# and display first_file.txt for editing.&lt;br /&gt;&lt;br /&gt;vim first_file.txt &lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;The second and all subsequent times you execute vim/gvim the files you set as parameters will be opened as tabs in the already opened vim/gvim instance.&lt;br /&gt;&lt;br /&gt;&lt;div class="code"&gt;&lt;br /&gt;# This command in other console will open the files&lt;br /&gt;# second_file.txt and third_file.txt as tabs in the&lt;br /&gt;# other console with first_file.txt open&lt;br /&gt;&lt;br /&gt;vim second_file.txt third_file.txt&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;The above examples work also with gvim instead of vim. The only drawback is that now it is difficult to open files in a separate console. The best solution I found is to call vim with a different server name:&lt;br /&gt;&lt;br /&gt;&lt;div class="code"&gt;&lt;br /&gt;# This command will create a new instance of vim in the current console window&lt;br /&gt;# and display the other_file.txt file for editing.&lt;br /&gt;&lt;br /&gt;vim --servername OTHERNAME other_file.txt&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;If you prefer not to use tabs and like files to be opened as buffers inside a current running Vim instance then simply replace "--remote-tab-silent" with "--remote-silent" in the above scripts.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/34829202-1977807154279183961?l=piao-tech.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://piao-tech.blogspot.com/feeds/1977807154279183961/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://piao-tech.blogspot.com/2008/10/open-new-files-as-tabs-in-current-vim.html#comment-form' title='4 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/34829202/posts/default/1977807154279183961'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/34829202/posts/default/1977807154279183961'/><link rel='alternate' type='text/html' href='http://piao-tech.blogspot.com/2008/10/open-new-files-as-tabs-in-current-vim.html' title='Open new files as tabs in current Vim Console'/><author><name>龍神</name><uri>http://www.blogger.com/profile/16648963337079496096</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>4</thr:total></entry><entry><id>tag:blogger.com,1999:blog-34829202.post-9130122878161532579</id><published>2008-10-09T19:48:00.017+09:00</published><updated>2009-12-23T21:13:21.471+09:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Ctags'/><category scheme='http://www.blogger.com/atom/ns#' term='Vim'/><category scheme='http://www.blogger.com/atom/ns#' term='Tips'/><category scheme='http://www.blogger.com/atom/ns#' term='Kubuntu'/><title type='text'>Make Vim and Ctag play nice together</title><content type='html'>&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_99Fzui5MBLY/SzIJTI943DI/AAAAAAAAAN4/fy1ezb0HP8c/s1600-h/ctags.png"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 320px; height: 210px;" src="http://1.bp.blogspot.com/_99Fzui5MBLY/SzIJTI943DI/AAAAAAAAAN4/fy1ezb0HP8c/s320/ctags.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5418403526109355058" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;The classic tutorial of Ctags + Vim will go something like:&lt;br /&gt;&lt;ul&gt;&lt;br /&gt;&lt;li&gt;- Install exuberant ctags&lt;/li&gt;&lt;br /&gt;&lt;li&gt;- Generate tags for your project&lt;/li&gt;&lt;br /&gt;&lt;li&gt;- Also install the tag list plugin&lt;/li&gt;&lt;br /&gt;&lt;li&gt;- Use ^] and ^T to jump around the code&lt;/li&gt;&lt;br /&gt;&lt;/ul&gt;&lt;br /&gt;&lt;br /&gt;In this post I will try to go a little further and show how I manage tags in vim for real and large C projects. &lt;br /&gt;&lt;br /&gt;Note that I mostly program in C (not C++), Ruby and Bash so I cannot guarantee my method works for all languages. In special Ctags has &lt;a href="http://stackoverflow.com/questions/656702/vim-ctags-and-identically-named-identifiers"&gt;problems&lt;/a&gt; supporting &lt;a href="http://stackoverflow.com/questions/1932396/c-source-tagging"&gt;C++&lt;/a&gt;. On the other side I have worked in small projects in Java and Python and I had no problems navigating them with my method.&lt;br /&gt;&lt;br /&gt;&lt;h2&gt;Pre requisites &lt;/h2&gt;&lt;br /&gt;&lt;br /&gt;The following instructions were tested on a Linux machine installed using Kubuntu 8.10, 9.04 and 9.10. The first step is of course to make sure you have installed Vim and exuberant-ctags in you machine: &lt;br /&gt;&lt;br /&gt;&lt;div class="code"&gt;&lt;br /&gt;sudo aptitude install vim-ruby vim-scripts vim-common exuberant-ctags&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;If you are new to Vim then you should take some time to set your minimal configuration. You may follow mine if you want &lt;a href="http://piao-tech.blogspot.com/2008/10/basic-vimrc-file.html"&gt;link&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;&lt;h2&gt; Generate system wide ctags &lt;/h2&gt;&lt;br /&gt;&lt;br /&gt;All large projects will use at some point external libraries. My C projects usually use the Linux/FreeBSD system calls, SDL, OpenGL, libavcodec and libavformat among others. &lt;br /&gt;&lt;br /&gt;To be able to jump to these libraries we must generate tags for each of them. I usually generate them inside my vim directory but you may create them in a system wide folder.&lt;br /&gt;&lt;br /&gt;This is extremely useful to easily find out the members of libavcodec large structs  or to quickly find out what are the arguments of SDL functions or system calls.&lt;br /&gt;&lt;br /&gt;&lt;h3&gt;Ctags for Linux System Calls&lt;/h3&gt;&lt;br /&gt;&lt;div class=code&gt;&lt;br /&gt;mkdir -p ~/.vim/tags&lt;br /&gt;sudo aptitude install linux-headers-`uname -r`&lt;br /&gt;ctags -R -f ~/.vim/tags/kerneltags /usr/src/linux-headers-`uname -r`&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;h3&gt;Ctags for Ruby core and gem libraries&lt;/h3&gt;&lt;br /&gt;&lt;div class=code&gt;&lt;br /&gt;mkdir -p ~/.vim/tags&lt;br /&gt;ctags -R -f ~/.vim/tags/rbtags /usr/lib/ruby&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;h3&gt;Ctags Java libraries&lt;/h3&gt;&lt;br /&gt;&lt;div class=code&gt;&lt;br /&gt;# For the java tags to work you need to install java source package. &lt;br /&gt;# In Kubuntu/Ubuntu follow these instructions:&lt;br /&gt;mkdir -p ~/.vim/tags&lt;br /&gt;sudo aptitude install sun-java6-source&lt;br /&gt;sudo mkdir -p /usr/lib/jvm/java-6-sun/src&lt;br /&gt;sudo unzip -d /usr/lib/jvm/java-6-sun/ /usr/lib/jvm/java-6-sun/src.zip&lt;br /&gt;ctags -R -f ~/.vim/tags/javatags /usr/lib/jvm/java-6-sun/src&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;At this you should be able to create tags for all the libraries you use in your projects. Simply get the source code or development packages of the library and run ctags on the folder that contains the source code and save the tags in a file you can access.&lt;br /&gt;&lt;br /&gt;TODO: I really need to research what are the best ctags flags for each language in order to generate the most information possible per tag.&lt;br /&gt;&lt;br /&gt;&lt;h2&gt;Updating your system wide ctags&lt;/h2&gt;&lt;br /&gt;&lt;br /&gt;Here we have three options:&lt;br /&gt;&lt;ul&gt;&lt;br /&gt;&lt;li&gt;Update your system/library tags manually each time you upgrade them&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Use a cron job to update them every certain period of time (e.g. once a week).&lt;li&gt;&lt;br /&gt;&lt;li&gt;Use &lt;a href="http://inotify.aiken.cz/?section=incron&amp;page=about&amp;lang=en"&gt;incrontab&lt;/a&gt; to monitor changes in the system/library folders and automatically update the tags every time these folders change.&lt;/li&gt;&lt;br /&gt;&lt;/ul&gt;&lt;br /&gt;&lt;br /&gt;Personally I use the cron job method and for some libraries that I update often (e.g. libavcodec from subversion) I manually generate the tags soon after I update the library.&lt;br /&gt;&lt;br /&gt;I found about &lt;a href="http://inotify.aiken.cz/?section=incron&amp;page=about&amp;lang=en"&gt;incrontab&lt;/a&gt; just recently and I think will be the best way to update system wide tags. It behaves mostly like crontab but instead of triggering actions based on time periods it triggers by file system events like file change, move, save, etc. It should be easy to monitor the folders containing the libraries of interest and regenerate the tags for each library based on change events in the folder contents. The tricky part would be to determine what file system event we must listen to decide if we should regenerate or not the tags.&lt;br /&gt;&lt;br /&gt;&lt;h2&gt;Generating ctags for your own libraries/projects&lt;/h2&gt;&lt;br /&gt;&lt;br /&gt;Now we need to generate tags for projects/libraries we are developing at the moment. These projects are constantly changing so we need to update them as soon as possible.&lt;br /&gt;&lt;br /&gt;This is a common problem that lot's of people solve in different ways. See for example these links:&lt;br /&gt;&lt;ul&gt;&lt;br /&gt;&lt;li&gt;&lt;a href="http://stackoverflow.com/questions/155449/vim-auto-generate-ctags"&gt;Vim auto-generate ctags&lt;/a&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;&lt;a href="http://stackoverflow.com/questions/563616/vimctags-tips-and-tricks"&gt;Vim+ctags tips and tricks&lt;/a&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;&lt;a href="http://www.vim.org/scripts/script.php?script_id=1535"&gt;TagsParser : Automatic tagfile updating and tag viewer&lt;/a&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;&lt;a href="http://linux.byexamples.com/archives/385/vim-with-ctags-for-multi-level-directory-hierarchy/"&gt;vim with ctags for multi-level directory hierarchy&lt;/a&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;&lt;a href="http://vim.wikia.com/wiki/Tags_generation_for_current_file"&gt;http://vim.wikia.com/wiki/Tags_generation_for_current_file&lt;/a&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;&lt;a href="http://vim.wikia.com/wiki/Auto_tags_by_project.vim"&gt;Auto tags by project.vim&lt;/a&gt;&lt;/li&gt;&lt;br /&gt;&lt;/ul&gt;&lt;br /&gt;&lt;br /&gt;Most methods I found do the same more or less: they set some auto commands to autogenerate tag files when a file is edited and set the search path in a way it can find the generated tags.&lt;br /&gt;&lt;br /&gt;I used to have some autocommands in vim to generate tags every time I modified a file in a project. Unfortunately I never figured out how to generate a single tags file per project/library. I always ended with a global tag file for all projects or a single tag file per folder. &lt;br /&gt;&lt;br /&gt;Another methods worked by adding tags generation commands to the build system so the tags get generated when we recompile the project (e.g. Makefile, Ant, CMake) and others simply created scripts per project and executed them manually from the project root directory or within vim using a key map.&lt;br /&gt;&lt;br /&gt;Since I use the Project.vim plugin it is natural for me to use it to generate the tags files as it is done &lt;a href="http://vim.wikia.com/wiki/Auto_tags_by_project.vim"&gt;here&lt;/a&gt;. My method is a lot different in that I do not use a Makefile to generate the tags and I only re-generate them when a file has been edited, not every time we open a file.&lt;br /&gt;&lt;br /&gt;&lt;h2&gt;Auto-generating Ctags Using the Project.vim plugin&lt;/h2&gt;&lt;br /&gt;&lt;br /&gt;Anyone that has used the Project.vim plugin is familiar with the snippet shown below:&lt;br /&gt;&lt;br /&gt;&lt;div class="code"&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt; myproj=&amp;lt;src-path&amp;gt; in=in.vim out=out.vim CD=&amp;lt;src-path&amp;gt; {&lt;br /&gt;   CMakeLists.txt&lt;br /&gt;   in.vim&lt;br /&gt;   out.vim&lt;br /&gt;   include----------------- &lt;br /&gt;   src---------------------&lt;br /&gt;   test--------------------&lt;br /&gt;   tools-------------------&lt;br /&gt; }&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;This corresponds to a project entry called "myproj" with root directory set to "src-path". Here the important parts are the "in", "out" and "CD" parameters.&lt;br /&gt;&lt;br /&gt;The "CD" parameter makes sure that you are at the project root directory when editing a file from that project. This is useful to have a single tags file per project.&lt;br /&gt;&lt;br /&gt;The "in" and "out" parameters are simple vim scripts. The "in" script is executed when opening a file from the project and the "out" script when leaving the file. In these scripts is where I set/unset the autocommands that take care of generating the tags files per project.&lt;br /&gt;&lt;br /&gt;Every time I create a new project using the Project.vim plugin I also create these in.vim and out.vim scripts:&lt;br /&gt;&lt;br /&gt;&lt;h4&gt;in.vim&lt;/h4&gt;&lt;br /&gt;&lt;div class="code"&gt;&lt;br /&gt;&lt;font face="monospace"&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;span style="background-color: #121212"&gt;&lt;font color="#87d787"&gt;&amp;quot; let ctags_cmd='/usr/local/bin/exctags'&amp;nbsp;&amp;nbsp; &amp;quot; Use this one in FreeBSD&lt;/font&gt;&lt;/span&gt;&lt;br&gt;&lt;br /&gt;&lt;span style="background-color: #121212"&gt;&lt;font color="#ffff00"&gt;&lt;b&gt;let&lt;/b&gt;&lt;/font&gt;&lt;/span&gt;&amp;nbsp;ctags_cmd&lt;span style="background-color: #121212"&gt;&lt;font color="#ffff00"&gt;&lt;b&gt;=&lt;/b&gt;&lt;/font&gt;&lt;/span&gt;&lt;span style="background-color: #121212"&gt;&lt;font color="#ff8700"&gt;'/usr/bin/ctags'&lt;/font&gt;&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="background-color: #121212"&gt;&lt;font color="#87d787"&gt;&amp;quot; Use this one in Linux&lt;/font&gt;&lt;/span&gt;&lt;br&gt;&lt;br /&gt;&lt;span style="background-color: #121212"&gt;&lt;font color="#ffff00"&gt;&lt;b&gt;let&lt;/b&gt;&lt;/font&gt;&lt;/span&gt;&amp;nbsp;proj_path&amp;nbsp;&lt;span style="background-color: #121212"&gt;&lt;font color="#ffff00"&gt;&lt;b&gt;=&lt;/b&gt;&lt;/font&gt;&lt;/span&gt;&amp;nbsp;&lt;span style="background-color: #121212"&gt;&lt;font color="#8787ff"&gt;escape&lt;/font&gt;&lt;/span&gt;&lt;span style="background-color: #121212"&gt;&lt;font color="#00ffff"&gt;(&lt;/font&gt;&lt;/span&gt;&lt;span style="background-color: #121212"&gt;&lt;font color="#8787ff"&gt;getcwd&lt;/font&gt;&lt;/span&gt;&lt;span style="background-color: #121212"&gt;&lt;font color="#00ffff"&gt;()&lt;/font&gt;&lt;/span&gt;, &lt;span style="background-color: #121212"&gt;&lt;font color="#ff8700"&gt;' '&lt;/font&gt;&lt;/span&gt;&lt;span style="background-color: #121212"&gt;&lt;font color="#00ffff"&gt;)&lt;/font&gt;&lt;/span&gt;&lt;br&gt;&lt;br /&gt;&lt;span style="background-color: #121212"&gt;&lt;font color="#ffff00"&gt;&lt;b&gt;let&lt;/b&gt;&lt;/font&gt;&lt;/span&gt;&amp;nbsp;_ctagargs_&amp;nbsp;&lt;span style="background-color: #121212"&gt;&lt;font color="#ffff00"&gt;&lt;b&gt;=&lt;/b&gt;&lt;/font&gt;&lt;/span&gt;&amp;nbsp;&lt;span style="background-color: #121212"&gt;&lt;font color="#ff8700"&gt;&amp;quot; --fields=+iaS --extra=+q -R &amp;quot;&lt;/font&gt;&lt;/span&gt;&lt;br&gt;&lt;br /&gt;&lt;span style="background-color: #121212"&gt;&lt;font color="#ffff00"&gt;&lt;b&gt;let&lt;/b&gt;&lt;/font&gt;&lt;/span&gt;&amp;nbsp;_ctag_&amp;nbsp;&lt;span style="background-color: #121212"&gt;&lt;font color="#ffff00"&gt;&lt;b&gt;=&lt;/b&gt;&lt;/font&gt;&lt;/span&gt;&amp;nbsp;ctags_cmd&amp;nbsp;&lt;span style="background-color: #121212"&gt;&lt;font color="#ffff00"&gt;&lt;b&gt;.&lt;/b&gt;&lt;/font&gt;&lt;/span&gt;&amp;nbsp;_ctagargs_&amp;nbsp;&lt;span style="background-color: #121212"&gt;&lt;font color="#ffff00"&gt;&lt;b&gt;.&lt;/b&gt;&lt;/font&gt;&lt;/span&gt;&amp;nbsp;&lt;span style="background-color: #121212"&gt;&lt;font color="#ff8700"&gt;&amp;quot; -f &amp;quot;&lt;/font&gt;&lt;/span&gt;&amp;nbsp;&lt;span style="background-color: #121212"&gt;&lt;font color="#ffff00"&gt;&lt;b&gt;.&lt;/b&gt;&lt;/font&gt;&lt;/span&gt;&amp;nbsp;proj_path&amp;nbsp;&lt;span style="background-color: #121212"&gt;&lt;font color="#ffff00"&gt;&lt;b&gt;.&lt;/b&gt;&lt;/font&gt;&lt;/span&gt;&amp;nbsp;&lt;span style="background-color: #121212"&gt;&lt;font color="#ff8700"&gt;&amp;quot;/.tags &amp;quot;&lt;/font&gt;&lt;/span&gt;&amp;nbsp;&lt;span style="background-color: #121212"&gt;&lt;font color="#ffff00"&gt;&lt;b&gt;.&lt;/b&gt;&lt;/font&gt;&lt;/span&gt;&amp;nbsp;proj_path&lt;br&gt;&lt;br /&gt;&lt;span style="background-color: #121212"&gt;&lt;font color="#ffff00"&gt;&lt;b&gt;au&lt;/b&gt;&lt;/font&gt;&lt;/span&gt;&amp;nbsp;&lt;span style="background-color: #121212"&gt;&lt;font color="#ff5f87"&gt;BufWritePost&lt;/font&gt;&lt;/span&gt;&amp;nbsp;&amp;lt;buffer&amp;gt;&amp;nbsp;&lt;span style="background-color: #121212"&gt;&lt;font color="#ffff00"&gt;&lt;b&gt;call&lt;/b&gt;&lt;/font&gt;&lt;/span&gt;&amp;nbsp;&lt;span style="background-color: #121212"&gt;&lt;font color="#8787ff"&gt;system&lt;/font&gt;&lt;/span&gt;&lt;span style="background-color: #121212"&gt;&lt;font color="#00ffff"&gt;(&lt;/font&gt;&lt;/span&gt;_ctag_&lt;span style="background-color: #121212"&gt;&lt;font color="#00ffff"&gt;)&lt;/font&gt;&lt;/span&gt;&lt;br&gt;&lt;br /&gt;&lt;/font&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;h4&gt;out.vim&lt;/h4&gt;&lt;br /&gt;&lt;div class="code"&gt;&lt;br /&gt;&lt;font face="monospace"&gt;&lt;br /&gt;&lt;span style="background-color: #121212"&gt;&lt;font color="#ffff00"&gt;&lt;b&gt;au&lt;/b&gt;&lt;/font&gt;&lt;/span&gt;! * &lt;span style="background-color: #121212"&gt;&lt;font color="#ffff00"&gt;&lt;b&gt;&amp;lt;&lt;/b&gt;&lt;/font&gt;&lt;/span&gt;&lt;span style="background-color: #121212"&gt;&lt;font color="#ffff00"&gt;&lt;b&gt;buffer&lt;/b&gt;&lt;/font&gt;&lt;/span&gt;&lt;span style="background-color: #121212"&gt;&lt;font color="#ffff00"&gt;&lt;b&gt;&amp;gt;&lt;/b&gt;&lt;/font&gt;&lt;/span&gt;&lt;br&gt;&lt;br /&gt;&lt;/font&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;Now every time you open a file from a project an autocommand will be created for that file that will regenerate tags for the whole project every time the file is saved. The generated tags file is always in the root directory of the project. You may prefer to use the "--append" switch of ctags to generate tags for the current file only but I personally prefer regenerating the tags of the whole project every time.&lt;br /&gt;&lt;br /&gt;When you leave the file the autocommand is removed in the out.vim script. If we do not remove the autocommand, it will be created every time we enter the file that results in a lot of autocommands around. I am not really sure if this can cause problems but is better go on the safe side.&lt;br /&gt;&lt;br /&gt;Now the last piece of the puzzle is how to tell Vim where to search for the tags.&lt;br /&gt;&lt;br /&gt;&lt;h2&gt;Tell Vim where to search for tags&lt;/h2&gt;&lt;br /&gt;&lt;br /&gt;To find the per project tags we can simply add this to our vimrc file:&lt;br /&gt;&lt;div class="code"&gt;&lt;br /&gt;&lt;font face="monospace"&gt;&lt;br /&gt;&lt;span style="background-color: #121212"&gt;&lt;font color="#ffff00"&gt;&lt;b&gt;set&lt;/b&gt;&lt;/font&gt;&lt;/span&gt;&amp;nbsp;&lt;span style="background-color: #121212"&gt;&lt;font color="#5fff5f"&gt;tags&lt;/font&gt;&lt;/span&gt;=./.tags;${HOME}&lt;br&gt;&lt;br /&gt;&lt;/font&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;This simple command tells vim to search tag files from the current directory backwards up to our $HOME directory. Since we are sure that we are always at the projects root directory where the tags file is automatically generated we can be sure that vim will always find the tag we are looking for.&lt;br /&gt;&lt;br /&gt;There are some system wide tags that we want to always load depending on the language we are developing. For example when I develop in C I would like to have the kernel system calls tag file (that we generated before) or when developing in Ruby/Java I expect to have these languages core tags loaded too.&lt;br /&gt;&lt;br /&gt;To do this I load all system wide libraries based on filetype using these commands in my vimrc file:&lt;br /&gt;&lt;div class="code"&gt;&lt;br /&gt;&lt;font face="monospace"&gt;&lt;br /&gt;&lt;span style="background-color: #121212"&gt;&lt;font color="#ffff00"&gt;&lt;b&gt;au&lt;/b&gt;&lt;/font&gt;&lt;/span&gt;&amp;nbsp;&lt;span style="background-color: #121212"&gt;&lt;font color="#ff5f87"&gt;BufRead&lt;/font&gt;&lt;/span&gt;,&lt;span style="background-color: #121212"&gt;&lt;font color="#ff5f87"&gt;BufNewFile&lt;/font&gt;&lt;/span&gt;&amp;nbsp;*.rb&amp;nbsp;&lt;span style="background-color: #121212"&gt;&lt;font color="#ffff00"&gt;&lt;b&gt;setlocal&lt;/b&gt;&lt;/font&gt;&lt;/span&gt;&amp;nbsp;&lt;span style="background-color: #121212"&gt;&lt;font color="#5fff5f"&gt;tags&lt;/font&gt;&lt;/span&gt;+=~/.vim/tags/rbtags&lt;br&gt;&lt;br /&gt;&lt;span style="background-color: #121212"&gt;&lt;font color="#ffff00"&gt;&lt;b&gt;au&lt;/b&gt;&lt;/font&gt;&lt;/span&gt;&amp;nbsp;&lt;span style="background-color: #121212"&gt;&lt;font color="#ff5f87"&gt;BufRead&lt;/font&gt;&lt;/span&gt;,&lt;span style="background-color: #121212"&gt;&lt;font color="#ff5f87"&gt;BufNewFile&lt;/font&gt;&lt;/span&gt;&amp;nbsp;*.cpp,*.h,*.c&amp;nbsp;&lt;span style="background-color: #121212"&gt;&lt;font color="#ffff00"&gt;&lt;b&gt;setlocal&lt;/b&gt;&lt;/font&gt;&lt;/span&gt;&amp;nbsp;&lt;span style="background-color: #121212"&gt;&lt;font color="#5fff5f"&gt;tags&lt;/font&gt;&lt;/span&gt;+=~/.vim/tags/kerneltags&lt;br&gt;&lt;br /&gt;&lt;span style="background-color: #121212"&gt;&lt;font color="#ffff00"&gt;&lt;b&gt;au&lt;/b&gt;&lt;/font&gt;&lt;/span&gt;&amp;nbsp;&lt;span style="background-color: #121212"&gt;&lt;font color="#ff5f87"&gt;BufRead&lt;/font&gt;&lt;/span&gt;,&lt;span style="background-color: #121212"&gt;&lt;font color="#ff5f87"&gt;BufNewFile&lt;/font&gt;&lt;/span&gt;&amp;nbsp;*.rl,*.def&amp;nbsp;&lt;span style="background-color: #121212"&gt;&lt;font color="#ffff00"&gt;&lt;b&gt;setlocal&lt;/b&gt;&lt;/font&gt;&lt;/span&gt;&amp;nbsp;&lt;span style="background-color: #121212"&gt;&lt;font color="#5fff5f"&gt;tags&lt;/font&gt;&lt;/span&gt;+=~/.vim/tags/kerneltags&lt;br&gt;&lt;br /&gt;&lt;span style="background-color: #121212"&gt;&lt;font color="#ffff00"&gt;&lt;b&gt;au&lt;/b&gt;&lt;/font&gt;&lt;/span&gt;&amp;nbsp;&lt;span style="background-color: #121212"&gt;&lt;font color="#ff5f87"&gt;BufRead&lt;/font&gt;&lt;/span&gt;,&lt;span style="background-color: #121212"&gt;&lt;font color="#ff5f87"&gt;BufNewFile&lt;/font&gt;&lt;/span&gt;&amp;nbsp;*.py&amp;nbsp;&lt;span style="background-color: #121212"&gt;&lt;font color="#ffff00"&gt;&lt;b&gt;setlocal&lt;/b&gt;&lt;/font&gt;&lt;/span&gt;&amp;nbsp;&lt;span style="background-color: #121212"&gt;&lt;font color="#5fff5f"&gt;tags&lt;/font&gt;&lt;/span&gt;+=~/.vim/tags/pytags&lt;br&gt;&lt;br /&gt;&lt;span style="background-color: #121212"&gt;&lt;font color="#ffff00"&gt;&lt;b&gt;au&lt;/b&gt;&lt;/font&gt;&lt;/span&gt;&amp;nbsp;&lt;span style="background-color: #121212"&gt;&lt;font color="#ff5f87"&gt;BufRead&lt;/font&gt;&lt;/span&gt;,&lt;span style="background-color: #121212"&gt;&lt;font color="#ff5f87"&gt;BufNewFile&lt;/font&gt;&lt;/span&gt;&amp;nbsp;*.java&amp;nbsp;&lt;span style="background-color: #121212"&gt;&lt;font color="#ffff00"&gt;&lt;b&gt;setlocal&lt;/b&gt;&lt;/font&gt;&lt;/span&gt;&amp;nbsp;&lt;span style="background-color: #121212"&gt;&lt;font color="#5fff5f"&gt;tags&lt;/font&gt;&lt;/span&gt;+=~/.vim/tags/javatags&lt;br&gt;&lt;br /&gt;&lt;/font&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;What these commands do is to load the system wide tag files we generated before depending on the file type. For example when editing a ruby file it loads the Ruby tags file.&lt;br /&gt;&lt;br /&gt;We must note that the commands only apply to the current file being edited (e.g. setlocal), not all the files in the project and that we are adding the tags file not replacing the current one (e.g. += ).&lt;br /&gt;&lt;br /&gt;Finally how can we add other tag files to the project that are not from the project itself and not system wide?. For example my project requires external libraries like libavcodec and SDL so it would be nice to query the function and struct definitions of these libraries.&lt;br /&gt;&lt;br /&gt;To do this I use the "in.vim" script of the Project.vim plugin like:&lt;br /&gt;&lt;br /&gt;&lt;div class="code"&gt;&lt;br /&gt;&lt;font face="monospace"&gt;&lt;br /&gt;&lt;span style="background-color: #121212"&gt;&lt;font color="#87d787"&gt;&amp;quot; let ctags_cmd='/usr/local/bin/exctags'&amp;nbsp;&amp;nbsp; &amp;quot; Use this one in FreeBSD&lt;/font&gt;&lt;/span&gt;&lt;br&gt;&lt;br /&gt;&lt;span style="background-color: #121212"&gt;&lt;font color="#ffff00"&gt;&lt;b&gt;let&lt;/b&gt;&lt;/font&gt;&lt;/span&gt;&amp;nbsp;ctags_cmd&lt;span style="background-color: #121212"&gt;&lt;font color="#ffff00"&gt;&lt;b&gt;=&lt;/b&gt;&lt;/font&gt;&lt;/span&gt;&lt;span style="background-color: #121212"&gt;&lt;font color="#ff8700"&gt;'/usr/bin/ctags'&lt;/font&gt;&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="background-color: #121212"&gt;&lt;font color="#87d787"&gt;&amp;quot; Use this one in Linux&lt;/font&gt;&lt;/span&gt;&lt;br&gt;&lt;br /&gt;&lt;span style="background-color: #121212"&gt;&lt;font color="#ffff00"&gt;&lt;b&gt;let&lt;/b&gt;&lt;/font&gt;&lt;/span&gt;&amp;nbsp;proj_path&amp;nbsp;&lt;span style="background-color: #121212"&gt;&lt;font color="#ffff00"&gt;&lt;b&gt;=&lt;/b&gt;&lt;/font&gt;&lt;/span&gt;&amp;nbsp;&lt;span style="background-color: #121212"&gt;&lt;font color="#8787ff"&gt;escape&lt;/font&gt;&lt;/span&gt;&lt;span style="background-color: #121212"&gt;&lt;font color="#00ffff"&gt;(&lt;/font&gt;&lt;/span&gt;&lt;span style="background-color: #121212"&gt;&lt;font color="#8787ff"&gt;getcwd&lt;/font&gt;&lt;/span&gt;&lt;span style="background-color: #121212"&gt;&lt;font color="#00ffff"&gt;()&lt;/font&gt;&lt;/span&gt;, &lt;span style="background-color: #121212"&gt;&lt;font color="#ff8700"&gt;' '&lt;/font&gt;&lt;/span&gt;&lt;span style="background-color: #121212"&gt;&lt;font color="#00ffff"&gt;)&lt;/font&gt;&lt;/span&gt;&lt;br&gt;&lt;br /&gt;&lt;span style="background-color: #121212"&gt;&lt;font color="#ffff00"&gt;&lt;b&gt;let&lt;/b&gt;&lt;/font&gt;&lt;/span&gt;&amp;nbsp;_ctagargs_&amp;nbsp;&lt;span style="background-color: #121212"&gt;&lt;font color="#ffff00"&gt;&lt;b&gt;=&lt;/b&gt;&lt;/font&gt;&lt;/span&gt;&amp;nbsp;&lt;span style="background-color: #121212"&gt;&lt;font color="#ff8700"&gt;&amp;quot; --c++-kinds=+p --fields=+iaS --extra=+q -R &amp;quot;&lt;/font&gt;&lt;/span&gt;&lt;br&gt;&lt;br /&gt;&lt;span style="background-color: #121212"&gt;&lt;font color="#ffff00"&gt;&lt;b&gt;let&lt;/b&gt;&lt;/font&gt;&lt;/span&gt;&amp;nbsp;_ctag_&amp;nbsp;&lt;span style="background-color: #121212"&gt;&lt;font color="#ffff00"&gt;&lt;b&gt;=&lt;/b&gt;&lt;/font&gt;&lt;/span&gt;&amp;nbsp;ctags_cmd&amp;nbsp;&lt;span style="background-color: #121212"&gt;&lt;font color="#ffff00"&gt;&lt;b&gt;.&lt;/b&gt;&lt;/font&gt;&lt;/span&gt;&amp;nbsp;_ctagargs_&amp;nbsp;&lt;span style="background-color: #121212"&gt;&lt;font color="#ffff00"&gt;&lt;b&gt;.&lt;/b&gt;&lt;/font&gt;&lt;/span&gt;&amp;nbsp;&lt;span style="background-color: #121212"&gt;&lt;font color="#ff8700"&gt;&amp;quot; -f &amp;quot;&lt;/font&gt;&lt;/span&gt;&amp;nbsp;&lt;span style="background-color: #121212"&gt;&lt;font color="#ffff00"&gt;&lt;b&gt;.&lt;/b&gt;&lt;/font&gt;&lt;/span&gt;&amp;nbsp;proj_path&amp;nbsp;&lt;span style="background-color: #121212"&gt;&lt;font color="#ffff00"&gt;&lt;b&gt;.&lt;/b&gt;&lt;/font&gt;&lt;/span&gt;&amp;nbsp;&lt;span style="background-color: #121212"&gt;&lt;font color="#ff8700"&gt;&amp;quot;/.tags &amp;quot;&lt;/font&gt;&lt;/span&gt;&amp;nbsp;&lt;span style="background-color: #121212"&gt;&lt;font color="#ffff00"&gt;&lt;b&gt;.&lt;/b&gt;&lt;/font&gt;&lt;/span&gt;&amp;nbsp;proj_path&lt;br&gt;&lt;br /&gt;&lt;span style="background-color: #121212"&gt;&lt;font color="#ffff00"&gt;&lt;b&gt;au&lt;/b&gt;&lt;/font&gt;&lt;/span&gt;&amp;nbsp;&lt;span style="background-color: #121212"&gt;&lt;font color="#ff5f87"&gt;BufWritePost&lt;/font&gt;&lt;/span&gt;&amp;nbsp;&amp;lt;buffer&amp;gt;&amp;nbsp;&lt;span style="background-color: #121212"&gt;&lt;font color="#ffff00"&gt;&lt;b&gt;call&lt;/b&gt;&lt;/font&gt;&lt;/span&gt;&amp;nbsp;&lt;span style="background-color: #121212"&gt;&lt;font color="#8787ff"&gt;system&lt;/font&gt;&lt;/span&gt;&lt;span style="background-color: #121212"&gt;&lt;font color="#00ffff"&gt;(&lt;/font&gt;&lt;/span&gt;_ctag_&lt;span style="background-color: #121212"&gt;&lt;font color="#00ffff"&gt;)&lt;/font&gt;&lt;/span&gt;&lt;br&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;span style="background-color: #121212"&gt;&lt;font color="#87d787"&gt;&amp;quot; Add external library tag files&lt;/font&gt;&lt;/span&gt;&lt;br&gt;&lt;br /&gt;&lt;span style="background-color: #121212"&gt;&lt;font color="#ffff00"&gt;&lt;b&gt;setlocal&lt;/b&gt;&lt;/font&gt;&lt;/span&gt;&amp;nbsp;&lt;span style="background-color: #121212"&gt;&lt;font color="#5fff5f"&gt;tags&lt;/font&gt;&lt;/span&gt;+=~/.vim/tags/sdltags&lt;br&gt;&lt;br /&gt;&lt;span style="background-color: #121212"&gt;&lt;font color="#ffff00"&gt;&lt;b&gt;setlocal&lt;/b&gt;&lt;/font&gt;&lt;/span&gt;&amp;nbsp;&lt;span style="background-color: #121212"&gt;&lt;font color="#5fff5f"&gt;tags&lt;/font&gt;&lt;/span&gt;+=~/.vim/tags/ffmpegtags&lt;br&gt;&lt;br /&gt;&lt;/font&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;This is exactly the same "in.vim" script as above with two added lines that include the libavcodec (FFMpeg) and SDL library tags files to the search path of vim for all files in the project. These files were of course generated before the same way we created the system wide tag files and updated via a cron job.&lt;br /&gt;&lt;br /&gt;Once you setup this once you don't need to worry about this anymore until you reinstall your computer. The system wide libraries will be always updated if you configured the corresponding cron jobs and once a project is created it will always have the tags files updated and ready to query.&lt;br /&gt;&lt;br /&gt;&lt;h2&gt;Setting up the TagList Plugin&lt;/h2&gt;&lt;br /&gt;&lt;br /&gt;No blog post about Vim+Ctags is complete without the mighty TagList plugin. To install this plugin go to &lt;a href="http://vim-taglist.sourceforge.net/"&gt;http://vim-taglist.sourceforge.net/&lt;/a&gt; and download the taglist_45.zip file. Then add it to your vim installation using the command:&lt;br /&gt;&lt;div class="code"&gt;&lt;br /&gt;unzip -d ~/.vim taglist_45.zip&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;Then add these commands to your vimrc file:&lt;br /&gt;&lt;div class="code"&gt;&lt;br /&gt;&lt;font face="monospace"&gt;&lt;br /&gt;&lt;font color="#008080"&gt;&amp;quot; let Tlist_Ctags_Cmd='/usr/local/bin/exctags'&amp;nbsp;&amp;nbsp; &amp;quot; Use this one in FreeBSD&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#ffff00"&gt;let&lt;/font&gt;&amp;nbsp;Tlist_Ctags_Cmd&lt;font color="#00ff00"&gt;=&lt;/font&gt;&lt;font color="#ffff00"&gt;'/usr/bin/ctags'&lt;/font&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;font color="#008080"&gt;&amp;quot; Use this one in Linux&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#ffff00"&gt;let&lt;/font&gt;&amp;nbsp;Tlist_Auto_Open&lt;font color="#00ff00"&gt;=&lt;/font&gt;&lt;font color="#87ffaf"&gt;0&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#ffff00"&gt;let&lt;/font&gt;&amp;nbsp;Tlist_Auto_Update&lt;font color="#00ff00"&gt;=&lt;/font&gt;&lt;font color="#87ffaf"&gt;1&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#ffff00"&gt;let&lt;/font&gt;&amp;nbsp;Tlist_Use_Horiz_Window&amp;nbsp;&lt;font color="#00ff00"&gt;=&lt;/font&gt;&amp;nbsp;&lt;font color="#87ffaf"&gt;0&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#008080"&gt;&amp;quot;let Tlist_Inc_Winwidth=0&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#008080"&gt;&amp;quot;let Tlist_Show_One_File=1&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#ffff00"&gt;let&lt;/font&gt;&amp;nbsp;Tlist_Exist_OnlyWindow&lt;font color="#00ff00"&gt;=&lt;/font&gt;&lt;font color="#87ffaf"&gt;1&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#ffff00"&gt;let&lt;/font&gt;&amp;nbsp;Tlist_Use_Right_Window&amp;nbsp;&lt;font color="#00ff00"&gt;=&lt;/font&gt;&amp;nbsp;&lt;font color="#87ffaf"&gt;1&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#ffff00"&gt;let&lt;/font&gt;&amp;nbsp;Tlist_Sort_Type&lt;font color="#00ff00"&gt;=&lt;/font&gt;&lt;font color="#ffff00"&gt;&amp;quot;name&amp;quot;&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#ffff00"&gt;let&lt;/font&gt;&amp;nbsp;Tlist_Display_Prototype&lt;font color="#00ff00"&gt;=&lt;/font&gt;&lt;font color="#87ffaf"&gt;0&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#ffff00"&gt;let&lt;/font&gt;&amp;nbsp;Tlist_Compact_Format&lt;font color="#00ff00"&gt;=&lt;/font&gt;&lt;font color="#87ffaf"&gt;1&lt;/font&gt;&amp;nbsp;&lt;font color="#008080"&gt;&amp;quot; Compact?&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#ffff00"&gt;let&lt;/font&gt;&amp;nbsp;Tlist_GainFocus_On_ToggleOpen&lt;font color="#00ff00"&gt;=&lt;/font&gt;&lt;font color="#87ffaf"&gt;1&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#ffff00"&gt;let&lt;/font&gt;&amp;nbsp;Tlist_Display_Tag_Scope&lt;font color="#00ff00"&gt;=&lt;/font&gt;&lt;font color="#87ffaf"&gt;1&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#ffff00"&gt;let&lt;/font&gt;&amp;nbsp;Tlist_Close_On_Select&lt;font color="#00ff00"&gt;=&lt;/font&gt;&lt;font color="#87ffaf"&gt;1&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#ffff00"&gt;let&lt;/font&gt;&amp;nbsp;Tlist_Enable_Fold_Column&lt;font color="#00ff00"&gt;=&lt;/font&gt;&lt;font color="#87ffaf"&gt;1&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#008080"&gt;&amp;quot;let TList_WinWidth=25&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#008080"&gt;&amp;quot; Map a F8 to the TlistToggle command for easy tags list access&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#ffff00"&gt;nnoremap&lt;/font&gt;&amp;nbsp;&lt;font color="#00ff00"&gt;&amp;lt;&lt;/font&gt;&lt;font color="#ff6060"&gt;silent&lt;/font&gt;&lt;font color="#00ff00"&gt;&amp;gt;&lt;/font&gt;&amp;nbsp;&lt;font color="#00ff00"&gt;&amp;lt;&lt;/font&gt;&lt;font color="#ff6060"&gt;F8&lt;/font&gt;&lt;font color="#00ff00"&gt;&amp;gt;&lt;/font&gt;&amp;nbsp;&lt;font color="#00ff00"&gt;&amp;lt;&lt;/font&gt;&lt;font color="#ff6060"&gt;ESC&lt;/font&gt;&lt;font color="#00ff00"&gt;&amp;gt;&lt;/font&gt;:TlistToggle&lt;font color="#00ff00"&gt;&amp;lt;&lt;/font&gt;&lt;font color="#ff6060"&gt;CR&lt;/font&gt;&lt;font color="#00ff00"&gt;&amp;gt;&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;/font&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;Of course I recommend you to read the help file and set the configuration as it fits you better. With my configuration you can press &lt;F8&gt; to open the tags list window and when you press &lt;Enter&gt; on a tag the windows automatically closes. This is specially useful on small screen laptops to allow more code visible all the time.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/34829202-9130122878161532579?l=piao-tech.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://piao-tech.blogspot.com/feeds/9130122878161532579/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://piao-tech.blogspot.com/2008/10/make-vim-and-ctag-play-nice-together.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/34829202/posts/default/9130122878161532579'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/34829202/posts/default/9130122878161532579'/><link rel='alternate' type='text/html' href='http://piao-tech.blogspot.com/2008/10/make-vim-and-ctag-play-nice-together.html' title='Make Vim and Ctag play nice together'/><author><name>龍神</name><uri>http://www.blogger.com/profile/16648963337079496096</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_99Fzui5MBLY/SzIJTI943DI/AAAAAAAAAN4/fy1ezb0HP8c/s72-c/ctags.png' height='72' width='72'/><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-34829202.post-6857098958218005916</id><published>2008-10-08T14:43:00.009+09:00</published><updated>2009-07-13T00:45:44.970+09:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Tips'/><category scheme='http://www.blogger.com/atom/ns#' term='Kubuntu'/><title type='text'>Basic .vimrc file</title><content type='html'>&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_99Fzui5MBLY/SO3gwQSlmfI/AAAAAAAAAMY/jmZy0aQprn0/s1600-h/vimsnap.png"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;" src="http://2.bp.blogspot.com/_99Fzui5MBLY/SO3gwQSlmfI/AAAAAAAAAMY/jmZy0aQprn0/s320/vimsnap.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5255103459822508530" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;My first Vim configuration files: .vimrc, plugins, color schemes, etc were very small and modest. It's been eight years since I started using Vim and these configuration files have morphed, evolved, grown and recently shrink in too many ways, more than I can remember, and every time I check www.vim.org I find new ways I would like my Vim to evolve even further.&lt;br /&gt;&lt;br /&gt;Here is the simplest version of my .vimrc file with no ctags or desktop integration as these topics require a separate post to explain. Most of the options here can be understood directly from Vim help files and by the comments in the file itself.&lt;br /&gt;&lt;br /&gt;If you would like to use this file make sure to copy it in your home directory and read the comments as to get full functionality.&lt;br /&gt;&lt;br /&gt;For comparison see the default install and my older configuration screenshot at the end of the post and compare it with my current configuration screenshot at the top of this post.&lt;br /&gt;&lt;br /&gt;&lt;div class="code"&gt;&lt;br /&gt;&lt;font face="monospace"&gt;&lt;br /&gt;&lt;font color="#00ffff"&gt;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#00ffff"&gt;&amp;quot;&amp;quot; General Vim Settings&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#00ffff"&gt;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#00ffff"&gt;&amp;quot;&amp;nbsp;&amp;nbsp; In Kubuntu/Ubuntu make sure you have a complete vim install&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#00ffff"&gt;&amp;quot;&amp;nbsp;&amp;nbsp; i.e.&amp;nbsp;&amp;nbsp;sudo aptitude install vim-ruby vim-scripts vim-common&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#00ffff"&gt;&amp;quot;&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#00ffff"&gt;&amp;quot; Disable compatibility with vi&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#ffff00"&gt;set&lt;/font&gt;&amp;nbsp;&lt;font color="#5fd7ff"&gt;nocompatible&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#00ffff"&gt;&amp;quot; Use the Unix file format&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#ffff00"&gt;set&lt;/font&gt;&amp;nbsp;&lt;font color="#5fd7ff"&gt;fileformats&lt;/font&gt;=unix&lt;font color="#ffff00"&gt;,&lt;/font&gt;dos&lt;br&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#00ffff"&gt;&amp;quot; Display line number in front of each line in the left margin.&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#ffff00"&gt;set&lt;/font&gt;&amp;nbsp;&lt;font color="#5fd7ff"&gt;number&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#00ffff"&gt;&amp;quot; I keep my own backups and all those files ending in '~' are&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#00ffff"&gt;&amp;quot; anoying.&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#ffff00"&gt;set&lt;/font&gt;&amp;nbsp;&lt;font color="#5fd7ff"&gt;nobackup&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#00ffff"&gt;&amp;quot; Display commands in the bottom right corner as they are typed.&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#ffff00"&gt;set&lt;/font&gt;&amp;nbsp;&lt;font color="#5fd7ff"&gt;showcmd&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#00ffff"&gt;&amp;quot; Smoother redraws&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#ffff00"&gt;set&lt;/font&gt;&amp;nbsp;&lt;font color="#5fd7ff"&gt;ttyfast&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#00ffff"&gt;&amp;quot; Avoid vim complains about not written file when jumping&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#00ffff"&gt;&amp;quot; between buffers using ctags.&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#ffff00"&gt;set&lt;/font&gt;&amp;nbsp;&lt;font color="#5fd7ff"&gt;autowrite&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#00ffff"&gt;&amp;quot; Vim Tip #1160 - Auto Save files when focus is lost.&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#ffff00"&gt;au&lt;/font&gt;&amp;nbsp;&lt;font color="#87ffaf"&gt;FocusLost&lt;/font&gt;&amp;nbsp;*&amp;nbsp;:wa&lt;br&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#00ffff"&gt;&amp;quot; Vim Tip #1279 - Highlight current line in Insert Mode&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#ffff00"&gt;autocmd&lt;/font&gt;&amp;nbsp;&lt;font color="#87ffaf"&gt;InsertLeave&lt;/font&gt;&amp;nbsp;*&amp;nbsp;&lt;font color="#ffff00"&gt;se&lt;/font&gt;&amp;nbsp;nocul&lt;br&gt;&lt;br /&gt;&lt;font color="#ffff00"&gt;autocmd&lt;/font&gt;&amp;nbsp;&lt;font color="#87ffaf"&gt;InsertEnter&lt;/font&gt;&amp;nbsp;*&amp;nbsp;&lt;font color="#ffff00"&gt;se&lt;/font&gt;&amp;nbsp;cul&lt;br&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#00ffff"&gt;&amp;quot; Enable syntax highlighting with 256 color support so we&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#00ffff"&gt;&amp;quot; can use nicer color schemes. For more information and to&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#00ffff"&gt;&amp;quot; get some nice color schemes check:&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#00ffff"&gt;&amp;quot;&amp;nbsp;&amp;nbsp; &lt;a href="http://www.frexx.de/xterm-256-notes/"&gt;http://www.frexx.de/xterm-256-notes/&lt;/a&gt;&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#00ffff"&gt;&amp;quot; Tested with Konsole-2.1 and yakuake 2.9.4&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#ffff00"&gt;set&lt;/font&gt;&amp;nbsp;&lt;font color="#5fd7ff"&gt;t_Co&lt;/font&gt;=256&lt;br&gt;&lt;br /&gt;&lt;font color="#ffff00"&gt;syntax&lt;/font&gt;&amp;nbsp;&lt;font color="#87ffaf"&gt;on&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#00ffff"&gt;&amp;quot; Set this background depending on your console and color scheme.&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#ffff00"&gt;set&lt;/font&gt;&amp;nbsp;&lt;font color="#5fd7ff"&gt;background&lt;/font&gt;=light&lt;br&gt;&lt;br /&gt;&lt;font color="#00ffff"&gt;&amp;quot;set background=dark&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#00ffff"&gt;&amp;quot; My favorite color schemes. You must download the color themes&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#00ffff"&gt;&amp;quot; and put them inside the color folder of your vim installation.&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#00ffff"&gt;&amp;quot;colors default&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;quot; Good fro transparent consoles&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#00ffff"&gt;&amp;quot;colors zenburn&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;quot; Vim Tip #415&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#ffff00"&gt;colors&lt;/font&gt;&amp;nbsp;&lt;font color="#ff40ff"&gt;256&lt;/font&gt;_asu1dark &lt;font color="#00ffff"&gt;&amp;quot; &lt;a href="http://www.frexx.de/xterm-256-notes/"&gt;http://www.frexx.de/xterm-256-notes/&lt;/a&gt;&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#00ffff"&gt;&amp;quot;colors pyte&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;quot; Vim Tip #1492&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#00ffff"&gt;&amp;quot; If in diff mode (vimdiff) use the inkpot color scheme&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#00ffff"&gt;&amp;quot; that better highlights file differences&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#ffff00"&gt;if&lt;/font&gt;&amp;nbsp;&amp;amp;diff&lt;br&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&lt;font color="#ffff00"&gt;colors&lt;/font&gt;&amp;nbsp;inkpot&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;font color="#00ffff"&gt;&amp;quot; Vim Tip #1143&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#ffff00"&gt;endif&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#00ffff"&gt;&amp;quot; Additional filetypes&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#ffff00"&gt;au&lt;/font&gt;&amp;nbsp;&lt;font color="#87ffaf"&gt;BufRead&lt;/font&gt;,&lt;font color="#87ffaf"&gt;BufNewFile&lt;/font&gt;&amp;nbsp;sconstruct&amp;nbsp;&lt;font color="#ffff00"&gt;setlocal&lt;/font&gt;&amp;nbsp;&lt;font color="#5fd7ff"&gt;filetype&lt;/font&gt;=python&lt;br&gt;&lt;br /&gt;&lt;font color="#ffff00"&gt;au&lt;/font&gt;&amp;nbsp;&lt;font color="#87ffaf"&gt;BufRead&lt;/font&gt;,&lt;font color="#87ffaf"&gt;BufNewFile&lt;/font&gt;&amp;nbsp;*.rl&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;font color="#ffff00"&gt;setlocal&lt;/font&gt;&amp;nbsp;&lt;font color="#5fd7ff"&gt;filetype&lt;/font&gt;=ragel&lt;br&gt;&lt;br /&gt;&lt;font color="#ffff00"&gt;au&lt;/font&gt;&amp;nbsp;&lt;font color="#87ffaf"&gt;BufRead&lt;/font&gt;,&lt;font color="#87ffaf"&gt;BufNewFile&lt;/font&gt;&amp;nbsp;*.rb&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;font color="#ffff00"&gt;setlocal&lt;/font&gt;&amp;nbsp;&lt;font color="#5fd7ff"&gt;filetype&lt;/font&gt;=ruby&lt;br&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#00ffff"&gt;&amp;quot; Additional Syntax Files. The ragel.vim file can be downloaded&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#00ffff"&gt;&amp;quot; from Ragel's home page &lt;a href="http://www.complang.org/ragel/."&gt;http://www.complang.org/ragel/.&lt;/a&gt;&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#ffff00"&gt;au&lt;/font&gt;! &lt;font color="#87ffaf"&gt;Syntax&lt;/font&gt;&amp;nbsp;ragel&amp;nbsp;&lt;font color="#ffff00"&gt;source&lt;/font&gt;&amp;nbsp;ragel&lt;font color="#ffff00"&gt;.&lt;/font&gt;&lt;font color="#ffff00"&gt;vim&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#00ffff"&gt;&amp;quot; Set path to search (i.e. gf) files recursively&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#ffff00"&gt;set&lt;/font&gt;&amp;nbsp;&lt;font color="#5fd7ff"&gt;path&lt;/font&gt;=/usr/include&lt;font color="#ffff00"&gt;,&lt;/font&gt;/usr/local/include&lt;font color="#ffff00"&gt;,&lt;/font&gt;**;$HOME&lt;br&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#00ffff"&gt;&amp;quot; Vim Tip #1274 - Highlight trailing whitespace characters&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#ffff00"&gt;set&lt;/font&gt;&amp;nbsp;&lt;font color="#5fd7ff"&gt;list&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#ffff00"&gt;set&lt;/font&gt;&amp;nbsp;&lt;font color="#5fd7ff"&gt;listchars&lt;/font&gt;=tab&lt;font color="#ffff00"&gt;:&lt;/font&gt;-&amp;gt;&lt;font color="#ffff00"&gt;,&lt;/font&gt;trail&lt;font color="#ffff00"&gt;:&lt;/font&gt;·&lt;br&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#00ffff"&gt;&amp;quot; Number of spaces used for (auto)indenting&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#00ffff"&gt;&amp;quot;set shiftwidth=2&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#00ffff"&gt;&amp;quot; Number of spaces to insert for a tab&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#00ffff"&gt;&amp;quot;set softtabstop=2&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#ffff00"&gt;set&lt;/font&gt;&amp;nbsp;&lt;font color="#5fd7ff"&gt;tabstop&lt;/font&gt;=2&lt;br&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#00ffff"&gt;&amp;quot; Insert spaces when the tab key is pressed&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#00ffff"&gt;&amp;quot; If you want a real tab use &lt;/font&gt;&lt;font color="#ff40ff"&gt;&amp;quot;ctrl-v, tab&amp;quot;&lt;/font&gt;&lt;font color="#00ffff"&gt;&amp;nbsp;in insert mode. This&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#00ffff"&gt;&amp;quot; is usefull for Makefiles that require real tabs to work.&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#ffff00"&gt;set&lt;/font&gt;&amp;nbsp;&lt;font color="#5fd7ff"&gt;expandtab&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#00ffff"&gt;&amp;quot; Word wrap with line breaks if they are longer than 80 characters &lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#00ffff"&gt;&amp;quot; long. If you prefer to wrap lines visually only use the wrap and&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#00ffff"&gt;&amp;quot; lbr commands below instead. If you have a document that has lines&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#00ffff"&gt;&amp;quot; longer than 80 characters you can use &lt;/font&gt;&lt;font color="#ff40ff"&gt;&amp;quot;gq}&amp;quot;&lt;/font&gt;&lt;font color="#00ffff"&gt;&amp;nbsp;to format it as a &lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#00ffff"&gt;&amp;quot; paragraph. This is more easier format for navigating the text.&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#ffff00"&gt;set&lt;/font&gt;&amp;nbsp;&lt;font color="#5fd7ff"&gt;textwidth&lt;/font&gt;=80&lt;br&gt;&lt;br /&gt;&lt;font color="#ffff00"&gt;set&lt;/font&gt;&amp;nbsp;&lt;font color="#5fd7ff"&gt;formatoptions&lt;/font&gt;=tcq&lt;br&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#00ffff"&gt;&amp;quot; Vim Tip #989: Word wrap without line breaks&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#00ffff"&gt;&amp;quot;set wrap&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#00ffff"&gt;&amp;quot;set lbr&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#00ffff"&gt;&amp;quot; Enable specific indenting&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#ffff00"&gt;set&lt;/font&gt;&amp;nbsp;&lt;font color="#5fd7ff"&gt;autoindent&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#ffff00"&gt;set&lt;/font&gt;&amp;nbsp;&lt;font color="#5fd7ff"&gt;smartindent&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#00ffff"&gt;&amp;quot; Enable code folding&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#ffff00"&gt;set&lt;/font&gt;&amp;nbsp;&lt;font color="#5fd7ff"&gt;foldmethod&lt;/font&gt;=syntax&lt;br&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#00ffff"&gt;&amp;quot; Show briefly matching bracket when closing it.&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#ffff00"&gt;set&lt;/font&gt;&amp;nbsp;&lt;font color="#5fd7ff"&gt;showmatch&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#00ffff"&gt;&amp;quot; Show cursor position&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#ffff00"&gt;set&lt;/font&gt;&amp;nbsp;&lt;font color="#5fd7ff"&gt;ruler&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#00ffff"&gt;&amp;quot; Additonal key mappings&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#ffff00"&gt;map&lt;/font&gt;&amp;nbsp;&lt;font color="#ffd7d7"&gt;&amp;lt;&lt;/font&gt;&lt;font color="#ffd7d7"&gt;F12&lt;/font&gt;&lt;font color="#ffd7d7"&gt;&amp;gt;&lt;/font&gt;&amp;nbsp;&lt;font color="#ffd7d7"&gt;&amp;lt;&lt;/font&gt;&lt;font color="#ffd7d7"&gt;ESC&lt;/font&gt;&lt;font color="#ffd7d7"&gt;&amp;gt;&lt;/font&gt;ggVGg?&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;quot; ROT13 fun&lt;br&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#00ffff"&gt;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#00ffff"&gt;&amp;quot;&amp;quot; Mini buffer explorer features&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#00ffff"&gt;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#ffff00"&gt;let&lt;/font&gt;&amp;nbsp;g:miniBufExplSplitBelow&lt;font color="#ffff00"&gt;=&lt;/font&gt;&lt;font color="#ff40ff"&gt;0&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#ffff00"&gt;let&lt;/font&gt;&amp;nbsp;g:miniBufExplSplitToEdge&amp;nbsp;&lt;font color="#ffff00"&gt;=&lt;/font&gt;&amp;nbsp;&lt;font color="#ff40ff"&gt;0&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#ffff00"&gt;let&lt;/font&gt;&amp;nbsp;g:miniBufExplVSplit&amp;nbsp;&lt;font color="#ffff00"&gt;=&lt;/font&gt;&amp;nbsp;&lt;font color="#ff40ff"&gt;20&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#ffff00"&gt;let&lt;/font&gt;&amp;nbsp;g:miniBufExplMapCTabSwitchBufs&amp;nbsp;&lt;font color="#ffff00"&gt;=&lt;/font&gt;&amp;nbsp;&lt;font color="#ff40ff"&gt;1&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#ffff00"&gt;let&lt;/font&gt;&amp;nbsp;g:miniBufExplUseSingleClick&amp;nbsp;&lt;font color="#ffff00"&gt;=&lt;/font&gt;&amp;nbsp;&lt;font color="#ff40ff"&gt;1&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#ffff00"&gt;let&lt;/font&gt;&amp;nbsp;g:miniBufExplorerMoreThanOne&lt;font color="#ffff00"&gt;=&lt;/font&gt;&lt;font color="#ff40ff"&gt;0&lt;/font&gt;&amp;nbsp;&lt;br&gt;&lt;br /&gt;&lt;font color="#ffff00"&gt;let&lt;/font&gt;&amp;nbsp;g:miniBufExplModSelTarget&amp;nbsp;&lt;font color="#ffff00"&gt;=&lt;/font&gt;&amp;nbsp;&lt;font color="#ff40ff"&gt;1&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#00ffff"&gt;&amp;quot; Map Tab and Shift-Tab for buffer navigation&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#00ffff"&gt;&amp;quot; Note that S-TAB does not work in certain consoles (i.e. KDE Konsole)&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#ffff00"&gt;map&lt;/font&gt;&amp;nbsp;&lt;font color="#ffd7d7"&gt;&amp;lt;&lt;/font&gt;&lt;font color="#ffd7d7"&gt;TAB&lt;/font&gt;&lt;font color="#ffd7d7"&gt;&amp;gt;&lt;/font&gt;&amp;nbsp;&lt;font color="#ffd7d7"&gt;&amp;lt;&lt;/font&gt;&lt;font color="#ffd7d7"&gt;ESC&lt;/font&gt;&lt;font color="#ffd7d7"&gt;&amp;gt;&amp;lt;&lt;/font&gt;&lt;font color="#ffd7d7"&gt;C-TAB&lt;/font&gt;&lt;font color="#ffd7d7"&gt;&amp;gt;&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#ffff00"&gt;map&lt;/font&gt;&amp;nbsp;&lt;font color="#ffd7d7"&gt;&amp;lt;&lt;/font&gt;&lt;font color="#ffd7d7"&gt;S-TAB&lt;/font&gt;&lt;font color="#ffd7d7"&gt;&amp;gt;&lt;/font&gt;&amp;nbsp;&lt;font color="#ffd7d7"&gt;&amp;lt;&lt;/font&gt;&lt;font color="#ffd7d7"&gt;ESC&lt;/font&gt;&lt;font color="#ffd7d7"&gt;&amp;gt;&amp;lt;&lt;/font&gt;&lt;font color="#ffd7d7"&gt;C-S-TAB&lt;/font&gt;&lt;font color="#ffd7d7"&gt;&amp;gt;&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#00ffff"&gt;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#00ffff"&gt;&amp;quot;&amp;quot; Improve VIM autocomplete features&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#00ffff"&gt;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#00ffff"&gt;&amp;quot; Enable search as you type:&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#ffff00"&gt;set&lt;/font&gt;&amp;nbsp;&lt;font color="#5fd7ff"&gt;incsearch&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#00ffff"&gt;&amp;quot;improve autocomplete menu color&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#ffff00"&gt;highlight&lt;/font&gt;&amp;nbsp;Pmenu&amp;nbsp;&lt;font color="#87ffaf"&gt;ctermbg&lt;/font&gt;=&lt;font color="#ff40ff"&gt;238&lt;/font&gt;&amp;nbsp;&lt;font color="#87ffaf"&gt;gui&lt;/font&gt;=&lt;font color="#5fd7ff"&gt;bold&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#00ffff"&gt;&amp;quot; &lt;a href="http://www.cuberick.com/2008/10/ruby-autocomplete-in-vim.html"&gt;http://www.cuberick.com/2008/10/ruby-autocomplete-in-vim.html&lt;/a&gt;&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#ffff00"&gt;autocmd&lt;/font&gt;&amp;nbsp;&lt;font color="#87ffaf"&gt;FileType&lt;/font&gt;&amp;nbsp;ruby,eruby&amp;nbsp;&lt;font color="#ffff00"&gt;set&lt;/font&gt;&amp;nbsp;&lt;font color="#5fd7ff"&gt;omnifunc&lt;/font&gt;=rubycomplete#Complete&lt;br&gt;&lt;br /&gt;&lt;font color="#ffff00"&gt;autocmd&lt;/font&gt;&amp;nbsp;&lt;font color="#87ffaf"&gt;FileType&lt;/font&gt;&amp;nbsp;ruby,eruby&amp;nbsp;&lt;font color="#ffff00"&gt;let&lt;/font&gt;&amp;nbsp;g:rubycomplete_buffer_loading&amp;nbsp;&lt;font color="#ffff00"&gt;=&lt;/font&gt;&amp;nbsp;&lt;font color="#ff40ff"&gt;1&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#ffff00"&gt;autocmd&lt;/font&gt;&amp;nbsp;&lt;font color="#87ffaf"&gt;FileType&lt;/font&gt;&amp;nbsp;ruby,eruby&amp;nbsp;&lt;font color="#ffff00"&gt;let&lt;/font&gt;&amp;nbsp;g:rubycomplete_rails&amp;nbsp;&lt;font color="#ffff00"&gt;=&lt;/font&gt;&amp;nbsp;&lt;font color="#ff40ff"&gt;1&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#ffff00"&gt;autocmd&lt;/font&gt;&amp;nbsp;&lt;font color="#87ffaf"&gt;FileType&lt;/font&gt;&amp;nbsp;ruby,eruby&amp;nbsp;&lt;font color="#ffff00"&gt;let&lt;/font&gt;&amp;nbsp;g:rubycomplete_classes_in_global&amp;nbsp;&lt;font color="#ffff00"&gt;=&lt;/font&gt;&amp;nbsp;&lt;font color="#ff40ff"&gt;1&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#00ffff"&gt;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#00ffff"&gt;&amp;quot; Vim tip #90 Enable VCS integration in vim&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#00ffff"&gt;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#00ffff"&gt;&amp;quot;&amp;nbsp;&amp;nbsp;Get vcscommand.zip from &lt;a href="http://www.vim.org/scripts/script.php?script_id=90"&gt;http://www.vim.org/scripts/script.php?script_id=90&lt;/a&gt;&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#00ffff"&gt;&amp;quot;&amp;nbsp;&amp;nbsp;Uncompress to your vim directory:&amp;nbsp;&amp;nbsp;unzip -d ~/.vim vcscommand.zip&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#00ffff"&gt;&amp;quot;&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#00ffff"&gt;&amp;quot;&amp;nbsp;&amp;nbsp;Now when editing a file that is under revision control (SVN, CVS, Git,...)&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#00ffff"&gt;&amp;quot;&amp;nbsp;&amp;nbsp;we can access the versioning commands:&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#00ffff"&gt;&amp;quot;&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#00ffff"&gt;&amp;quot;&amp;nbsp;&amp;nbsp;VCSAdd&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#00ffff"&gt;&amp;quot;&amp;nbsp;&amp;nbsp;VCSAnnotate&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#00ffff"&gt;&amp;quot;&amp;nbsp;&amp;nbsp;VCSCommit&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#00ffff"&gt;&amp;quot;&amp;nbsp;&amp;nbsp;VCSDelete&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#00ffff"&gt;&amp;quot;&amp;nbsp;&amp;nbsp;VCSDiff&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#00ffff"&gt;&amp;quot;&amp;nbsp;&amp;nbsp;VCSGotoOriginal&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#00ffff"&gt;&amp;quot;&amp;nbsp;&amp;nbsp;VCSGotoOriginal!&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#00ffff"&gt;&amp;quot;&amp;nbsp;&amp;nbsp;VCSInfo&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#00ffff"&gt;&amp;quot;&amp;nbsp;&amp;nbsp;VCSLog&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#00ffff"&gt;&amp;quot;&amp;nbsp;&amp;nbsp;VCSLock&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#00ffff"&gt;&amp;quot;&amp;nbsp;&amp;nbsp;VCSReview&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#00ffff"&gt;&amp;quot;&amp;nbsp;&amp;nbsp;VCSStatus&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#00ffff"&gt;&amp;quot;&amp;nbsp;&amp;nbsp;VCSUpdate&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#00ffff"&gt;&amp;quot;&amp;nbsp;&amp;nbsp;VCSUnlock&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#00ffff"&gt;&amp;quot;&amp;nbsp;&amp;nbsp;VCSVimDiff&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#00ffff"&gt;&amp;quot; Map F4 to VimDiff to check differences&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#ffff00"&gt;map&lt;/font&gt;&amp;nbsp;&lt;font color="#ffd7d7"&gt;&amp;lt;&lt;/font&gt;&lt;font color="#ffd7d7"&gt;F4&lt;/font&gt;&lt;font color="#ffd7d7"&gt;&amp;gt;&lt;/font&gt;&amp;nbsp;&lt;font color="#ffd7d7"&gt;&amp;lt;&lt;/font&gt;&lt;font color="#ffd7d7"&gt;ESC&lt;/font&gt;&lt;font color="#ffd7d7"&gt;&amp;gt;&lt;/font&gt;:VCSVimDiff&lt;font color="#ffd7d7"&gt;&amp;lt;&lt;/font&gt;&lt;font color="#ffd7d7"&gt;CR&lt;/font&gt;&lt;font color="#ffd7d7"&gt;&amp;gt;&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#00ffff"&gt;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#00ffff"&gt;&amp;quot; Latex Configuration&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#00ffff"&gt;&amp;quot; &lt;a href="http://vim-latex.sourceforge.net/documentation/latex-suite/recommended-settings.html"&gt;http://vim-latex.sourceforge.net/documentation/latex-suite/recommended-settings.html&lt;/a&gt;&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#00ffff"&gt;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#ffff00"&gt;au&lt;/font&gt;&amp;nbsp;&lt;font color="#87ffaf"&gt;BufRead&lt;/font&gt;,&lt;font color="#87ffaf"&gt;BufNewFile&lt;/font&gt;&amp;nbsp;*.cls&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;font color="#ffff00"&gt;setlocal&lt;/font&gt;&amp;nbsp;&lt;font color="#5fd7ff"&gt;filetype&lt;/font&gt;=tex&lt;br&gt;&lt;br /&gt;&lt;font color="#00ffff"&gt;&amp;quot;let g:tex_flavor='latex'&amp;nbsp;&amp;nbsp; &amp;quot; loads latexsuite with empty tex files.&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#ffff00"&gt;set&lt;/font&gt;&amp;nbsp;&lt;font color="#5fd7ff"&gt;iskeyword&lt;/font&gt;+=&lt;font color="#ffff00"&gt;:&lt;/font&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;font color="#00ffff"&gt;&amp;quot; type /ref{fig: and press &amp;lt;C-n&amp;gt; to autocomplete references&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#00ffff"&gt;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#00ffff"&gt;&amp;quot; Working with Makefiles&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#00ffff"&gt;&amp;quot;&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#00ffff"&gt;&amp;quot; Press F5 to compile and open the error window if there&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#00ffff"&gt;&amp;quot; are errors. If there are errors you can use :cn and :cN to&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#00ffff"&gt;&amp;quot; jump foward and backward thru the error list. Press :ccl to&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#00ffff"&gt;&amp;quot; close the error list or F5 again to recompile&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#ffff00"&gt;map&lt;/font&gt;&amp;nbsp;&lt;font color="#ffd7d7"&gt;&amp;lt;&lt;/font&gt;&lt;font color="#ffd7d7"&gt;F5&lt;/font&gt;&lt;font color="#ffd7d7"&gt;&amp;gt;&lt;/font&gt;&amp;nbsp;&lt;font color="#ffd7d7"&gt;&amp;lt;&lt;/font&gt;&lt;font color="#ffd7d7"&gt;ESC&lt;/font&gt;&lt;font color="#ffd7d7"&gt;&amp;gt;&lt;/font&gt;:make&lt;font color="#ffd7d7"&gt;&amp;lt;&lt;/font&gt;&lt;font color="#ffd7d7"&gt;CR&lt;/font&gt;&lt;font color="#ffd7d7"&gt;&amp;gt;&amp;lt;&lt;/font&gt;&lt;font color="#ffd7d7"&gt;ESC&lt;/font&gt;&lt;font color="#ffd7d7"&gt;&amp;gt;&lt;/font&gt;:botright cwindow&lt;font color="#ffd7d7"&gt;&amp;lt;&lt;/font&gt;&lt;font color="#ffd7d7"&gt;CR&lt;/font&gt;&lt;font color="#ffd7d7"&gt;&amp;gt;&lt;/font&gt;&amp;nbsp;&amp;quot; Compile and open quick fix list&lt;br&gt;&lt;br /&gt;&lt;font color="#ffff00"&gt;map&lt;/font&gt;&amp;nbsp;&lt;font color="#ffd7d7"&gt;&amp;lt;&lt;/font&gt;&lt;font color="#ffd7d7"&gt;F6&lt;/font&gt;&lt;font color="#ffd7d7"&gt;&amp;gt;&lt;/font&gt;&amp;nbsp;&lt;font color="#ffd7d7"&gt;&amp;lt;&lt;/font&gt;&lt;font color="#ffd7d7"&gt;ESC&lt;/font&gt;&lt;font color="#ffd7d7"&gt;&amp;gt;&lt;/font&gt;:cN&lt;font color="#ffd7d7"&gt;&amp;lt;&lt;/font&gt;&lt;font color="#ffd7d7"&gt;CR&lt;/font&gt;&lt;font color="#ffd7d7"&gt;&amp;gt;&lt;/font&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;quot; Jump to prev error/warn&lt;br&gt;&lt;br /&gt;&lt;font color="#ffff00"&gt;map&lt;/font&gt;&amp;nbsp;&lt;font color="#ffd7d7"&gt;&amp;lt;&lt;/font&gt;&lt;font color="#ffd7d7"&gt;F7&lt;/font&gt;&lt;font color="#ffd7d7"&gt;&amp;gt;&lt;/font&gt;&amp;nbsp;&lt;font color="#ffd7d7"&gt;&amp;lt;&lt;/font&gt;&lt;font color="#ffd7d7"&gt;ESC&lt;/font&gt;&lt;font color="#ffd7d7"&gt;&amp;gt;&lt;/font&gt;:cn&lt;font color="#ffd7d7"&gt;&amp;lt;&lt;/font&gt;&lt;font color="#ffd7d7"&gt;CR&lt;/font&gt;&lt;font color="#ffd7d7"&gt;&amp;gt;&lt;/font&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;quot; Jump to next error/warn&lt;br&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#00ffff"&gt;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#00ffff"&gt;&amp;quot; Enable spell checking in latex, bib and txt files&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#00ffff"&gt;&amp;quot;&lt;/font&gt;&amp;nbsp;&lt;font color="#5fd7ff"&gt;Commands:&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#00ffff"&gt;&amp;quot;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;[s&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;-&amp;gt;&amp;nbsp;&amp;nbsp;jump to next bad word&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#00ffff"&gt;&amp;quot;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;]s&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;-&amp;gt;&amp;nbsp;&amp;nbsp;jump to prev bad word&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#00ffff"&gt;&amp;quot;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;z=&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;-&amp;gt;&amp;nbsp;&amp;nbsp;suggest word&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#00ffff"&gt;&amp;quot;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;zg&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;-&amp;gt;&amp;nbsp;&amp;nbsp;mark word as good (add to dictionary)&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#00ffff"&gt;&amp;quot;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;zw&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;-&amp;gt;&amp;nbsp;&amp;nbsp;mark word as bad&amp;nbsp;&amp;nbsp;(remove from dictionary)&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#00ffff"&gt;&amp;quot;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;:h spell -&amp;gt; get more details about spelling&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#00ffff"&gt;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#ffff00"&gt;au&lt;/font&gt;&amp;nbsp;&lt;font color="#87ffaf"&gt;BufRead&lt;/font&gt;,&lt;font color="#87ffaf"&gt;BufNewFile&lt;/font&gt;&amp;nbsp;*.txt,*.tex,*.bib&amp;nbsp;&amp;nbsp;&lt;font color="#ffff00"&gt;setlocal&lt;/font&gt;&amp;nbsp;&lt;font color="#5fd7ff"&gt;spell&lt;/font&gt;&amp;nbsp;&lt;font color="#5fd7ff"&gt;spelllang&lt;/font&gt;=en_us&lt;br&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#00ffff"&gt;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#00ffff"&gt;&amp;quot; Other Good Vim tips not used here&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#00ffff"&gt;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&amp;quot;&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#00ffff"&gt;&amp;quot; Vim Tip #64&amp;nbsp;&amp;nbsp; - Set working dir to the file you are editing&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#00ffff"&gt;&amp;quot;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Why not used: Makes difficult the management of sessions and&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#00ffff"&gt;&amp;quot;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; makefiles.&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#00ffff"&gt;&amp;quot; Vim Tip #305&amp;nbsp;&amp;nbsp;- List of editing vim tips&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#00ffff"&gt;&amp;quot;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Why not used: I can remember all the commands I use.&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#00ffff"&gt;&amp;quot; Vim Tip #1203 - mapping to set up vtreeexplorer and taglist in left window&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#00ffff"&gt;&amp;quot;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Why not used: I use MiniBufExpl instead of vtreeexplorer&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#00ffff"&gt;&amp;quot; Vim Tip #1318 - An attempt to emulate TextMate's snippet expansion&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#00ffff"&gt;&amp;quot;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Why not used: I am unable to get this working correctly.&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#00ffff"&gt;&amp;quot; Vim Tip #???? - Force gf to open in new tabs&amp;nbsp;&amp;nbsp;&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#00ffff"&gt;&amp;quot;&lt;/font&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;font color="#5fd7ff"&gt;Command:&lt;/font&gt;&lt;font color="#00ffff"&gt;&amp;nbsp;nnoremap gf &amp;lt;C-W&amp;gt;gf &lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#00ffff"&gt;&amp;quot;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Why not used: I use MiniBufExpl so no more tabs for me.&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#00ffff"&gt;&amp;quot; Vim Tip #565&amp;nbsp;&amp;nbsp;- Never see ^M and pesky trailing spaces again&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#00ffff"&gt;&amp;quot;&lt;/font&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;font color="#5fd7ff"&gt;Command:&lt;/font&gt;&lt;font color="#00ffff"&gt;&amp;nbsp;autocmd BufRead * silent! %s/[\r \t]\+$//&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#00ffff"&gt;&amp;quot;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Why not used: Not a good idea when working with others source&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#00ffff"&gt;&amp;quot;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;code. All the automatically deleted chars will be seen as &lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#00ffff"&gt;&amp;quot;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;changes in the diff files making it difficult to review the &lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#00ffff"&gt;&amp;quot;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;changes. Never use this if you plan to submit patches to ffmpeg &lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#00ffff"&gt;&amp;quot;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;or the Linux kernel or they will spam filter you forever!&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;/font&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://photos1.blogger.com/blogger/4210/3782/1600/screen3.png"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;" src="http://photos1.blogger.com/blogger/4210/3782/320/screen3.png" border="1" alt="" /&gt;&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/34829202-6857098958218005916?l=piao-tech.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://piao-tech.blogspot.com/feeds/6857098958218005916/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://piao-tech.blogspot.com/2008/10/basic-vimrc-file.html#comment-form' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/34829202/posts/default/6857098958218005916'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/34829202/posts/default/6857098958218005916'/><link rel='alternate' type='text/html' href='http://piao-tech.blogspot.com/2008/10/basic-vimrc-file.html' title='Basic .vimrc file'/><author><name>龍神</name><uri>http://www.blogger.com/profile/16648963337079496096</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_99Fzui5MBLY/SO3gwQSlmfI/AAAAAAAAAMY/jmZy0aQprn0/s72-c/vimsnap.png' height='72' width='72'/><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-34829202.post-2723121582162763650</id><published>2008-09-25T10:47:00.001+09:00</published><updated>2011-04-22T16:17:36.409+09:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Tips'/><category scheme='http://www.blogger.com/atom/ns#' term='Kubuntu'/><title type='text'>Canon Satera LBP5910 Linux Driver</title><content type='html'>If you have a Canon printer based on the LIPSLX driver (i.e. LBP family) then you are lucky because Canon provides the linux drivers for these printers.&lt;br /&gt;&lt;br /&gt;Simply go to this page &lt;a href="http://cweb.canon.jp/drv-upd/lasershot/linux/lipslxlinux.html"&gt;Canon Linux Driver&lt;/a&gt; check for the supported printers and the respective drivers. For my case I have the LBP5910F printer that is supported by the LIPS LX Printer Driver so I enter this page and download the two corresponding .deb packages for Ubuntu/Debian. If you use Redhat or any other distribution that uses RPMs then download the corresponding RPMs.&lt;br /&gt;&lt;br /&gt;To install in Ubuntu/Debian 32bit:&lt;br /&gt;&lt;br /&gt;&lt;div class="code"&gt;&lt;br /&gt;sudo dpkg -i cndrvcups-common_2.20-1_i386.deb&lt;br /&gt;sudo dpkg -i cndrvcups-lipslx_2.20-1_i386.deb&lt;br /&gt;sudo /etc/init.d/cupsys restart&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;Now enter CUPS configuration page (i.e. http://localhost:631) and follow the steps. In my case the printer was already listed in the select box of printers with IP address and everithing. In Make/Manufacturer select Canon and finally in Model/Driver select the corresponding driver:&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_99Fzui5MBLY/SNrwWWS40dI/AAAAAAAAAMQ/hHKaJfcGkQc/s1600-h/cupsys.png"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;" src="http://2.bp.blogspot.com/_99Fzui5MBLY/SNrwWWS40dI/AAAAAAAAAMQ/hHKaJfcGkQc/s320/cupsys.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5249772582386323922" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;And that is all now you can try to print a test page.&lt;br /&gt;&lt;br /&gt;To install in Ubuntu/Debian 64bit:&lt;br /&gt;&lt;br /&gt;For some reason there are no deb packages for 64bit architecture but fortunately is easy to convert the 64bit rpms to deb packages using alien.&lt;br /&gt;&lt;br /&gt;First install alien:&lt;br /&gt;&lt;div class=code&gt;sudo aptitude install alien&lt;br /&gt;&lt;/div&gt;then using this tool convert the rpm packages to deb packages:&lt;br /&gt;&lt;div class=code&gt;sudo alien -k cndrvcups-lipslx-2.20-1.x86_64.rpm &lt;br /&gt;sudo alien -k cndrvcups-common-2.20-1.x86_64.rpm&lt;br /&gt;&lt;/div&gt;this will generate two 64bit deb packages that work perfectly with Ubuntu/Kubuntu and can be installed as the 32 bit versions above:&lt;br /&gt;&lt;div class=code&gt;sudo dpkg -i cndrvcups-lipslx_2.20-1_amd64.deb cndrvcups-common_2.20-1_amd64.deb&lt;br /&gt;&lt;/div&gt;after installing the packages you can proceed with the installation the same way as with the 32bit packages.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/34829202-2723121582162763650?l=piao-tech.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://piao-tech.blogspot.com/feeds/2723121582162763650/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://piao-tech.blogspot.com/2008/09/canon-satera-lbp5910-linux-driver.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/34829202/posts/default/2723121582162763650'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/34829202/posts/default/2723121582162763650'/><link rel='alternate' type='text/html' href='http://piao-tech.blogspot.com/2008/09/canon-satera-lbp5910-linux-driver.html' title='Canon Satera LBP5910 Linux Driver'/><author><name>龍神</name><uri>http://www.blogger.com/profile/16648963337079496096</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_99Fzui5MBLY/SNrwWWS40dI/AAAAAAAAAMQ/hHKaJfcGkQc/s72-c/cupsys.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-34829202.post-1197929848483300660</id><published>2008-06-25T12:38:00.000+09:00</published><updated>2008-06-25T13:11:22.634+09:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Tips'/><category scheme='http://www.blogger.com/atom/ns#' term='SftpDrive'/><category scheme='http://www.blogger.com/atom/ns#' term='OpenSSH'/><title type='text'>Use PuTTY generated keys with SftpDrive</title><content type='html'>So you created a public/private key pair using &lt;a href="http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html"&gt;PuTTYgen&lt;/a&gt; and now you want to use these keys in other applications like &lt;a href="http://sshwindows.sourceforge.net/"&gt;OpenSSH&lt;/a&gt; and/or &lt;a href="http://www.sftpdrive.com/"&gt;SftpDrive&lt;/a&gt; but you realise that the private key generated by PuTTYgen is not compatible with these programs??&lt;br /&gt;&lt;br /&gt;No worries...  all you have to do is convert your PuTTYgen key (.ppk) to and OpenSSH compatible key and it happens to be that PuTTYgen can do this conversion.&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://bp0.blogger.com/_99Fzui5MBLY/SGHCVS7MTII/AAAAAAAAAJ8/2ykzfh1PCrQ/s1600-h/puttygen2.PNG"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;" src="http://bp0.blogger.com/_99Fzui5MBLY/SGHCVS7MTII/AAAAAAAAAJ8/2ykzfh1PCrQ/s320/puttygen2.PNG" border="0" alt=""id="BLOGGER_PHOTO_ID_5215663514584894594" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Open PuTTYgen and load your private key using the "load" button and opening your private key .ppk file. Once loaded select from the top menu "Conversions -&gt; Export OpenSSH key" and select a file name to save the exported key. Now this saved key can be used in other applications that are OpenSSH compatible.&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://bp3.blogger.com/_99Fzui5MBLY/SGHDSXrL8iI/AAAAAAAAAKE/7A_lYzZwYck/s1600-h/sftpdrive1.PNG"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;" src="http://bp3.blogger.com/_99Fzui5MBLY/SGHDSXrL8iI/AAAAAAAAAKE/7A_lYzZwYck/s320/sftpdrive1.PNG" border="0" alt=""id="BLOGGER_PHOTO_ID_5215664563831960098" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;To use this key with SftpDrive open SftpDrive Manager and on "New Driver" change the Authentication method (see image above) to "Use a public key to log in...". This will open a dialog box (see image below).&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://bp2.blogger.com/_99Fzui5MBLY/SGHD0Gov21I/AAAAAAAAAKM/FGQCf16yAIg/s1600-h/sftpdrive2.PNG"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;" src="http://bp2.blogger.com/_99Fzui5MBLY/SGHD0Gov21I/AAAAAAAAAKM/FGQCf16yAIg/s320/sftpdrive2.PNG" border="0" alt=""id="BLOGGER_PHOTO_ID_5215665143373880146" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Here you can generate a new public/private key pair but we want to use the one we generated with PuTTYgen so select "Import Existing Key Pair" that will open yet another dialog box (see image below):&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://bp2.blogger.com/_99Fzui5MBLY/SGHEOOJvpUI/AAAAAAAAAKU/2kGm0Zc1UzM/s1600-h/sftpdrive3.PNG"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;" src="http://bp2.blogger.com/_99Fzui5MBLY/SGHEOOJvpUI/AAAAAAAAAKU/2kGm0Zc1UzM/s320/sftpdrive3.PNG" border="0" alt=""id="BLOGGER_PHOTO_ID_5215665592067925314" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Here simply browse the location of the private and the corresponding public keys and press "OK". Now SftpDrive will use these keys to connect to your SSH server.&lt;br /&gt;&lt;br /&gt;If you get errors make sure you have selected the exported OpenSSH compatible key and not the PuTTYgen generated one (i.e. .ppk). Also if you saved the public key using the PuTTYgen "save public key" button then this key has a format SftpDrive does not understands so it will be unable to read the key. To solve this copy and paste the public key as it appears in PuTTYgen text box (i.e. the large string starting with ssh-rsa or ssh-dsa) in a text file (i.e. mykey.pub) and then import that file as the public key. This format is OpenSSH compatible so should work with no problems.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/34829202-1197929848483300660?l=piao-tech.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://piao-tech.blogspot.com/feeds/1197929848483300660/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://piao-tech.blogspot.com/2008/06/use-putty-generated-keys-with-sftpdrive.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/34829202/posts/default/1197929848483300660'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/34829202/posts/default/1197929848483300660'/><link rel='alternate' type='text/html' href='http://piao-tech.blogspot.com/2008/06/use-putty-generated-keys-with-sftpdrive.html' title='Use PuTTY generated keys with SftpDrive'/><author><name>龍神</name><uri>http://www.blogger.com/profile/16648963337079496096</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://bp0.blogger.com/_99Fzui5MBLY/SGHCVS7MTII/AAAAAAAAAJ8/2ykzfh1PCrQ/s72-c/puttygen2.PNG' height='72' width='72'/><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-34829202.post-7526363447212366530</id><published>2008-06-24T09:10:00.002+09:00</published><updated>2008-06-25T12:13:55.867+09:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Tips'/><category scheme='http://www.blogger.com/atom/ns#' term='Subversion'/><category scheme='http://www.blogger.com/atom/ns#' term='Servers'/><category scheme='http://www.blogger.com/atom/ns#' term='OpenSSH'/><title type='text'>Subversion + OpenSSH Server + PuTTY Client Setup</title><content type='html'>This setup is of a &lt;a href="http://subversion.tigris.org/"&gt;subversion&lt;/a&gt; server running on Linux (Kubuntu 8.04) and subversion clients (&lt;a href="http://tortoisesvn.tigris.org/"&gt;Tortoise SVN&lt;/a&gt;) running in Windows (WinXP).&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Pre-requisites&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;I assume you already have a subversion repository working and now you want to access it using ssh tunnelling for security reasons. Also the server must have remote ssh access and be configured to do Private Key authentication.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Setting up Putty&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The best SSH client and related tools for Windows are the PuTTY family of programs that can be found at &lt;a href="http://www.chiark.greenend.org.uk/~sgtatham/putty/"&gt;http://www.chiark.greenend.org.uk/~sgtatham/putty/&lt;/a&gt;. You can download the individual ".exe" files an put them in your path but I recommend you to use the &lt;a href="http://the.earth.li/~sgtatham/putty/latest/x86/putty-0.60-installer.exe"&gt;installer&lt;/a&gt; that will install all the tools and set them nicely in your start menu.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Create public/private key pair&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://bp2.blogger.com/_99Fzui5MBLY/SGBAZdZ7FJI/AAAAAAAAAJs/yNW6mcYvvcI/s1600-h/puttygen.PNG"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;" src="http://bp2.blogger.com/_99Fzui5MBLY/SGBAZdZ7FJI/AAAAAAAAAJs/yNW6mcYvvcI/s320/puttygen.PNG" border="0" alt=""id="BLOGGER_PHOTO_ID_5215239174629299346" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Objective&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;To access the subversion server via ssh you need a public/private key pair. To generate these key pair you can use the PuTTY Key Generator (PuTTYgen.exe) that was installed along with PuTTY installer.&lt;br /&gt;&lt;br /&gt;Simply execute the PuTTYgen.exe program and press the "generate" button. After that keep moving your mouse, to generate some randomness, until the progress bar reaches the end. At this point you will get your public and private keys generated.&lt;br /&gt;&lt;br /&gt;Make sure you add a "Key passphrase" that will be like a password to access the keys. The comment part is not necessary but is customary to put your email address.&lt;br /&gt;&lt;br /&gt;Also make sure you are generating a SSH-2 key pair as SSH-1 is not secure. Choosing between RSA or DSA keys is a matter of application. It is known that DSA is fast at key generation and signing while RSA is faster at verification. So if your application requires a lot of signing (i.e. SSL Web Application) then DSA is good but if your application requires a lot of verifying (i.e. Subversion) then RSA is best. Since we are going to use this key for Subversion I recommend subversion but you are free to use the one you prefer.&lt;br /&gt;&lt;br /&gt;Now we need to save your generated keys somewhere in your hard disk. The public key is visible in the PuTTYgen application widget (i.e. the long sequence of letters in the top text box). This key starts usually with "ssh-rsa" or "ssh-dsa" depending on what type of key you generated (RSA or DSA).&lt;br /&gt;&lt;br /&gt;To save your public key on disk do not use the "save public key" button as this will generate a key in a format that is not compatible with OpenSSH. Simply copy and paste the key from the text box to a file on disk. You can save this file with whatever name you like but I recommend putting a ".pub" extension just as OpenSSH does.&lt;br /&gt;&lt;br /&gt;The private key you must save it using the "save private key" button as this generates a file with ".ppk" extension that is understood only by PuTTY programs. Make sure you put the same name as the public key but with the ".ppk" extension instead of ".pub".&lt;br /&gt;&lt;br /&gt;As an additional step if you would like to use your private key with other applications like SftpDrive so these can also connect to the OpenSSH server without need for a password, then you must convert your private key (.ppk file) to the OpenSSH key format. To do this simply select "Conversions" in the PuTTYgen.exe menu and then "Export OpenSSH key" to generate a key that can be used with OpenSSH compatible applications. &lt;br /&gt;&lt;br /&gt;Note that with PuTTYgen.exe you can convert your private keys between PuTTY (.ppk) format and OpenSSH format so if you generate your public/private keys using OpenSSH ssh-keygen program you can use them in PuTTY by importing the private key using PuTTYgen.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Setting your public keys&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The way the public/private key pair are used is simple. You keep the private key in your local machine usually in a key manager like ssh-agent or pageant and send your public key to all the servers you want to access via ssh.&lt;br /&gt;&lt;br /&gt;To set up your public key in the SSH server (assumed OpenSSH server) simply log to the server shell using your account username and password (if you don't have one ask you administrator or if you are the administrator create one yourself). Then copy the contents of your public key file inside the file "~/.ssh/authorized_keys2".&lt;br /&gt;&lt;br /&gt;To do this edit the "~/.ssh/authorized_keys2" file with any text editor (Vi, Nano, Kwrite, gEdit) and make sure it looks like in the next figure:&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://bp2.blogger.com/_99Fzui5MBLY/SGBG7r8G9BI/AAAAAAAAAJ0/mxK9gWInL9g/s1600-h/putty-openssh-13.gif"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;" src="http://bp2.blogger.com/_99Fzui5MBLY/SGBG7r8G9BI/AAAAAAAAAJ0/mxK9gWInL9g/s320/putty-openssh-13.gif" border="0" alt=""id="BLOGGER_PHOTO_ID_5215246359716099090" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;The key must start with ssh-rsa or ssh-dsa depending on the key you generated followed by the key all in one line (i.e. no new lines and spaces) and finally the comment again all in one line.&lt;br /&gt;&lt;br /&gt;Finally make sure the authorized_keys2 file has correct permissions by executing "chmod 600 authorized_keys2".&lt;br /&gt;&lt;br /&gt;You can set the public key in as many SSH servers as you like so you can access them all using the same private key.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Setting your private key&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Your private key must be your most guarded secret and shall not be passed to anyone. Only you should have access to this key because anyone who gets his/her hands on that private key can access all the servers where you installed your public key and we don't want anyone to have that access power do we?&lt;br /&gt;&lt;br /&gt;To use a your private key we usually use a SSH authentication agent like ssh-agent in Linux/Unix or pageant in Windows. The PuTTY installer comes with pageant.exe that is the one I use and recommend.&lt;br /&gt;&lt;br /&gt; Simply execute pageant.exe from the application menu and a small icon will appear in your system tray. Right click the icon and select "Add key" on the context menu, then browse the directory where you saved your private key (i.e. &lt;hostname&gt;.ppk) and select it. And that is it....&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Testing SSH access&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;To test open the PuTTY.exe SSH client and create a new session to connect to your SSH server (make sure you save the session). When you open the session it should log you in without asking for any username and passwords. If it asks you for username and password then you did something wrong. Make sure the publickey format is correct on the server and that the private key is set in pageant. Of course make sure the OpenSSH server is running on the remote machine and that pageant is running on the local machine.&lt;br /&gt;&lt;br /&gt;Once you can connect to the SSH server without need for a username and password then we can proceed to set up TortoiseSVN to access your Subversion repositories via SSH tunnels.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Setting TortoiseSVN with SSH tunnelling&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Once you have SSH set to work with public/private key authentication and have pageant configured configuring TortoiseSVN is a breeze. All you have to do is make sure you use the correct URL format to access the repository.&lt;br /&gt;&lt;br /&gt;If you have TortoiseSVN installed try to make a checkout and in the URL put something like:&lt;br /&gt;&lt;div class="code"&gt;&lt;br /&gt;svn+ssh://username@hostname/dir/to/repo&lt;br /&gt;&lt;/div&gt; &lt;br /&gt;And you should be able to ckeck out that project over an SSH tunnel. You don't even need to have svnserve running on the server as the svn+ssh scheme tells the TortoiseSVN to start it for you and tunnel it over SSH.&lt;br /&gt;&lt;br /&gt;Of course replace username with the username you use to access the SSH server and hostname with the IP address or FQDN of your SSH server. The path to the repository must be absolute path starting from the root "/" directory and have correct access privileges (read/write) for the username you use.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Resources&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://neubia.com/archives/000191.html"&gt;http://neubia.com/archives/000191.html&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.unixwiz.net/techtips/putty-openssh.html"&gt;http://www.unixwiz.net/techtips/putty-openssh.html&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/34829202-7526363447212366530?l=piao-tech.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://piao-tech.blogspot.com/feeds/7526363447212366530/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://piao-tech.blogspot.com/2008/06/subversion-openssh-server-putty-client.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/34829202/posts/default/7526363447212366530'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/34829202/posts/default/7526363447212366530'/><link rel='alternate' type='text/html' href='http://piao-tech.blogspot.com/2008/06/subversion-openssh-server-putty-client.html' title='Subversion + OpenSSH Server + PuTTY Client Setup'/><author><name>龍神</name><uri>http://www.blogger.com/profile/16648963337079496096</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://bp2.blogger.com/_99Fzui5MBLY/SGBAZdZ7FJI/AAAAAAAAAJs/yNW6mcYvvcI/s72-c/puttygen.PNG' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-34829202.post-5635281598832844310</id><published>2008-06-14T11:47:00.000+09:00</published><updated>2008-06-14T11:50:22.883+09:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Rant'/><title type='text'>Best gift ever??</title><content type='html'>Now I can reaffirm that I married the right person, just look what I got for fathers day!!!&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://bp2.blogger.com/_99Fzui5MBLY/SFMxps6PeAI/AAAAAAAAAJk/zrVNw5ciW-8/s1600-h/IMG_1373.JPG"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;" src="http://bp2.blogger.com/_99Fzui5MBLY/SFMxps6PeAI/AAAAAAAAAJk/zrVNw5ciW-8/s400/IMG_1373.JPG" border="0" alt=""id="BLOGGER_PHOTO_ID_5211563786297636866" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;I know I do not blog that often but be assured that now I will be blogging none at all for at least a few weeks, or months....&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/34829202-5635281598832844310?l=piao-tech.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://piao-tech.blogspot.com/feeds/5635281598832844310/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://piao-tech.blogspot.com/2008/06/best-gift-ever.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/34829202/posts/default/5635281598832844310'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/34829202/posts/default/5635281598832844310'/><link rel='alternate' type='text/html' href='http://piao-tech.blogspot.com/2008/06/best-gift-ever.html' title='Best gift ever??'/><author><name>龍神</name><uri>http://www.blogger.com/profile/16648963337079496096</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://bp2.blogger.com/_99Fzui5MBLY/SFMxps6PeAI/AAAAAAAAAJk/zrVNw5ciW-8/s72-c/IMG_1373.JPG' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-34829202.post-2199566126864711914</id><published>2008-04-17T10:18:00.000+09:00</published><updated>2008-04-17T10:25:04.375+09:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Rant'/><title type='text'>Plotting SVN history??</title><content type='html'>Found a &lt;a href="http://www.wand.net.nz/~stj2/blog/?p=629"&gt;blog post&lt;/a&gt; by Samuel Jansen were he plots his subversion repository history so out of curiosity I plotted mine too...  &lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://bp3.blogger.com/_99Fzui5MBLY/SAamgWc6M1I/AAAAAAAAAJA/P1IDlhwU9bk/s1600-h/repo.png"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;" src="http://bp3.blogger.com/_99Fzui5MBLY/SAamgWc6M1I/AAAAAAAAAJA/P1IDlhwU9bk/s400/repo.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5190018695303934802" /&gt;&lt;/a&gt;&lt;br /&gt;actually nothing interesting, steady development almost linear and as you can see but it made me notice that I am almost near my 1000 mark!!  when I reach it then I will have an excuse to celebrate and give a nice "1000 SVN passed mark present".&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/34829202-2199566126864711914?l=piao-tech.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://piao-tech.blogspot.com/feeds/2199566126864711914/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://piao-tech.blogspot.com/2008/04/plotting-svn-history.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/34829202/posts/default/2199566126864711914'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/34829202/posts/default/2199566126864711914'/><link rel='alternate' type='text/html' href='http://piao-tech.blogspot.com/2008/04/plotting-svn-history.html' title='Plotting SVN history??'/><author><name>龍神</name><uri>http://www.blogger.com/profile/16648963337079496096</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://bp3.blogger.com/_99Fzui5MBLY/SAamgWc6M1I/AAAAAAAAAJA/P1IDlhwU9bk/s72-c/repo.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-34829202.post-8350379595390040248</id><published>2008-04-13T17:00:00.000+09:00</published><updated>2008-04-13T17:07:03.618+09:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Rant'/><title type='text'>Linux Cafe in Akihabara</title><content type='html'>Have been in &lt;a href="http://en.wikipedia.org/wiki/Akihabara"&gt;Akihabara&lt;/a&gt; (Electric Town) several times but never saw this shop before:&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://bp1.blogger.com/_99Fzui5MBLY/SAG-RGc6MyI/AAAAAAAAAIo/YR-uKXAAjx4/s1600-h/CRW_3742.jpg"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;" src="http://bp1.blogger.com/_99Fzui5MBLY/SAG-RGc6MyI/AAAAAAAAAIo/YR-uKXAAjx4/s400/CRW_3742.jpg" border="0" alt=""id="BLOGGER_PHOTO_ID_5188637446706443042" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://bp1.blogger.com/_99Fzui5MBLY/SAG-bGc6MzI/AAAAAAAAAIw/xVRNYJA7s0I/s1600-h/CRW_3744.jpg"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;" src="http://bp1.blogger.com/_99Fzui5MBLY/SAG-bGc6MzI/AAAAAAAAAIw/xVRNYJA7s0I/s320/CRW_3744.jpg" border="0" alt=""id="BLOGGER_PHOTO_ID_5188637618505134898" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;If you read the details below the logo you will see this shop is been there since 2001!! and I never saw it... I must go check my eyes.  Anyway if you are an Open Source person walking around Akihabara you may well pass a get yourself a nice cup of open source coffee.&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://bp1.blogger.com/_99Fzui5MBLY/SAG-8Gc6M0I/AAAAAAAAAI4/yZepkGi9zuc/s1600-h/CRW_3745.jpg"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;" src="http://bp1.blogger.com/_99Fzui5MBLY/SAG-8Gc6M0I/AAAAAAAAAI4/yZepkGi9zuc/s400/CRW_3745.jpg" border="0" alt=""id="BLOGGER_PHOTO_ID_5188638185440817986" /&gt;&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/34829202-8350379595390040248?l=piao-tech.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://piao-tech.blogspot.com/feeds/8350379595390040248/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://piao-tech.blogspot.com/2008/04/linux-cafe-in-akihabara.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/34829202/posts/default/8350379595390040248'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/34829202/posts/default/8350379595390040248'/><link rel='alternate' type='text/html' href='http://piao-tech.blogspot.com/2008/04/linux-cafe-in-akihabara.html' title='Linux Cafe in Akihabara'/><author><name>龍神</name><uri>http://www.blogger.com/profile/16648963337079496096</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://bp1.blogger.com/_99Fzui5MBLY/SAG-RGc6MyI/AAAAAAAAAIo/YR-uKXAAjx4/s72-c/CRW_3742.jpg' height='72' width='72'/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-34829202.post-1771592333071915074</id><published>2008-04-09T09:05:00.003+09:00</published><updated>2008-04-09T10:06:14.645+09:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Tips'/><category scheme='http://www.blogger.com/atom/ns#' term='Servers'/><title type='text'>Simple Mail Server (Kubuntu)</title><content type='html'>If you need a small personal mail server to send log reports and system alarms from your Kubuntu machines to a local and/or external mail address then you may use Exim4 that is the default mail server (MTA) that comes with (K)Ubuntu.&lt;br /&gt;&lt;br /&gt;To install is very easy:&lt;br /&gt;&lt;div class="code"&gt;&lt;br /&gt;&lt;font face="monospace"&gt;&lt;br /&gt;&lt;font color="#ff6060"&gt;&lt;b&gt;1 &lt;/b&gt;&lt;/font&gt;sudo aptitude install exim4 exim4-base&lt;br&gt;&lt;br /&gt;&lt;/font&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;and to configure simply run:&lt;br /&gt;&lt;div class="code"&gt;&lt;br /&gt;&lt;font face="monospace"&gt;&lt;br /&gt;&lt;font color="#ff6060"&gt;&lt;b&gt;1 &lt;/b&gt;&lt;/font&gt;sudo dpkg-reconfigure exim4-config&lt;br&gt;&lt;br /&gt;&lt;/font&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;and in the first dialog (image below) select "internet site". For all next options I used the defaults that would allow local users and services to send emails locally and to remote addresses (i.e. gmail accounts).&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://bp2.blogger.com/_99Fzui5MBLY/R_wNst22ijI/AAAAAAAAAIg/MsRbq_NIIOQ/s1600-h/exim01.png"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;" src="http://bp2.blogger.com/_99Fzui5MBLY/R_wNst22ijI/AAAAAAAAAIg/MsRbq_NIIOQ/s320/exim01.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5187035932699036210" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Now to test the new server you can send a simple email to your Gmail account:&lt;br /&gt;&lt;div class="code"&gt;&lt;br /&gt;&lt;font face="monospace"&gt;&lt;br /&gt;&lt;font color="#ff6060"&gt;&lt;b&gt;1 &lt;/b&gt;&lt;/font&gt;mail -s test mygmail@gmail.com&lt;br&gt;&lt;br /&gt;&lt;font color="#ff6060"&gt;&lt;b&gt;2 &lt;/b&gt;&lt;/font&gt;test mail&lt;br&gt;&lt;br /&gt;&lt;font color="#ff6060"&gt;&lt;b&gt;3 &lt;/b&gt;&lt;/font&gt;.&lt;br&gt;&lt;br /&gt;&lt;font color="#ff6060"&gt;&lt;b&gt;4 &lt;/b&gt;&lt;/font&gt;Cc:&lt;br&gt;&lt;br /&gt;&lt;/font&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;The "-s" switch is the mail subject. After the command simply type whatever you want in the mail body. To finish the email press &lt;enter&gt; followed by a dot "." and then &lt;enter&gt; again. After this you will be prompted with "Cc:" so press &lt;enter&gt; and then check your Gmail account. You should have received an email with the message and subject you used above.&lt;br /&gt;&lt;br /&gt;Now say you want to receive &lt;a href="http://piao-tech.blogspot.com/2007/04/receive-log-reports-via-email-ubuntu.html"&gt;LogWatch&lt;/a&gt; reports or any other mail directed to root in your Gmail account. Then you can simply create an alias in the "/etc/aliases" file like:&lt;br /&gt;&lt;div class="code"&gt;&lt;br /&gt;&lt;font face="monospace"&gt;&lt;br /&gt;&lt;font color="#ff6060"&gt;&lt;b&gt;1 &lt;/b&gt;&lt;/font&gt;&lt;font color="#00ffff"&gt;&lt;b&gt;# Added by installer for initial user&lt;/b&gt;&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#ff6060"&gt;&lt;b&gt;2 &lt;/b&gt;&lt;/font&gt;&lt;font color="#00ffff"&gt;&lt;b&gt;root&lt;/b&gt;&lt;/font&gt;&lt;font color="#ff6060"&gt;&lt;b&gt;:&lt;/b&gt;&lt;/font&gt;&amp;nbsp;&amp;nbsp; &lt;font color="#ff40ff"&gt;&lt;b&gt;mygmail@gmail.com&lt;/b&gt;&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;/font&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;then rebuild the aliases database&lt;br /&gt;&lt;div class="code"&gt;&lt;br /&gt;&lt;font face="monospace"&gt;&lt;br /&gt;&lt;font color="#ff6060"&gt;&lt;b&gt;1 &lt;/b&gt;&lt;/font&gt;sudo newaliases&lt;br&gt;&lt;br /&gt;&lt;/font&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;If you require more complex mail configurations you may check my previous posts about Sendmail and Postfix setup in (K)Ubuntu &lt;a href="http://piao-tech.blogspot.com/2007/03/linux-mail-server-setup.html"&gt;here&lt;/a&gt;.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/34829202-1771592333071915074?l=piao-tech.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://piao-tech.blogspot.com/feeds/1771592333071915074/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://piao-tech.blogspot.com/2008/04/simple-mail-server-kubuntu.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/34829202/posts/default/1771592333071915074'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/34829202/posts/default/1771592333071915074'/><link rel='alternate' type='text/html' href='http://piao-tech.blogspot.com/2008/04/simple-mail-server-kubuntu.html' title='Simple Mail Server (Kubuntu)'/><author><name>龍神</name><uri>http://www.blogger.com/profile/16648963337079496096</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://bp2.blogger.com/_99Fzui5MBLY/R_wNst22ijI/AAAAAAAAAIg/MsRbq_NIIOQ/s72-c/exim01.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-34829202.post-5024787254007856300</id><published>2008-04-04T15:46:00.006+09:00</published><updated>2008-04-04T17:11:35.342+09:00</updated><title type='text'>Get latest ffmpeg (svn) in FreeBSD-7.0</title><content type='html'>If you want to compile the latest ffmpeg from subversion with some external libraries support like x264, faac, Theora and Vorbis in the latest FreeBSD release (7.0) then follow this simple steps:&lt;br /&gt;&lt;br /&gt;If you do not have the ports tree installed (i.e. /usr/ports is empty or non existent) then you can use portsnap to download and update it (these commands must be done as root):&lt;br /&gt;&lt;div class="code"&gt;&lt;br /&gt;&lt;font face="monospace"&gt;&lt;br /&gt;&lt;font color="#ff6060"&gt;&lt;b&gt;1 &lt;/b&gt;&lt;/font&gt;pkg_add &lt;font color="#ff6060"&gt;&lt;b&gt;-r&lt;/b&gt;&lt;/font&gt;&amp;nbsp;portsnap&lt;br&gt;&lt;br /&gt;&lt;font color="#ff6060"&gt;&lt;b&gt;2 &lt;/b&gt;&lt;/font&gt;mkdir /usr/ports&lt;br&gt;&lt;br /&gt;&lt;font color="#ff6060"&gt;&lt;b&gt;3 &lt;/b&gt;&lt;/font&gt;portsnap fetch&lt;br&gt;&lt;br /&gt;&lt;font color="#ff6060"&gt;&lt;b&gt;4 &lt;/b&gt;&lt;/font&gt;portsnap extract&lt;br&gt;&lt;br /&gt;&lt;font color="#ff6060"&gt;&lt;b&gt;5 &lt;/b&gt;&lt;/font&gt;portsnap update&lt;br&gt;&lt;br /&gt;&lt;/font&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;Install some ports to enable more funcionality in ffmpeg (these commands also must be done as root):&lt;br /&gt;&lt;div class="code"&gt;&lt;br /&gt;&lt;font face="monospace"&gt;&lt;br /&gt;&lt;font color="#ff6060"&gt;&lt;b&gt;&amp;nbsp;1 &lt;/b&gt;&lt;/font&gt;&lt;font color="#00ffff"&gt;&lt;b&gt;# faac support&lt;/b&gt;&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#ff6060"&gt;&lt;b&gt;&amp;nbsp;2 &lt;/b&gt;&lt;/font&gt;&lt;font color="#ffff00"&gt;&lt;b&gt;cd&lt;/b&gt;&lt;/font&gt;&amp;nbsp;/usr/ports/audio/faac&lt;br&gt;&lt;br /&gt;&lt;font color="#ff6060"&gt;&lt;b&gt;&amp;nbsp;3 &lt;/b&gt;&lt;/font&gt;make install clean&lt;br&gt;&lt;br /&gt;&lt;font color="#ff6060"&gt;&lt;b&gt;&amp;nbsp;4 &lt;/b&gt;&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#ff6060"&gt;&lt;b&gt;&amp;nbsp;5 &lt;/b&gt;&lt;/font&gt;&lt;font color="#00ffff"&gt;&lt;b&gt;# vorbis support&lt;/b&gt;&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#ff6060"&gt;&lt;b&gt;&amp;nbsp;6 &lt;/b&gt;&lt;/font&gt;&lt;font color="#ffff00"&gt;&lt;b&gt;cd&lt;/b&gt;&lt;/font&gt;&amp;nbsp;/usr/ports/audio/vorbis-tools&lt;br&gt;&lt;br /&gt;&lt;font color="#ff6060"&gt;&lt;b&gt;&amp;nbsp;7 &lt;/b&gt;&lt;/font&gt;make install clean&lt;br&gt;&lt;br /&gt;&lt;font color="#ff6060"&gt;&lt;b&gt;&amp;nbsp;8 &lt;/b&gt;&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#ff6060"&gt;&lt;b&gt;&amp;nbsp;9 &lt;/b&gt;&lt;/font&gt;&lt;font color="#00ffff"&gt;&lt;b&gt;# x264 support&lt;/b&gt;&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#ff6060"&gt;&lt;b&gt;10 &lt;/b&gt;&lt;/font&gt;&lt;font color="#ffff00"&gt;&lt;b&gt;cd&lt;/b&gt;&lt;/font&gt;&amp;nbsp;/usr/ports/multimedia/x264&lt;br&gt;&lt;br /&gt;&lt;font color="#ff6060"&gt;&lt;b&gt;11 &lt;/b&gt;&lt;/font&gt;make install clean&lt;br&gt;&lt;br /&gt;&lt;font color="#ff6060"&gt;&lt;b&gt;12 &lt;/b&gt;&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#ff6060"&gt;&lt;b&gt;13 &lt;/b&gt;&lt;/font&gt;&lt;font color="#00ffff"&gt;&lt;b&gt;# theora support&lt;/b&gt;&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#ff6060"&gt;&lt;b&gt;14 &lt;/b&gt;&lt;/font&gt;&lt;font color="#ffff00"&gt;&lt;b&gt;cd&lt;/b&gt;&lt;/font&gt;&amp;nbsp;/usr/ports/multimedia/libtheora&lt;br&gt;&lt;br /&gt;&lt;font color="#ff6060"&gt;&lt;b&gt;15 &lt;/b&gt;&lt;/font&gt;make install clean&lt;br&gt;&lt;br /&gt;&lt;font color="#ff6060"&gt;&lt;b&gt;16 &lt;/b&gt;&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#ff6060"&gt;&lt;b&gt;17 &lt;/b&gt;&lt;/font&gt;&lt;font color="#00ffff"&gt;&lt;b&gt;# ffplay support&lt;/b&gt;&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#ff6060"&gt;&lt;b&gt;18 &lt;/b&gt;&lt;/font&gt;&lt;font color="#ffff00"&gt;&lt;b&gt;cd&lt;/b&gt;&lt;/font&gt;&amp;nbsp;/usr/ports/deve/sdl12&lt;br&gt;&lt;br /&gt;&lt;font color="#ff6060"&gt;&lt;b&gt;19 &lt;/b&gt;&lt;/font&gt;make install clean&lt;br&gt;&lt;br /&gt;&lt;/font&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;Checkout ffmpeg from subversion, configure, compile and install (only the last command needs root priviledges);&lt;br /&gt;&lt;div class="code"&gt;&lt;br /&gt;&lt;font face="monospace"&gt;&lt;br /&gt;&lt;font color="#ff6060"&gt;&lt;b&gt;&amp;nbsp;1 &lt;/b&gt;&lt;/font&gt;&lt;font color="#00ffff"&gt;&lt;b&gt;# checkout ffmpeg from subversion&lt;/b&gt;&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#ff6060"&gt;&lt;b&gt;&amp;nbsp;2 &lt;/b&gt;&lt;/font&gt;svn co svn://svn.mplayerhq.hu/ffmpeg/trunk ffmpeg&lt;br&gt;&lt;br /&gt;&lt;font color="#ff6060"&gt;&lt;b&gt;&amp;nbsp;3 &lt;/b&gt;&lt;/font&gt;&lt;font color="#ffff00"&gt;&lt;b&gt;cd&lt;/b&gt;&lt;/font&gt;&amp;nbsp;ffmpeg&lt;br&gt;&lt;br /&gt;&lt;font color="#ff6060"&gt;&lt;b&gt;&amp;nbsp;4 &lt;/b&gt;&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#ff6060"&gt;&lt;b&gt;&amp;nbsp;5 &lt;/b&gt;&lt;/font&gt;&lt;font color="#00ffff"&gt;&lt;b&gt;# export library and include paths &lt;/b&gt;&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#ff6060"&gt;&lt;b&gt;&amp;nbsp;6 &lt;/b&gt;&lt;/font&gt;&lt;font color="#00ffff"&gt;&lt;b&gt;# so configure can find the external &lt;/b&gt;&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#ff6060"&gt;&lt;b&gt;&amp;nbsp;7 &lt;/b&gt;&lt;/font&gt;&lt;font color="#00ffff"&gt;&lt;b&gt;# libraries (i.e. x264)&lt;/b&gt;&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#ff6060"&gt;&lt;b&gt;&amp;nbsp;8 &lt;/b&gt;&lt;/font&gt;&lt;font color="#ffff00"&gt;&lt;b&gt;export&lt;/b&gt;&lt;/font&gt;&amp;nbsp;&lt;font color="#00ffff"&gt;&lt;b&gt;LIBRARY_PATH&lt;/b&gt;&lt;/font&gt;=/usr/local/lib&lt;br&gt;&lt;br /&gt;&lt;font color="#ff6060"&gt;&lt;b&gt;&amp;nbsp;9 &lt;/b&gt;&lt;/font&gt;&lt;font color="#ffff00"&gt;&lt;b&gt;export&lt;/b&gt;&lt;/font&gt;&amp;nbsp;&lt;font color="#00ffff"&gt;&lt;b&gt;CPATH&lt;/b&gt;&lt;/font&gt;=/usr/local/include&lt;br&gt;&lt;br /&gt;&lt;font color="#ff6060"&gt;&lt;b&gt;10 &lt;/b&gt;&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#ff6060"&gt;&lt;b&gt;11 &lt;/b&gt;&lt;/font&gt;&lt;font color="#00ffff"&gt;&lt;b&gt;# run configure with desired options&lt;/b&gt;&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#ff6060"&gt;&lt;b&gt;12 &lt;/b&gt;&lt;/font&gt;./configure &lt;font color="#ff6060"&gt;&lt;b&gt;--enable-gpl&lt;/b&gt;&lt;/font&gt;&amp;nbsp;&lt;font color="#ff6060"&gt;&lt;b&gt;--enable-pthreads&lt;/b&gt;&lt;/font&gt;&amp;nbsp;&lt;font color="#ffff00"&gt;&lt;b&gt;\&lt;/b&gt;&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#ff6060"&gt;&lt;b&gt;13 &lt;/b&gt;&lt;/font&gt;&amp;nbsp;&lt;font color="#ff6060"&gt;&lt;b&gt;--enable-shared&lt;/b&gt;&lt;/font&gt;&amp;nbsp;&lt;font color="#ff6060"&gt;&lt;b&gt;--enable-swscale&lt;/b&gt;&lt;/font&gt;&amp;nbsp;&amp;nbsp;&lt;font color="#ffff00"&gt;&lt;b&gt;\&lt;/b&gt;&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#ff6060"&gt;&lt;b&gt;14 &lt;/b&gt;&lt;/font&gt;&amp;nbsp;&lt;font color="#ff6060"&gt;&lt;b&gt;--enable-libx264&lt;/b&gt;&lt;/font&gt;&amp;nbsp;&lt;font color="#ff6060"&gt;&lt;b&gt;--enable-libfaac&lt;/b&gt;&lt;/font&gt;&amp;nbsp;&lt;font color="#ffff00"&gt;&lt;b&gt;\&lt;/b&gt;&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#ff6060"&gt;&lt;b&gt;15 &lt;/b&gt;&lt;/font&gt;&amp;nbsp;&lt;font color="#ff6060"&gt;&lt;b&gt;--enable-libtheora&lt;/b&gt;&lt;/font&gt;&amp;nbsp;&lt;font color="#ff6060"&gt;&lt;b&gt;--enable-libvorbis&lt;/b&gt;&lt;/font&gt;&amp;nbsp;&lt;font color="#ffff00"&gt;&lt;b&gt;\&lt;/b&gt;&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#ff6060"&gt;&lt;b&gt;16 &lt;/b&gt;&lt;/font&gt;&amp;nbsp;&lt;font color="#ff6060"&gt;&lt;b&gt;--enable-encoder=g726&lt;/b&gt;&lt;/font&gt;&amp;nbsp;&lt;font color="#ff6060"&gt;&lt;b&gt;--enable-encoder=ljpeg&lt;/b&gt;&lt;/font&gt;&amp;nbsp;&lt;font color="#ffff00"&gt;&lt;b&gt;\&lt;/b&gt;&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#ff6060"&gt;&lt;b&gt;17 &lt;/b&gt;&lt;/font&gt;&amp;nbsp;&lt;font color="#ff6060"&gt;&lt;b&gt;--enable-encoder=mjpeg&lt;/b&gt;&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#ff6060"&gt;&lt;b&gt;18 &lt;/b&gt;&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#ff6060"&gt;&lt;b&gt;19 &lt;/b&gt;&lt;/font&gt;&lt;font color="#00ffff"&gt;&lt;b&gt;# compile using GNU Make (gmake), not BSD Make&lt;/b&gt;&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#ff6060"&gt;&lt;b&gt;20 &lt;/b&gt;&lt;/font&gt;gmake&lt;br&gt;&lt;br /&gt;&lt;font color="#ff6060"&gt;&lt;b&gt;21 &lt;/b&gt;&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#ff6060"&gt;&lt;b&gt;22 &lt;/b&gt;&lt;/font&gt;&lt;font color="#00ffff"&gt;&lt;b&gt;# install&lt;/b&gt;&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#ff6060"&gt;&lt;b&gt;23 &lt;/b&gt;&lt;/font&gt;su root &lt;font color="#ff6060"&gt;&lt;b&gt;-c&lt;/b&gt;&lt;/font&gt;&amp;nbsp;&lt;font color="#ffff00"&gt;&lt;b&gt;'&lt;/b&gt;&lt;/font&gt;&lt;font color="#ff40ff"&gt;&lt;b&gt;gmake install&lt;/b&gt;&lt;/font&gt;&lt;font color="#ffff00"&gt;&lt;b&gt;'&lt;/b&gt;&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;/font&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;If you want to enable other external codec libraries supported by ffmpeg make sure to install their respective ports (if available) and then run the configure script with the desired libraries enabled. You can see a list of supported codec libraries with ".configure --help".&lt;br /&gt;&lt;br /&gt;Note that this instructions were tested with revision 12684 of ffmpeg subverion but ffmpeg is a very active project and this instructions are not guarantee to work with the latest subversion revision.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/34829202-5024787254007856300?l=piao-tech.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://piao-tech.blogspot.com/feeds/5024787254007856300/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://piao-tech.blogspot.com/2008/04/get-latest-ffmpeg-svn-in-freebsd-70.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/34829202/posts/default/5024787254007856300'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/34829202/posts/default/5024787254007856300'/><link rel='alternate' type='text/html' href='http://piao-tech.blogspot.com/2008/04/get-latest-ffmpeg-svn-in-freebsd-70.html' title='Get latest ffmpeg (svn) in FreeBSD-7.0'/><author><name>龍神</name><uri>http://www.blogger.com/profile/16648963337079496096</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-34829202.post-8464901854248479412</id><published>2008-04-03T10:57:00.000+09:00</published><updated>2008-04-03T11:20:04.375+09:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Tips'/><category scheme='http://www.blogger.com/atom/ns#' term='Kubuntu'/><title type='text'>Japanese Input in KDE 4.0.3 (Anthy)</title><content type='html'>So you want to try the newest and greatest KDE 4.0.3 release but you can't because you need to be able to write other languages other than English like in my case Japanese, Chinese and/or Korean?? &lt;br /&gt;&lt;br /&gt;After googling I found &lt;a href="http://www.nabble.com/Call-for-test-for-scim-bridge-td15405990.html"&gt;here&lt;/a&gt; that there is a scim input method that allows input of these languages in KDE4 and also fixes some problems with proprietary software like Skype, Adobe Reader, etc.&lt;br /&gt;&lt;br /&gt;This input method is called scim-bridge and can be easily installed in Kubuntu with the command:&lt;br /&gt;&lt;div class=code&gt;&lt;br /&gt;sudo aptitude install scim-bridge-agent scim-bridge-client-qt4 scim-bridge-client-qt scim-bridge-client-gtk &lt;br /&gt;&lt;/div&gt;&lt;br /&gt;Then to enable scim-bridge as your input method you can use im-switch:&lt;br /&gt;&lt;div class=code&gt;&lt;br /&gt;im-switch -s scim-bridge&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;or if you do not have im-switch then you can do it manually with:&lt;br /&gt;&lt;div class=code&gt;&lt;br /&gt;sudo ln -sf /etc/alternatives/xinput-all_ALL /etc/X11/xinit/xinput.d/scim-bridge &lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;Seems that scim-bridge is now the default input method in Ubuntu/Kubuntu but not sure, see resources below to get  more detailed explanation on how to setup SCIM in Ubuntu.&lt;br /&gt;&lt;br /&gt;&lt;a href="https://help.ubuntu.com/community/SCIM"&gt;https://help.ubuntu.com/community/SCIM&lt;/a&gt;&lt;br /&gt;&lt;a href="https://help.ubuntu.com/community/SCIM/Kubuntu"&gt;https://help.ubuntu.com/community/SCIM/Kubuntu&lt;/a&gt;&lt;br /&gt;&lt;a href="https://wiki.ubuntu.com/InputMethods/SCIM/Setup"&gt;https://wiki.ubuntu.com/InputMethods/SCIM/Setup&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/34829202-8464901854248479412?l=piao-tech.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://piao-tech.blogspot.com/feeds/8464901854248479412/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://piao-tech.blogspot.com/2008/04/japanese-input-in-kde-403-anthy.html#comment-form' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/34829202/posts/default/8464901854248479412'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/34829202/posts/default/8464901854248479412'/><link rel='alternate' type='text/html' href='http://piao-tech.blogspot.com/2008/04/japanese-input-in-kde-403-anthy.html' title='Japanese Input in KDE 4.0.3 (Anthy)'/><author><name>龍神</name><uri>http://www.blogger.com/profile/16648963337079496096</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-34829202.post-5398001950654493430</id><published>2008-03-03T23:05:00.001+09:00</published><updated>2008-03-05T09:58:54.603+09:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Android'/><category scheme='http://www.blogger.com/atom/ns#' term='Netbeans'/><title type='text'>Developing Android in Netbeans</title><content type='html'>Anyone who reads this blog would know that I like Netbeans a lot for mobile development (see &lt;a href="http://piao-tech.blogspot.com/2006/10/developing-for-japanese-phones-in.html"&gt;here&lt;/a&gt;, &lt;a href="http://piao-tech.blogspot.com/2006/10/developing-for-japanese-phones-in_06.html"&gt;here&lt;/a&gt;, &lt;a href="http://piao-tech.blogspot.com/2006/10/developing-for-japanese-phones-in_11.html"&gt;here&lt;/a&gt; and &lt;a href="http://piao-tech.blogspot.com/2007/06/doja-development-in-netbeans.html"&gt;here&lt;/a&gt;) and when I found that Google's mobile platform (&lt;a href="http://code.google.com/android/"&gt;Android&lt;/a&gt;) does not have a Netbeans plugin I was very disappointed. &lt;br /&gt;&lt;br /&gt;Of course Netbeans enthusiasts developed a plugin (&lt;a href="http://undroid.nolimit.cz/"&gt;Undroid&lt;/a&gt;) but it is not supported by Google, I could not get it to launch the emulator directly from the IDE and currently it does not work with the latest Android SDK so still we do not have a full solution for Android development in Netbeans.&lt;br /&gt;&lt;br /&gt;Now if you don't mind working in a mixed setting using Android tools from command line and using Netbeans to code, compile and install your Android applications then here is how you can do it.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Prerequisites&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;I assume you have the latest Netbeans 6.0.1 already installed and the latest Android SDK m5-rc14 also installed in your computer. I have tested this configuration in my Linux (Kubuntu) machine but should also work in Windows and other Linux distributions.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Creating a new project&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;The first thing is to create a new project using the  activityCreator.py script that comes with the Android SDK:&lt;br /&gt;&lt;div class="code"&gt;&lt;br /&gt;activityCreator.py --out HelloAndroid org.piaotech.android&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;this script will create the project skeleton and more important the build.xml file that can be used by Netbeans to build/install your Android applications.&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://bp0.blogger.com/_99Fzui5MBLY/R8wKuFfmXGI/AAAAAAAAAH4/JR9kFj0zC0o/s1600-h/android1.png"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;" src="http://bp0.blogger.com/_99Fzui5MBLY/R8wKuFfmXGI/AAAAAAAAAH4/JR9kFj0zC0o/s320/android1.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5173521858806832226" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Start Netbeans and create a new "Java Project with Existing Ant Script" as shown in the figure above. In the next screen browse the location of the project directory created by the activityCreator.py script (HelloAndroid above) and the rest of the fields will be filled automatically by Netbeans. You can change the project name if you wish but the default is ok.&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://bp2.blogger.com/_99Fzui5MBLY/R8wLxlfmXHI/AAAAAAAAAIA/vztA1rwN4Vk/s1600-h/android2.png"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;" src="http://bp2.blogger.com/_99Fzui5MBLY/R8wLxlfmXHI/AAAAAAAAAIA/vztA1rwN4Vk/s320/android2.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5173523018448002162" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;In the next screen (figure above) select the Ant tasks that each of the Netbeans commands should execute. I simply put &lt;span style="font-style:italic;"&gt;compile&lt;/span&gt; for &lt;span style="font-style:italic;"&gt;Build Project&lt;/span&gt; and &lt;span style="font-style:italic;"&gt;install&lt;/span&gt; for &lt;span style="font-style:italic;"&gt;Run Project&lt;/span&gt;.&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://bp3.blogger.com/_99Fzui5MBLY/R8wNR1fmXII/AAAAAAAAAII/KNJ4UqbKmLc/s1600-h/android3.png"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;" src="http://bp3.blogger.com/_99Fzui5MBLY/R8wNR1fmXII/AAAAAAAAAII/KNJ4UqbKmLc/s320/android3.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5173524672010411138" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;In the last screen make sure to add the &lt;span style="font-style:italic;"&gt;src&lt;/span&gt; and &lt;span style="font-style:italic;"&gt;res&lt;/span&gt; of the project to the &lt;span style="font-style:italic;"&gt;Source Package Folders&lt;/span&gt; as shown above.&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://bp0.blogger.com/_99Fzui5MBLY/R8wPeFfmXJI/AAAAAAAAAIQ/s0dih168VRM/s1600-h/android4.png"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;" src="http://bp0.blogger.com/_99Fzui5MBLY/R8wPeFfmXJI/AAAAAAAAAIQ/s0dih168VRM/s320/android4.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5173527081487064210" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;finally select &lt;span style="font-style:italic;"&gt;Java Sources Classpath&lt;/span&gt; in categories and add the &lt;span style="font-style:italic;"&gt;doc&lt;/span&gt; directory that is inside the Android SDK as shown in the picture above and press finish.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Running you project&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;Now you should have your new Android project in Netbeans project view and now you can code and build it as you would using any other Netbeans project. Now if you try to run the application you will get an error indicating that there is no device. This is because I still have not found a way to launch the emulator from within Netbeans so we must launch it manually. From the command line run the emulator:&lt;br /&gt;&lt;br /&gt;&lt;div class="code"&gt;&lt;br /&gt;android-sdk_m5-rc14_linux-x86/tools/emulator&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;now with the emulator running if you run your project from within Netbeans the Android application will be automatically installed in the emulator. &lt;br /&gt; &lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://bp1.blogger.com/_99Fzui5MBLY/R8wTCVfmXKI/AAAAAAAAAIY/dfg61PggLfg/s1600-h/android6.png"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;" src="http://bp1.blogger.com/_99Fzui5MBLY/R8wTCVfmXKI/AAAAAAAAAIY/dfg61PggLfg/s320/android6.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5173531002792205474" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;It takes some effort to setup an Android project in Netbeans and actually there is no benefit from doing this as any java editor with support for Ant scripts can do the same. In my case is simply a matter of preference as all my Java projects are in Netbeans I did not want to have a separate project format only for Android applications. &lt;br /&gt;&lt;br /&gt;Note that there is no need to close the emulator each time you rebuild your application so leave it running during the time you are developing. I also recommend you set up a console running the &lt;span style="font-style:italic;"&gt;adb logcat&lt;/span&gt; command so you can see all the debugging messages (Log.v()) that Android throws.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/34829202-5398001950654493430?l=piao-tech.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://piao-tech.blogspot.com/feeds/5398001950654493430/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://piao-tech.blogspot.com/2008/03/developing-android-in-netbeans.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/34829202/posts/default/5398001950654493430'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/34829202/posts/default/5398001950654493430'/><link rel='alternate' type='text/html' href='http://piao-tech.blogspot.com/2008/03/developing-android-in-netbeans.html' title='Developing Android in Netbeans'/><author><name>龍神</name><uri>http://www.blogger.com/profile/16648963337079496096</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://bp0.blogger.com/_99Fzui5MBLY/R8wKuFfmXGI/AAAAAAAAAH4/JR9kFj0zC0o/s72-c/android1.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-34829202.post-5727449121760402254</id><published>2008-02-23T17:56:00.000+09:00</published><updated>2008-02-23T17:58:32.256+09:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Others'/><title type='text'>Dr. Randy Pausch</title><content type='html'>A very inspirational talk by Dr. Randy Paush.&lt;br /&gt;&lt;br /&gt;&lt;object width="425" height="355"&gt;&lt;param name="movie" value="http://www.youtube.com/v/_tIyt8oSLVs&amp;rel=0&amp;color1=0x3a3a3a&amp;color2=0x999999&amp;border=0"&gt;&lt;/param&gt;&lt;param name="wmode" value="transparent"&gt;&lt;/param&gt;&lt;embed src="http://www.youtube.com/v/_tIyt8oSLVs&amp;rel=0&amp;color1=0x3a3a3a&amp;color2=0x999999&amp;border=0" type="application/x-shockwave-flash" wmode="transparent" width="425" height="355"&gt;&lt;/embed&gt;&lt;/object&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/34829202-5727449121760402254?l=piao-tech.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://piao-tech.blogspot.com/feeds/5727449121760402254/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://piao-tech.blogspot.com/2008/02/dr-randy-pausch.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/34829202/posts/default/5727449121760402254'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/34829202/posts/default/5727449121760402254'/><link rel='alternate' type='text/html' href='http://piao-tech.blogspot.com/2008/02/dr-randy-pausch.html' title='Dr. Randy Pausch'/><author><name>龍神</name><uri>http://www.blogger.com/profile/16648963337079496096</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-34829202.post-1761964076290030900</id><published>2008-02-22T01:25:00.005+09:00</published><updated>2008-03-05T09:59:07.860+09:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Tips'/><title type='text'>Reduce GIF size using RMagick</title><content type='html'>If you are creating GIF images using RMagick and your application has very stringent size restrictions (i.e. mobile devices) then this post may help you get the most of RMagick.&lt;br /&gt;&lt;br /&gt;While it is possible to control the compression of JPEG and PNG files using the quality parameter for GIF files we are left with almost no options. Fortunately a little understanding of the default, and only, compression scheme used in GIF can help you improve the compression performance of your images.&lt;br /&gt;&lt;br /&gt;The LZW compression algorithm used in GIF images and developed by Abraham Lempel, Jakob Ziv and Terry Welch, contructs a color table for an image wherein each color value is matched to a pixel. Thus, &lt;font color="#ff40ff"&gt;images with large areas of one color will be compressed far better than those that those that do not have such color blocks&lt;/font&gt;.&lt;br /&gt;&lt;br /&gt;So to get better compression (smaller images) we must ensure we have large contiguous blocks of the same color in our image. When creating images in ImageMagick we can use these tips to ensure small size results:&lt;br /&gt;&lt;br /&gt;First: Make use simple graphics with flat colors (i.e. avoid using  Magick::GradientFill).&lt;br /&gt;&lt;br /&gt;Second: when using an RMagick::Draw object always make sure you call the stroke_antialias(false) method on it:&lt;br /&gt;&lt;br /&gt;&lt;div class="code"&gt;&lt;br /&gt;&lt;font face="monospace"&gt;&lt;br /&gt;&lt;font color="#00ffff"&gt;1 &lt;/font&gt;&lt;font color="#ff6060"&gt;require&lt;/font&gt;&amp;nbsp;&lt;font color="#008080"&gt;&amp;quot;&lt;/font&gt;&lt;font color="#ff40ff"&gt;RMagick&lt;/font&gt;&lt;font color="#008080"&gt;&amp;quot;&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#00ffff"&gt;2 &lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#00ffff"&gt;3 &lt;/font&gt;gc = &lt;font color="#00ff00"&gt;Magick&lt;/font&gt;::&lt;font color="#00ff00"&gt;Draw&lt;/font&gt;.new&lt;br&gt;&lt;br /&gt;&lt;font color="#00ffff"&gt;4 &lt;/font&gt;gc.stroke_antialias(&lt;font color="#ff40ff"&gt;false&lt;/font&gt;)&lt;br&gt;&lt;br /&gt;&lt;font color="#00ffff"&gt;5 &lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#00ffff"&gt;6 &lt;/font&gt;&lt;font color="#ff6060"&gt;# your drawing code below&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;/font&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;Third: When writing text using the annotate method from the Magick::Draw or Magick::Image classes do not use text antialiasing:&lt;br /&gt;&lt;br /&gt;&lt;div class="code"&gt;&lt;br /&gt;&lt;font face="monospace"&gt;&lt;br /&gt;&lt;font color="#00ffff"&gt;1 &lt;/font&gt;&lt;font color="#ff6060"&gt;require&lt;/font&gt;&amp;nbsp;&lt;font color="#008080"&gt;&amp;quot;&lt;/font&gt;&lt;font color="#ff40ff"&gt;RMagick&lt;/font&gt;&lt;font color="#008080"&gt;&amp;quot;&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#00ffff"&gt;2 &lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#00ffff"&gt;3 &lt;/font&gt;gc = &lt;font color="#00ff00"&gt;Magick&lt;/font&gt;::&lt;font color="#00ff00"&gt;Draw&lt;/font&gt;.new&lt;br&gt;&lt;br /&gt;&lt;font color="#00ffff"&gt;4 &lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#00ffff"&gt;5 &lt;/font&gt;gc.annotate(img,...) {&lt;br&gt;&lt;br /&gt;&lt;font color="#00ffff"&gt;6 &lt;/font&gt;&amp;nbsp;&amp;nbsp;&lt;font color="#ff40ff"&gt;self&lt;/font&gt;.text_antialias = &lt;font color="#ff40ff"&gt;false&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#00ffff"&gt;7 &lt;/font&gt;}&lt;br&gt;&lt;br /&gt;&lt;/font&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;A very simple method to reduce the image size is using the despeckle filter on the image. This will reduce the color dither making the color distribution more planar so we have larger portions of the image with the same color. By doing this the LZW algorithm can reduce the final image size up to a 20% of the original size depending on the image.&lt;br /&gt;&lt;br /&gt;&lt;div class="code"&gt;&lt;br /&gt;&lt;font face="monospace"&gt;&lt;br /&gt;&lt;font color="#00ffff"&gt;1 &lt;/font&gt;&lt;font color="#ff6060"&gt;require&lt;/font&gt;&amp;nbsp;&lt;font color="#008080"&gt;&amp;quot;&lt;/font&gt;&lt;font color="#ff40ff"&gt;RMagick&lt;/font&gt;&lt;font color="#008080"&gt;&amp;quot;&lt;/font&gt;&lt;br&gt;&lt;font color="#00ffff"&gt;2 &lt;/font&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br&gt;&lt;font color="#00ffff"&gt;3 &lt;/font&gt;small_image = big_image.despeckle&lt;br&gt;&lt;font color="#00ffff"&gt;4 &lt;/font&gt;small_image.write(&lt;font color="#008080"&gt;&amp;quot;&lt;/font&gt;&lt;font color="#ff40ff"&gt;small_image.gif&lt;/font&gt;&lt;font color="#008080"&gt;&amp;quot;&lt;/font&gt;){&lt;br&gt;&lt;font color="#00ffff"&gt;5 &lt;/font&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;font color="#ff40ff"&gt;self&lt;/font&gt;.compression = &lt;font color="#00ff00"&gt;Magick&lt;/font&gt;::&lt;font color="#00ff00"&gt;LZWCompression&lt;/font&gt;&lt;br&gt;&lt;font color="#00ffff"&gt;6 &lt;/font&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;font color="#ff40ff"&gt;self&lt;/font&gt;.dither = &lt;font color="#ff40ff"&gt;false&lt;/font&gt;&lt;br&gt;&lt;font color="#00ffff"&gt;7 &lt;/font&gt;}&lt;br&gt;&lt;br /&gt;&lt;/font&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;Actually calling self.compression is not needed as it is set by default by RMagick but is good just to make sure.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Resources&lt;/b&gt;&lt;br /&gt;&lt;a href="http://rmagick.rubyforge.org/"&gt;http://rmagick.rubyforge.org/&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.faqs.org/faqs/jpeg-faq/part1/section-9.html"&gt;http://www.faqs.org/faqs/jpeg-faq/part1/section-9.html&lt;/a&gt;&lt;br /&gt;&lt;a href="http://rmagick.rubyforge.org/src_over.html"&gt;http://rmagick.rubyforge.org/src_over.html&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.webdevelopersnotes.com/graphics/gifs_compression_algorithm.php3"&gt;http://www.webdevelopersnotes.com/graphics/gifs_compression_algorithm.php3&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/34829202-1761964076290030900?l=piao-tech.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://piao-tech.blogspot.com/feeds/1761964076290030900/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://piao-tech.blogspot.com/2008/02/reduce-gif-size-using-rmagick.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/34829202/posts/default/1761964076290030900'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/34829202/posts/default/1761964076290030900'/><link rel='alternate' type='text/html' href='http://piao-tech.blogspot.com/2008/02/reduce-gif-size-using-rmagick.html' title='Reduce GIF size using RMagick'/><author><name>龍神</name><uri>http://www.blogger.com/profile/16648963337079496096</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-34829202.post-1149297315102967550</id><published>2008-02-18T18:43:00.007+09:00</published><updated>2008-03-05T09:59:34.046+09:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Ruby'/><category scheme='http://www.blogger.com/atom/ns#' term='Rails'/><title type='text'>Using ActiveRecord with Microsoft SQL Server (MSSQL)</title><content type='html'>There seems to be a lot of confusion on how to use ActiveRecord from Ruby on Rails to query a MSSQL (Microsoft SQL) Database. During my last two projects I had to research this topic and found that this confusion stems from the fact that the documentation is sparced all over the web and most of the time it is incomplete and misleading.&lt;br /&gt;&lt;br /&gt;After some tests and real projects I found there are mainly two ways to get ActiveRecord working with a MSSQL Database server: (1) Using the ADO driver and (2) using an ODBC driver. How these methods are used differ if we are in a Windows client or in a Linux client so we get a total of four different ways to connect ActiveRecord to MSSQL, in fact I only got three as we will see later, but in theory there can be four if I get ADO to work in Linux.&lt;br /&gt;&lt;br /&gt;The confusion most people new to this topic confront is that the documentation found in the web usually mention these methods separately and without much detail on the configuration. For example some pages in the web explain how to connect to MSSQL using the ADO driver but they don't mention that this works only if you are using a Windows client where win32ole can be installed. Some others talk about success using ODBC and present the configuration but do not explain how to create the DSN needed for connection because they assume this is common knowledge (it was not for me).&lt;br /&gt;&lt;br /&gt;To avoid the pain I had to suffer when getting my work done to others, here I present my experiences in this topic in four subsections. Each one explains how to use the ADO or ODBC methods from a Windows or Linux client.&lt;br /&gt;&lt;br /&gt;&lt;B&gt;Windows Client using ADO driver&lt;/B&gt;&lt;br /&gt;&lt;br /&gt;I have tested this configuration using a WinXP Home client with the ruby one click installer (184-20 and 186-26) connecting to a Windows Server 2003 running Microsoft SQL Enterprise 2000 SP3.&lt;br /&gt;&lt;br /&gt;To start download an extract the ruby-dbi package (&lt;a href="https://rubyforge.org/frs/download.php/12368/dbi-0.1.1.tar.gz"&gt;dbi-0.1.1.tar.gz&lt;/a&gt;) somewhere in your Windows machine.&lt;br /&gt;&lt;br /&gt;The following instructions are to be executed from within a command shell (cmd.exe).&lt;br /&gt;&lt;br /&gt;&lt;div class="code"&gt;&lt;br /&gt;&lt;font face="monospace"&gt;&lt;br /&gt;&lt;font color="#ffff00"&gt;1 &lt;/font&gt;gem update &lt;font color="#ffa500"&gt;--system&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#ffff00"&gt;2 &lt;/font&gt;gem install activerecord-sqlserver-adapter &lt;font color="#ffa500"&gt;--source=&lt;a href="http://gems.rubyonrails.org"&gt;http://gems.rubyonrails.org&lt;/a&gt;&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#ffff00"&gt;3 &lt;/font&gt;mkdir c:\ruby\lib\ruby\site_ruby\&lt;font color="#ffa0a0"&gt;1&lt;/font&gt;.&lt;font color="#ffa0a0"&gt;8&lt;/font&gt;\DBD\ADO&lt;br&gt;&lt;br /&gt;&lt;font color="#ffff00"&gt;4 &lt;/font&gt;copy ruby-dbi\lib\dbd\ADO.rb c:\ruby\lib\ruby\site_ruby\&lt;font color="#ffa0a0"&gt;1&lt;/font&gt;.&lt;font color="#ffa0a0"&gt;8&lt;/font&gt;\DBD\ADO&lt;br&gt;&lt;br /&gt;&lt;/font&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;These commands simply update the RubyGems system and install the Active Record gem with all dependencies needed to connect to MSSQL. We then copy the ADO driver from ruby-dbi inside our ruby install directory. If you have ruby installed in a place other than "c:\ruby" make the appropiate changes to the commands above.&lt;br /&gt;&lt;br /&gt;Now in your code you can connect to the MSSQL database using the following:&lt;br /&gt;&lt;br /&gt;&lt;div class="code"&gt;&lt;br /&gt;&lt;font face="monospace"&gt;&lt;br /&gt;&lt;font color="#ffff00"&gt;1 &lt;/font&gt;&lt;font color="#60ff60"&gt;ActiveRecord&lt;/font&gt;::&lt;font color="#60ff60"&gt;Base&lt;/font&gt;.establish_connection(&lt;br&gt;&lt;br /&gt;&lt;font color="#ffff00"&gt;2 &lt;/font&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;font color="#ffa0a0"&gt;:adapter&lt;/font&gt;&amp;nbsp;=&amp;gt; &lt;font color="#ffa500"&gt;&amp;quot;&lt;/font&gt;&lt;font color="#ffa0a0"&gt;sqlserver&lt;/font&gt;&lt;font color="#ffa500"&gt;&amp;quot;&lt;/font&gt;,&lt;br&gt;&lt;br /&gt;&lt;font color="#ffff00"&gt;3 &lt;/font&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;font color="#ffa0a0"&gt;:mode&lt;/font&gt;&amp;nbsp;=&amp;gt; &lt;font color="#ffa500"&gt;&amp;quot;&lt;/font&gt;&lt;font color="#ffa0a0"&gt;ADO&lt;/font&gt;&lt;font color="#ffa500"&gt;&amp;quot;&lt;/font&gt;,&lt;br&gt;&lt;br /&gt;&lt;font color="#ffff00"&gt;4 &lt;/font&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;font color="#ffa0a0"&gt;:username&lt;/font&gt;&amp;nbsp;=&amp;gt; &lt;font color="#ffa500"&gt;&amp;quot;&lt;/font&gt;&lt;font color="#ffa0a0"&gt;youruser&lt;/font&gt;&lt;font color="#ffa500"&gt;&amp;quot;&lt;/font&gt;,&lt;br&gt;&lt;br /&gt;&lt;font color="#ffff00"&gt;5 &lt;/font&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;font color="#ffa0a0"&gt;:password&lt;/font&gt;&amp;nbsp;=&amp;gt; &lt;font color="#ffa500"&gt;&amp;quot;&lt;/font&gt;&lt;font color="#ffa0a0"&gt;yourpass&lt;/font&gt;&lt;font color="#ffa500"&gt;&amp;quot;&lt;/font&gt;,&lt;br&gt;&lt;br /&gt;&lt;font color="#ffff00"&gt;6 &lt;/font&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;font color="#ffa0a0"&gt;:host&lt;/font&gt;&amp;nbsp;=&amp;gt; &lt;font color="#ffa500"&gt;&amp;quot;&lt;/font&gt;&lt;font color="#ffa0a0"&gt;serverhostname_or_ipaddress&lt;/font&gt;&lt;font color="#ffa500"&gt;&amp;quot;&lt;/font&gt;,&lt;br&gt;&lt;br /&gt;&lt;font color="#ffff00"&gt;7 &lt;/font&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;font color="#ffa0a0"&gt;:database&lt;/font&gt;&amp;nbsp;=&amp;gt; &lt;font color="#ffa500"&gt;&amp;quot;&lt;/font&gt;&lt;font color="#ffa0a0"&gt;YourDbName&lt;/font&gt;&lt;font color="#ffa500"&gt;&amp;quot;&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#ffff00"&gt;8 &lt;/font&gt;) &lt;br&gt;&lt;br /&gt;&lt;/font&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;I have tested this configuration with ActiveRecord version 1.14.4 and 2.0.2 but I assume this should work with all version in between too.&lt;br /&gt;&lt;br /&gt;&lt;B&gt;Windows Client using ODBC&lt;/B&gt;&lt;br /&gt;&lt;br /&gt;I have only tested this with the latest ActiveRecord 2.0.2 so I don't know if this works with previous versions and using a WinXP Home client with the ruby one click installer (184-20 and 186-26) connecting to a Windows Server 2003 running Microsoft SQL Enterprise 2000 SP3&lt;br /&gt;&lt;br /&gt;The following instructions are to be executed from within a command shell (cmd.exe).&lt;br /&gt;&lt;br /&gt;&lt;div class="code"&gt;&lt;br /&gt;&lt;font face="monospace"&gt;&lt;br /&gt;&lt;font color="#ffff00"&gt;1 &lt;/font&gt;gem update &lt;font color="#ffa500"&gt;--system&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#ffff00"&gt;2 &lt;/font&gt;gem install activerecord-sqlserver-adapter &lt;font color="#ffa500"&gt;--source=&lt;a href="http://gems.rubyonrails.org"&gt;http://gems.rubyonrails.org&lt;/a&gt;&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;/font&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;As with the ADO driver these commands simply update the RubyGems system and install the ActiveRecord gem with all dependencies needed to connect to MSSQL.&lt;br /&gt;&lt;br /&gt;The next step is where most documentation I have seen fails. They say you must specify a DSN to connect via ODBC but they do not mention what this DSN is or where to get it. I guess these gurus assume we must know this things or we would not be looking for this info but in my case it took me a while to figure out where this DSN thing is supposed to come from.&lt;br /&gt;&lt;br /&gt;The DSN (Data Source Name) must be created and in Windows we do it by using a tool called "odbcad32.exe" or choosing "Data Sources (ODBC)" from the "Administrative Tools" inside Windows "Control Panel". For instructions on how to use this tool refer to the detailed explanation at &lt;a href="http://www.truthsolutions.com/sql/odbc/creating_a_new_odbc_dsn.htm"&gt;www.truthsolutions.com&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;&lt;a href="http://bp2.blogger.com/_99Fzui5MBLY/R7k_mS-COxI/AAAAAAAAAHo/OGcEcPsjf7Y/s1600-h/fig1.jpg"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;" src="http://bp2.blogger.com/_99Fzui5MBLY/R7k_mS-COxI/AAAAAAAAAHo/OGcEcPsjf7Y/s320/fig1.jpg" border="0" alt=""id="BLOGGER_PHOTO_ID_5168231974543964946" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;When creating the new DSN make note of the name you set on it (see figure above) because this is the name you must use to connect to the MSSQL server when using ActiveRecord. Also make sure you select the "SQL Server" driver as instructed at &lt;a href="http://www.truthsolutions.com/sql/odbc/creating_a_new_odbc_dsn.htm"&gt;www.truthsolutions.com&lt;/a&gt;. The authentication method depends on how you have your MSSQL server configured but I always use the using Login and Password entered by the user option so I don't know about the network login ID option. At the end make sure you test the DSN to make sure it is valid and is working.&lt;br /&gt;&lt;br /&gt;Once the DSN is created you can connect to the MSSQL server using ActiveRecord like:&lt;br /&gt;&lt;br /&gt;&lt;div class="code"&gt;&lt;br /&gt;&lt;font face="monospace"&gt;&lt;br /&gt;&lt;font color="#ffff00"&gt;1 &lt;/font&gt;&lt;font color="#60ff60"&gt;ActiveRecord&lt;/font&gt;::&lt;font color="#60ff60"&gt;Base&lt;/font&gt;.establish_connection(&lt;br&gt;&lt;br /&gt;&lt;font color="#ffff00"&gt;2 &lt;/font&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;font color="#ffa0a0"&gt;:adapter&lt;/font&gt;&amp;nbsp;=&amp;gt; &lt;font color="#ffa500"&gt;&amp;quot;&lt;/font&gt;&lt;font color="#ffa0a0"&gt;sqlserver&lt;/font&gt;&lt;font color="#ffa500"&gt;&amp;quot;&lt;/font&gt;,&lt;br&gt;&lt;br /&gt;&lt;font color="#ffff00"&gt;3 &lt;/font&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;font color="#ffa0a0"&gt;:mode&lt;/font&gt;&amp;nbsp;=&amp;gt; &lt;font color="#ffa500"&gt;&amp;quot;&lt;/font&gt;&lt;font color="#ffa0a0"&gt;odbc&lt;/font&gt;&lt;font color="#ffa500"&gt;&amp;quot;&lt;/font&gt;,&lt;br&gt;&lt;br /&gt;&lt;font color="#ffff00"&gt;4 &lt;/font&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;font color="#ffa0a0"&gt;:username&lt;/font&gt;&amp;nbsp;=&amp;gt; &lt;font color="#ffa500"&gt;&amp;quot;&lt;/font&gt;&lt;font color="#ffa0a0"&gt;youruser&lt;/font&gt;&lt;font color="#ffa500"&gt;&amp;quot;&lt;/font&gt;,&lt;br&gt;&lt;br /&gt;&lt;font color="#ffff00"&gt;5 &lt;/font&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;font color="#ffa0a0"&gt;:password&lt;/font&gt;&amp;nbsp;=&amp;gt; &lt;font color="#ffa500"&gt;&amp;quot;&lt;/font&gt;&lt;font color="#ffa0a0"&gt;yourpass&lt;/font&gt;&lt;font color="#ffa500"&gt;&amp;quot;&lt;/font&gt;,&lt;br&gt;&lt;br /&gt;&lt;font color="#ffff00"&gt;6 &lt;/font&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;font color="#ffa0a0"&gt;:dsn&lt;/font&gt;&amp;nbsp;=&amp;gt; &lt;font color="#ffa500"&gt;&amp;quot;&lt;/font&gt;&lt;font color="#ffa0a0"&gt;SQLServer&lt;/font&gt;&lt;font color="#ffa500"&gt;&amp;quot;&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#ffff00"&gt;7 &lt;/font&gt;) &lt;br&gt;&lt;br /&gt;&lt;/font&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;and make sure to replace "SQLServer" with the DSN name you set up when creating it using the "odbcad32.exe" tool.&lt;br /&gt;&lt;br /&gt;&lt;B&gt;Linux Client using ODBC&lt;/B&gt;&lt;br /&gt;&lt;br /&gt;The following instructions were tested in Kubuntu Gusty (7.10) using the latest ActiveRecord 2.0.2 as client connecting to a Windows Server 2003 running Microsoft SQL Enterprise 2000 SP3.&lt;br /&gt;&lt;br /&gt;From console install the following packages:&lt;br /&gt;&lt;br /&gt;&lt;div class="code"&gt;&lt;br /&gt;&lt;font face="monospace"&gt;&lt;br /&gt;&lt;font color="#ffff00"&gt;1 &lt;/font&gt;sudo aptitude install ruby1.&lt;font color="#ffa0a0"&gt;8&lt;/font&gt;&amp;nbsp;unixodbc tdsodbc libodbc-ruby1.&lt;font color="#ffa0a0"&gt;8&lt;/font&gt;&amp;nbsp;rubygems&lt;br&gt;&lt;br /&gt;&lt;/font&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;Next you can choose to install ActiveRecord using Ubuntu repositories or using RubyGems repositories. I chose to use RubyGems as this provides the latest versions and is updated more often.&lt;br /&gt;&lt;br /&gt;&lt;div class="code"&gt;&lt;br /&gt;&lt;font face="monospace"&gt;&lt;br /&gt;&lt;font color="#ffff00"&gt;1 &lt;/font&gt;sudo gem install activerecord-sqlserver-adapter &lt;font color="#ffa500"&gt;--source=&lt;a href="http://gems.rubyonrails.org"&gt;http://gems.rubyonrails.org&lt;/a&gt;&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;/font&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;Now as in Windows we must create a DSN for unixODBC. The first step is to add the freeTDS driver to unixODBC and to to this we create a configuration file (simple text file) called for example "myodbcdriver.ini" that contains:&lt;br /&gt;&lt;br /&gt;&lt;div class="code"&gt;&lt;br /&gt;&lt;font face="monospace"&gt;&lt;br /&gt;&lt;font color="#ffff00"&gt;1 &lt;/font&gt;&lt;font color="#ffa500"&gt;[FreeTDS]&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#ffff00"&gt;2 &lt;/font&gt;&lt;font color="#60ff60"&gt;Description&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; =&lt;/font&gt;&amp;nbsp;TDS driver (Sybase/MS SQL)&lt;br&gt;&lt;br /&gt;&lt;font color="#ffff00"&gt;3 &lt;/font&gt;&lt;font color="#60ff60"&gt;Driver&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;=&lt;/font&gt;&amp;nbsp;/usr/lib/odbc/libtdsodbc.so&lt;br&gt;&lt;br /&gt;&lt;font color="#ffff00"&gt;4 &lt;/font&gt;&lt;font color="#60ff60"&gt;Setup&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; =&lt;/font&gt;&amp;nbsp;/usr/lib/odbc/libtdsS.so&lt;br&gt;&lt;br /&gt;&lt;font color="#ffff00"&gt;5 &lt;/font&gt;&lt;font color="#60ff60"&gt;CPTimeout&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; =&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#ffff00"&gt;6 &lt;/font&gt;&lt;font color="#60ff60"&gt;CPReuse&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; =&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;/font&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;If you are not using Kubuntu/Ubuntu then make sure you have installed unixODBC and the freeTDS ODBC driver and change the "Driver" and "Setup" paths to reflect your system installation. In Kubuntu the "tdsodbc" package we installed above provides us with this configuration file in "/usr/share/tdsodbc/odbcinst.ini" so we do not need to create it.&lt;br /&gt;&lt;br /&gt;With this configuration we can add the freeTDS driver to unixODBC by issuing the following command:&lt;br /&gt;&lt;div class="code"&gt;&lt;br /&gt;&lt;font face="monospace"&gt;&lt;br /&gt;&lt;font color="#ffff00"&gt;1 &lt;/font&gt;sudo odbcinst &lt;font color="#ffa500"&gt;-i&lt;/font&gt;&amp;nbsp;&lt;font color="#ffa500"&gt;-d&lt;/font&gt;&amp;nbsp;&lt;font color="#ffa500"&gt;-f&lt;/font&gt;&amp;nbsp;myodbcdriver.ini&lt;br&gt;&lt;br /&gt;&lt;/font&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;or in Kubuntu that provides the configuration file&lt;br /&gt;&lt;br /&gt;&lt;div class="code"&gt;&lt;br /&gt;&lt;font face="monospace"&gt;&lt;br /&gt;&lt;font color="#ffff00"&gt;1 &lt;/font&gt;sudo odbcinst &lt;font color="#ffa500"&gt;-i&lt;/font&gt;&amp;nbsp;&lt;font color="#ffa500"&gt;-d&lt;/font&gt;&amp;nbsp;&lt;font color="#ffa500"&gt;-f&lt;/font&gt;&amp;nbsp;/usr/share/tdsodbc/odbcinst.ini&lt;br&gt;&lt;br /&gt;&lt;/font&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;Next we must create a DSN configuration file, say mydsn.ini, that looks like:&lt;br /&gt;&lt;br /&gt;&lt;div class="code"&gt;&lt;br /&gt;&lt;font face="monospace"&gt;&lt;br /&gt;&lt;font color="#ffff00"&gt;1 &lt;/font&gt;&lt;font color="#ffa500"&gt;[SQLServer]&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#ffff00"&gt;2 &lt;/font&gt;&lt;font color="#60ff60"&gt;Driver&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;=&lt;/font&gt;&amp;nbsp;FreeTDS&lt;br&gt;&lt;br /&gt;&lt;font color="#ffff00"&gt;3 &lt;/font&gt;&lt;font color="#60ff60"&gt;Description =&lt;/font&gt;&amp;nbsp;My First SQLServer Database&lt;br&gt;&lt;br /&gt;&lt;font color="#ffff00"&gt;4 &lt;/font&gt;&lt;font color="#60ff60"&gt;Trace&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; =&lt;/font&gt;&amp;nbsp;No&lt;br&gt;&lt;br /&gt;&lt;font color="#ffff00"&gt;5 &lt;/font&gt;&lt;font color="#60ff60"&gt;Server&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;=&lt;/font&gt;&amp;nbsp;hostname_or_ipaddress&lt;br&gt;&lt;br /&gt;&lt;font color="#ffff00"&gt;6 &lt;/font&gt;&lt;font color="#60ff60"&gt;Port&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;=&lt;/font&gt;&amp;nbsp;1433&lt;br&gt;&lt;br /&gt;&lt;font color="#ffff00"&gt;7 &lt;/font&gt;&lt;font color="#60ff60"&gt;Database&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;=&lt;/font&gt;&amp;nbsp;SQLServerDB&lt;br&gt;&lt;br /&gt;&lt;/font&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;As in Windows take note of the name you set to the DSN ([SQLServer]) as this is used for the connection. Finally we add the DSN to unixODBC with the following command:&lt;br /&gt;&lt;br /&gt;&lt;div class="code"&gt;&lt;br /&gt;&lt;font face="monospace"&gt;&lt;br /&gt;&lt;font color="#ffff00"&gt;1 &lt;/font&gt;odbcinst &lt;font color="#ffa500"&gt;-i&lt;/font&gt;&amp;nbsp;&lt;font color="#ffa500"&gt;-s&lt;/font&gt;&amp;nbsp;&lt;font color="#ffa500"&gt;-f&lt;/font&gt;&amp;nbsp;mydsn.ini &lt;font color="#ffa500"&gt;-h&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;/font&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;Note that we execute this command without the "sudo" because we are installing a User DSN that will be accessible only to the system user that installed the DSN. To install a system wide DSN we use a similar command but with the "-l" switch instead of the "-h".&lt;br /&gt;&lt;br /&gt;&lt;div class="code"&gt;&lt;br /&gt;&lt;font face="monospace"&gt;&lt;br /&gt;&lt;font color="#ffff00"&gt;1 &lt;/font&gt;odbcinst &lt;font color="#ffa500"&gt;-i&lt;/font&gt;&amp;nbsp;&lt;font color="#ffa500"&gt;-s&lt;/font&gt;&amp;nbsp;&lt;font color="#ffa500"&gt;-f&lt;/font&gt;&amp;nbsp;mydsn.ini &lt;font color="#ffa500"&gt;-l&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;/font&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;You can run the odbcinst command without any arguments to get a list of possible options. To test the newly created DSN we can use the isql command tool that comes with unixODBC:&lt;br /&gt;&lt;br /&gt;&lt;div class="code"&gt;&lt;br /&gt;&lt;font face="monospace"&gt;&lt;br /&gt;&lt;font color="#ffff00"&gt;1 &lt;/font&gt;isql SQLServer username password&lt;br&gt;&lt;br /&gt;&lt;/font&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;replacing SQLServer with the name you used when creating the DSN and if everything is working you should get a message similar to:&lt;br /&gt;&lt;br /&gt;&lt;div class="code"&gt;&lt;br /&gt;&lt;font face="monospace"&gt;&lt;br /&gt;&lt;font color="#ffff00"&gt;1 &lt;/font&gt;+---------------------------------------+&lt;br&gt;&lt;br /&gt;&lt;font color="#ffff00"&gt;2 &lt;/font&gt;&lt;font color="#ffff00"&gt;|&lt;/font&gt;&amp;nbsp;Connected&lt;font color="#ffff00"&gt;!&lt;/font&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;font color="#ffff00"&gt;|&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#ffff00"&gt;3 &lt;/font&gt;&lt;font color="#ffff00"&gt;|&lt;/font&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;font color="#ffff00"&gt;|&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#ffff00"&gt;4 &lt;/font&gt;&lt;font color="#ffff00"&gt;|&lt;/font&gt;&amp;nbsp;sql-statement&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;font color="#ffff00"&gt;|&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#ffff00"&gt;5 &lt;/font&gt;&lt;font color="#ffff00"&gt;|&lt;/font&gt;&amp;nbsp;help &lt;font color="#ffff00"&gt;[&lt;/font&gt;tablename&lt;font color="#ffff00"&gt;]&lt;/font&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;font color="#ffff00"&gt;|&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#ffff00"&gt;6 &lt;/font&gt;&lt;font color="#ffff00"&gt;|&lt;/font&gt;&amp;nbsp;quit&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;font color="#ffff00"&gt;|&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#ffff00"&gt;7 &lt;/font&gt;&lt;font color="#ffff00"&gt;|&lt;/font&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;font color="#ffff00"&gt;|&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#ffff00"&gt;8 &lt;/font&gt;+---------------------------------------+&lt;br&gt;&lt;br /&gt;&lt;font color="#ffff00"&gt;9 &lt;/font&gt;SQL&lt;font color="#ffff00"&gt;&amp;gt;&lt;/font&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br&gt;&lt;br /&gt;&lt;/font&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;input "quit" to exit the SQL prompt. As in Windows, once the DSN is created you can connect to the MSSQL server using ActiveRecord using:&lt;br /&gt;&lt;br /&gt;&lt;div class="code"&gt;&lt;br /&gt;&lt;font face="monospace"&gt;&lt;br /&gt;&lt;font color="#ffff00"&gt;1 &lt;/font&gt;&lt;font color="#60ff60"&gt;ActiveRecord&lt;/font&gt;::&lt;font color="#60ff60"&gt;Base&lt;/font&gt;.establish_connection(&lt;br&gt;&lt;br /&gt;&lt;font color="#ffff00"&gt;2 &lt;/font&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;font color="#ffa0a0"&gt;:adapter&lt;/font&gt;&amp;nbsp;=&amp;gt; &lt;font color="#ffa500"&gt;&amp;quot;&lt;/font&gt;&lt;font color="#ffa0a0"&gt;sqlserver&lt;/font&gt;&lt;font color="#ffa500"&gt;&amp;quot;&lt;/font&gt;,&lt;br&gt;&lt;br /&gt;&lt;font color="#ffff00"&gt;3 &lt;/font&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;font color="#ffa0a0"&gt;:mode&lt;/font&gt;&amp;nbsp;=&amp;gt; &lt;font color="#ffa500"&gt;&amp;quot;&lt;/font&gt;&lt;font color="#ffa0a0"&gt;odbc&lt;/font&gt;&lt;font color="#ffa500"&gt;&amp;quot;&lt;/font&gt;,&lt;br&gt;&lt;br /&gt;&lt;font color="#ffff00"&gt;4 &lt;/font&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;font color="#ffa0a0"&gt;:username&lt;/font&gt;&amp;nbsp;=&amp;gt; &lt;font color="#ffa500"&gt;&amp;quot;&lt;/font&gt;&lt;font color="#ffa0a0"&gt;youruser&lt;/font&gt;&lt;font color="#ffa500"&gt;&amp;quot;&lt;/font&gt;,&lt;br&gt;&lt;br /&gt;&lt;font color="#ffff00"&gt;5 &lt;/font&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;font color="#ffa0a0"&gt;:password&lt;/font&gt;&amp;nbsp;=&amp;gt; &lt;font color="#ffa500"&gt;&amp;quot;&lt;/font&gt;&lt;font color="#ffa0a0"&gt;yourpass&lt;/font&gt;&lt;font color="#ffa500"&gt;&amp;quot;&lt;/font&gt;,&lt;br&gt;&lt;br /&gt;&lt;font color="#ffff00"&gt;6 &lt;/font&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;font color="#ffa0a0"&gt;:dsn&lt;/font&gt;&amp;nbsp;=&amp;gt; &lt;font color="#ffa500"&gt;&amp;quot;&lt;/font&gt;&lt;font color="#ffa0a0"&gt;SQLServer&lt;/font&gt;&lt;font color="#ffa500"&gt;&amp;quot;&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#ffff00"&gt;7 &lt;/font&gt;) &lt;br&gt;&lt;br /&gt;&lt;/font&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;again make sure to replace "SQLServer" with the DSN name you set up when creating it.&lt;br /&gt;&lt;br /&gt;&lt;a href="http://bp3.blogger.com/_99Fzui5MBLY/R7lTXi-COyI/AAAAAAAAAHw/mKWHYE-qRWI/s1600-h/fig2.png"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;" src="http://bp3.blogger.com/_99Fzui5MBLY/R7lTXi-COyI/AAAAAAAAAHw/mKWHYE-qRWI/s320/fig2.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5168253711373450018" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Some notes about the Linux to MSSQL connection:&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;br /&gt;&lt;li&gt;There are GUI based tools similar to "odbcad32.exe" in Windows that allows you to manage DSN's and ODBC drivers more easily. In Kubuntu simply install the "unixodbc-bin" package and then execute "OBDCConfig". As you can se from the image above this tool is quite similar to the Windows counterpart.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;The freeTDS driver is free and even thought it is rather stable I have found some small issues specially when working with non-ascii character sets like SJIS and ISO-2022-JP used in Japanese OSes. There is a commercial &lt;a href="http://www.easysoft.com/products/data_access/odbc-sql-server-driver/index.html"&gt;alternative driver&lt;/a&gt; produced by EasySoft in case you need commercial support and reliability.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;There is another implementation of ODBC in Linux called &lt;a href="http://www.iodbc.org/"&gt;iODBC&lt;/a&gt; but have never used it. It may be interesting to test the Windows ODBC, unixODBC and iODBC in performance.&lt;/li&gt;&lt;br /&gt;&lt;/ul&gt;&lt;br /&gt;&lt;br /&gt;&lt;B&gt;Linux Client using ADO driver&lt;/B&gt;&lt;br /&gt;&lt;br /&gt;So far I have been unable to make this configuration work. It seems that the ADO driver uses some components from the win32ole library that is only available in Windows machines. This means the only way to connect to a MSSQL server from a Linux client is using the unixODBC/freeTDS driver method described before. &lt;br /&gt;&lt;br /&gt;If someone knows of other ways to make Linux communicate with a MSSQL database please let me know.&lt;br /&gt;&lt;br /&gt;&lt;B&gt;Resources&lt;/B&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://softiesonrails.com/2006/6/28/activerecord-with-sqlserver-without-rails"&gt;http://softiesonrails.com/2006/6/28/activerecord-with-sqlserver-without-rails&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.imarichardson.com/2006/09/26/rubyonrails-using-mssql-server-and-freetds/"&gt;http://www.imarichardson.com/&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.themolehill.com/index.php/2006/10/13/connecting-to-a-microsoft-sql-server-from-a-rails-application/"&gt;http://www.themolehill.com/&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.freetds.org/"&gt;http://www.freetds.org/&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.unixodbc.org/"&gt;http://www.unixodbc.org/&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.unixodbc.org/doc/FreeTDS2.html"&gt;http://www.unixodbc.org/doc/FreeTDS2.html&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.truthsolutions.com/sql/odbc/creating_a_new_odbc_dsn.htm"&gt;http://www.truthsolutions.com/sql/odbc/creating_a_new_odbc_dsn.htm&lt;/a&gt;&lt;br /&gt;&lt;a href="http://josiah.ritchietribe.net/blog/archive/2006/01/1176/"&gt;http://josiah.ritchietribe.net/blog/archive/2006/01/1176/&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/34829202-1149297315102967550?l=piao-tech.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://piao-tech.blogspot.com/feeds/1149297315102967550/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://piao-tech.blogspot.com/2008/02/using-activerecord-with-microsoft-sql.html#comment-form' title='14 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/34829202/posts/default/1149297315102967550'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/34829202/posts/default/1149297315102967550'/><link rel='alternate' type='text/html' href='http://piao-tech.blogspot.com/2008/02/using-activerecord-with-microsoft-sql.html' title='Using ActiveRecord with Microsoft SQL Server (MSSQL)'/><author><name>龍神</name><uri>http://www.blogger.com/profile/16648963337079496096</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://bp2.blogger.com/_99Fzui5MBLY/R7k_mS-COxI/AAAAAAAAAHo/OGcEcPsjf7Y/s72-c/fig1.jpg' height='72' width='72'/><thr:total>14</thr:total></entry><entry><id>tag:blogger.com,1999:blog-34829202.post-8926896657303930255</id><published>2008-02-18T11:12:00.004+09:00</published><updated>2008-02-19T16:27:59.194+09:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Tips'/><category scheme='http://www.blogger.com/atom/ns#' term='Ruby'/><title type='text'>RubyGems Explicit Versioning</title><content type='html'>One of the most useful features of &lt;a href="http://rubygems.org/"&gt;RubyGems&lt;/a&gt; as a package manager is the ability to force explicit versions of the packages in your ruby code. Unfortunately worst than not being documented this feature is wrongly documented even in RubyGems own &lt;a href="http://rubygems.org/read/chapter/4#page71"&gt;manual&lt;/a&gt; pages.&lt;br /&gt;&lt;br /&gt;So for the record here is how to tell your ruby code to use a specific gem version:&lt;br /&gt;&lt;br /&gt;For RubyGems version &lt; 0.9.4 we use:&lt;br /&gt;&lt;br /&gt;&lt;div class="code"&gt;&lt;br /&gt;&lt;font face="monospace"&gt;&lt;br /&gt;&lt;font color="#ffff00"&gt;1 &lt;/font&gt;&lt;font color="#ff80ff"&gt;require&lt;/font&gt;&amp;nbsp;&lt;font color="#ffa500"&gt;'&lt;/font&gt;&lt;font color="#ffa0a0"&gt;rubygems&lt;/font&gt;&lt;font color="#ffa500"&gt;'&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#ffff00"&gt;2 &lt;/font&gt;require_gem &lt;font color="#ffa500"&gt;'&lt;/font&gt;&lt;font color="#ffa0a0"&gt;mechanize&lt;/font&gt;&lt;font color="#ffa500"&gt;'&lt;/font&gt;,&lt;font color="#ffa500"&gt;'&lt;/font&gt;&lt;font color="#ffa0a0"&gt;=0.4.7&lt;/font&gt;&lt;font color="#ffa500"&gt;'&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#ffff00"&gt;3 &lt;/font&gt;&lt;font color="#ff80ff"&gt;require&lt;/font&gt;&amp;nbsp;&lt;font color="#ffa500"&gt;'&lt;/font&gt;&lt;font color="#ffa0a0"&gt;mechanize&lt;/font&gt;&lt;font color="#ffa500"&gt;'&lt;/font&gt;&lt;/font&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;What we do is call "require_gem" to set up the version we want and then load the gem using "require".&lt;br /&gt;&lt;br /&gt;After RubyGems 0.9.4 onwards the "Kernel#require_gem" method was deprecated and replaced with "Kernel#gem". So if you have the latest RubyGems the code above becomes:&lt;br /&gt;&lt;br /&gt;&lt;div class="code"&gt;&lt;br /&gt;&lt;font face="monospace"&gt;&lt;br /&gt;&lt;font color="#ffff00"&gt;1 &lt;/font&gt;&lt;font color="#ff80ff"&gt;require&lt;/font&gt;&amp;nbsp;&lt;font color="#ffa500"&gt;'&lt;/font&gt;&lt;font color="#ffa0a0"&gt;rubygems&lt;/font&gt;&lt;font color="#ffa500"&gt;'&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#ffff00"&gt;2 &lt;/font&gt;gem &lt;font color="#ffa500"&gt;'&lt;/font&gt;&lt;font color="#ffa0a0"&gt;mechanize&lt;/font&gt;&lt;font color="#ffa500"&gt;'&lt;/font&gt;,&lt;font color="#ffa500"&gt;'&lt;/font&gt;&lt;font color="#ffa0a0"&gt;=0.4.7&lt;/font&gt;&lt;font color="#ffa500"&gt;'&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#ffff00"&gt;3 &lt;/font&gt;&lt;font color="#ff80ff"&gt;require&lt;/font&gt;&amp;nbsp;&lt;font color="#ffa500"&gt;'&lt;/font&gt;&lt;font color="#ffa0a0"&gt;mechanize&lt;/font&gt;&lt;font color="#ffa500"&gt;'&lt;/font&gt;&lt;/font&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;Instead of using "=0.4.7" it is also possible to use "&lt;0.4.7" or "&gt;0.4.7" if the specific version is not required.&lt;br /&gt;&lt;br /&gt;We can be more professional and make our scripts handle both cases above using the Gem::RubyGemsVersion constant:&lt;br /&gt;&lt;br /&gt;&lt;div class="code"&gt;&lt;br /&gt;&lt;font face="monospace"&gt;&lt;br /&gt;&lt;font color="#ffff00"&gt;1 &lt;/font&gt;&lt;font color="#ff80ff"&gt;require&lt;/font&gt;&amp;nbsp;&lt;font color="#ffa500"&gt;'&lt;/font&gt;&lt;font color="#ffa0a0"&gt;rubygems&lt;/font&gt;&lt;font color="#ffa500"&gt;'&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#ffff00"&gt;2 &lt;/font&gt;&lt;font color="#ffff00"&gt;if&lt;/font&gt;&amp;nbsp;&lt;font color="#60ff60"&gt;Gem&lt;/font&gt;::&lt;font color="#60ff60"&gt;RubyGemsVersion&lt;/font&gt;&amp;nbsp;&amp;lt; &lt;font color="#ffa500"&gt;&amp;quot;&lt;/font&gt;&lt;font color="#ffa0a0"&gt;0.9.4&lt;/font&gt;&lt;font color="#ffa500"&gt;&amp;quot;&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#ffff00"&gt;3 &lt;/font&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;require_gem &lt;font color="#ffa500"&gt;'&lt;/font&gt;&lt;font color="#ffa0a0"&gt;mechanize&lt;/font&gt;&lt;font color="#ffa500"&gt;'&lt;/font&gt;,&lt;font color="#ffa500"&gt;'&lt;/font&gt;&lt;font color="#ffa0a0"&gt;=0.4.7&lt;/font&gt;&lt;font color="#ffa500"&gt;'&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#ffff00"&gt;4 &lt;/font&gt;&lt;font color="#ffff00"&gt;else&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#ffff00"&gt;5 &lt;/font&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;gem &lt;font color="#ffa500"&gt;'&lt;/font&gt;&lt;font color="#ffa0a0"&gt;mechanize&lt;/font&gt;&lt;font color="#ffa500"&gt;'&lt;/font&gt;,&lt;font color="#ffa500"&gt;'&lt;/font&gt;&lt;font color="#ffa0a0"&gt;=0.4.7&lt;/font&gt;&lt;font color="#ffa500"&gt;'&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#ffff00"&gt;6 &lt;/font&gt;&lt;font color="#ffff00"&gt;end&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#ffff00"&gt;7 &lt;/font&gt;&lt;font color="#ff80ff"&gt;require&lt;/font&gt;&amp;nbsp;&lt;font color="#ffa500"&gt;'&lt;/font&gt;&lt;font color="#ffa0a0"&gt;mechanize&lt;/font&gt;&lt;font color="#ffa500"&gt;'&lt;/font&gt;&lt;/font&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;This way our code will (hopefully) work with all versions of RubyGems.&lt;br /&gt;&lt;br /&gt;References:&lt;br /&gt;&lt;a href="http://redhanded.hobix.com/inspect/autorequireIsBasicallyGoneEveryone.html"&gt;http://redhanded.hobix.com/inspect/autorequireIsBasicallyGoneEveryone.html&lt;/a&gt;&lt;br /&gt;&lt;a href="http://piao-tech.blogspot.com/2006/11/tips-on-rubygems-installation-and.html"&gt;http://piao-tech.blogspot.com/2006/11/tips-on-rubygems-installation-and.html&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/34829202-8926896657303930255?l=piao-tech.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://piao-tech.blogspot.com/feeds/8926896657303930255/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://piao-tech.blogspot.com/2008/02/rubygems-explicit-versioning.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/34829202/posts/default/8926896657303930255'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/34829202/posts/default/8926896657303930255'/><link rel='alternate' type='text/html' href='http://piao-tech.blogspot.com/2008/02/rubygems-explicit-versioning.html' title='RubyGems Explicit Versioning'/><author><name>龍神</name><uri>http://www.blogger.com/profile/16648963337079496096</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-34829202.post-7083595519506581056</id><published>2008-02-12T13:21:00.001+09:00</published><updated>2008-02-19T16:29:30.535+09:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Tips'/><category scheme='http://www.blogger.com/atom/ns#' term='Latex'/><title type='text'>Per user Latex style and bst files</title><content type='html'>Easy way to tell latex where to look for custom sty, cls and bst files:&lt;br /&gt;&lt;br /&gt;&lt;div class="code"&gt;&lt;br /&gt;&lt;font face="monospace"&gt;&lt;br /&gt;&lt;font color="#ffff00"&gt;1 &lt;/font&gt;&lt;font color="#80a0ff"&gt;# The double slash at the end means recursive.&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#ffff00"&gt;2 &lt;/font&gt;&lt;font color="#ffff00"&gt;export&lt;/font&gt;&amp;nbsp;&lt;font color="#40ffff"&gt;BSTINPUTS&lt;/font&gt;=.:~/.latex//:&lt;br&gt;&lt;br /&gt;&lt;font color="#ffff00"&gt;3 &lt;/font&gt;&lt;font color="#ffff00"&gt;export&lt;/font&gt;&amp;nbsp;&lt;font color="#40ffff"&gt;BIBINPUTS&lt;/font&gt;=.:~/.latex//:&lt;br&gt;&lt;br /&gt;&lt;font color="#ffff00"&gt;4 &lt;/font&gt;&lt;font color="#ffff00"&gt;export&lt;/font&gt;&amp;nbsp;&lt;font color="#40ffff"&gt;TEXINPUTS&lt;/font&gt;=.:~/.latex//:&lt;br&gt;&lt;br /&gt;&lt;/font&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;Change the path to reflect your system and make sure to include the current dir "." in the list of paths or latex won't be able to find the tex files in the current directory.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/34829202-7083595519506581056?l=piao-tech.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://piao-tech.blogspot.com/feeds/7083595519506581056/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://piao-tech.blogspot.com/2008/02/per-user-latex-style-and-bst-files.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/34829202/posts/default/7083595519506581056'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/34829202/posts/default/7083595519506581056'/><link rel='alternate' type='text/html' href='http://piao-tech.blogspot.com/2008/02/per-user-latex-style-and-bst-files.html' title='Per user Latex style and bst files'/><author><name>龍神</name><uri>http://www.blogger.com/profile/16648963337079496096</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-34829202.post-7325405814306686771</id><published>2008-01-07T23:03:00.000+09:00</published><updated>2008-01-07T23:18:52.986+09:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Thunderbird'/><category scheme='http://www.blogger.com/atom/ns#' term='Tips'/><category scheme='http://www.blogger.com/atom/ns#' term='Windows'/><title type='text'>Reset Master Password in Thunderbird 2.0.0.9</title><content type='html'>For some mysterious reason the master password of Mozilla Thunderbird got set in my wife's computer (Windows XP)  and every minutes a dialog box would pop up asking for it. Of course no one knew what the master password was so using Thunderbird in that machine was starting to get annoying.&lt;br /&gt;&lt;br /&gt;After searching in Google I found two solutions: one consisted in create a new profile and transfer the mail data from the problematic profile to the new one.This solution required too much effort for my liking. The second solution that everybody said would not fail was running the following command:&lt;br /&gt;&lt;div class="code"&gt;&lt;br /&gt;"C:\path to thunderbird\thunderbird.exe" -chrome chrome://pippki/content/resetpassword.xul&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;Unfortunately for me this command never worked no matter what I did and as this &lt;a href="http://www.velocityreviews.com/forums/t10416-forgotten-masterpassword.html"&gt;forum thread&lt;/a&gt; shows I am not alone so I assume is a Thunderbird problem and not mine. I even tested the command in two different machines one with a clean Windows installation and I can assure this command does not work!.&lt;br /&gt;&lt;br /&gt;So a little more research showed me that the passwords are stored in a file called &lt;i&gt;key3.db&lt;/i&gt; that resides inside the mail profile folder. If you don't know where is your profile folder check this &lt;a href="http://www.mozilla.org/support/thunderbird/profile#locate"&gt;link&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;So I simply closed Thunderbird and renamed the "key3.db" file to "key3.db.bak" and started Thunderbird. And that was it...  all passwords were gone but also the annoying master password was gone too.&lt;br /&gt;&lt;br /&gt;If you need to reset your master password for any reason and you do not care loosing the already stored passwords (web account passwords) then this is the simplest method to do it.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/34829202-7325405814306686771?l=piao-tech.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://piao-tech.blogspot.com/feeds/7325405814306686771/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://piao-tech.blogspot.com/2008/01/reset-master-password-in-thunderbird.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/34829202/posts/default/7325405814306686771'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/34829202/posts/default/7325405814306686771'/><link rel='alternate' type='text/html' href='http://piao-tech.blogspot.com/2008/01/reset-master-password-in-thunderbird.html' title='Reset Master Password in Thunderbird 2.0.0.9'/><author><name>龍神</name><uri>http://www.blogger.com/profile/16648963337079496096</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-34829202.post-7369830456982442922</id><published>2007-12-27T00:07:00.000+09:00</published><updated>2007-12-27T00:16:48.307+09:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Tips'/><category scheme='http://www.blogger.com/atom/ns#' term='Kubuntu'/><title type='text'>Shade windows in KDE using double click in the title bar</title><content type='html'>In KDE using compiz-fusion to shade the current active window we need to press Ctrl+Alt+s that is not a very easy thing to do specially in small keyboards (i.e. laptops).&lt;br /&gt;&lt;br /&gt;Another way to shade windows is by double clicking in the window title bar but for this to work we must first enable it in kwin by editing the file: ~/.kde/share/config/kwinrc. Inside this file after the section [Windows] simply add the following line:&lt;br /&gt;&lt;br /&gt;&lt;div class="code"&gt;&lt;br /&gt;TitlebarDoubleClickCommand=Shade&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;Now after you have restarted you KDE session you will be able to shade windows by double clicking their title bars.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/34829202-7369830456982442922?l=piao-tech.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://piao-tech.blogspot.com/feeds/7369830456982442922/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://piao-tech.blogspot.com/2007/12/shade-windows-in-kde-using-double-click.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/34829202/posts/default/7369830456982442922'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/34829202/posts/default/7369830456982442922'/><link rel='alternate' type='text/html' href='http://piao-tech.blogspot.com/2007/12/shade-windows-in-kde-using-double-click.html' title='Shade windows in KDE using double click in the title bar'/><author><name>龍神</name><uri>http://www.blogger.com/profile/16648963337079496096</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-34829202.post-1738433074952109463</id><published>2007-10-21T13:42:00.000+09:00</published><updated>2007-10-21T13:59:48.863+09:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Tips'/><category scheme='http://www.blogger.com/atom/ns#' term='Kubuntu'/><title type='text'>How to fix the "Warning: Unable to load the OpenGL" error in Matlab</title><content type='html'>If you use Matlab in K/Ubuntu and you get a warning message like "Warning: Unable to load the OpenGL" everytime you start Matlab it means you are not using the powerful OpenGL rendering engine to draw your plots.&lt;br /&gt;&lt;br /&gt;This may not be a big problem as Matlab will work as expected but if you have a 3D accelated graphics card (ATI or NVidia) then  you could greatly benefit from having Matlab use the OpenGL renderer. Even without a 3D accelerated graphics card I would say that using OpenGL for rendering is a plus.&lt;br /&gt;&lt;br /&gt;So solve this problem you simply need to remove a file (libgcc_s.so.1) from the Matlab install directory in order for it to use the one in the system that has correct links to the OpenGL libraries.&lt;br /&gt;&lt;br /&gt;Find the file inside $MATHROOT/sys/os/glnx86 and move it to another place like:&lt;br /&gt;&lt;code&gt;&lt;br /&gt;mv libgcc_s.so.1 libgcc_s.so.1.old&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;Restart Matlab and the warning message should have dissapeared and the command "opengl info" should give and output like:&lt;br /&gt;&lt;code&gt;&lt;br /&gt;Version        = 2.0.6473 (8.37.6)&lt;br /&gt;Vendor         = ATI Technologies Inc.&lt;br /&gt;Renderer       = ATI MOBILITY FireGL V3200&lt;br /&gt;MaxTextureSize = 2048&lt;br /&gt;Visual         = 0x29 (TrueColor, depth 24, RGB mask 0xff0000 0xff00 0x00ff)&lt;br /&gt;...&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;The output may vary depending on your graphics card or if you have accelerated or non-accelerated (i.e. Mesa) OpenGL graphics.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/34829202-1738433074952109463?l=piao-tech.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://piao-tech.blogspot.com/feeds/1738433074952109463/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://piao-tech.blogspot.com/2007/10/how-to-fix-warning-unable-to-load.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/34829202/posts/default/1738433074952109463'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/34829202/posts/default/1738433074952109463'/><link rel='alternate' type='text/html' href='http://piao-tech.blogspot.com/2007/10/how-to-fix-warning-unable-to-load.html' title='How to fix the &quot;Warning: Unable to load the OpenGL&quot; error in Matlab'/><author><name>龍神</name><uri>http://www.blogger.com/profile/16648963337079496096</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-34829202.post-247088517251422462</id><published>2007-08-01T09:08:00.000+09:00</published><updated>2007-08-01T09:46:45.560+09:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Ruby'/><title type='text'>Dealing with Errno::EBADF in ruby net/http</title><content type='html'>In August 2006 I posted a question in a forum about an error (Bad File Descriptor) I was getting when using the net/http library of Ruby. Today, almost one year latter, I received an email from someone with that same problem asking for my advice and a few hours latter the same person wrote again saying he found a satisfactory solution and wanted to share it with me.&lt;br /&gt;&lt;br /&gt;As part of this wonderful online community I am obliged to share my new knowledge in hopes it is useful to others as it was useful for me.&lt;br /&gt;&lt;br /&gt;The Bad File Descriptor error (Errno::EBADF) occurred sporadically while using the net/http library to connect to a lot of pages (web spider) in a short time span. The main problem was that I could never catch that error (i.e. rescue it) and the script would not finish leaving a lot of pages without processing. To solve this problem at the time I split my script is several smaller ones and added a small delay between web pages. &lt;br /&gt;&lt;br /&gt;My solution works but that small delay for a thousand pages add up and the scripts take not minutes but hours to finish.&lt;br /&gt;&lt;br /&gt;The email I got explained that the cause of this error is that the operating system (Win XP) is running out of TCP ports for new connections. Many of the sockets open are put in TIME_WAIT state (meaning that the client has closed but the server has yet to close from its side).  &lt;br /&gt;&lt;br /&gt;The first approach to solve this is to force Ruby to close the connection but there is no such facility, at least in Ruby 1.8.x, for doing it. The second solution and the one I received by mail was to increase the upper range of dynamically allocated to client TCP/IP connections to a value.&lt;br /&gt;&lt;br /&gt;Here are the instruction on how to do it:&lt;br /&gt;&lt;a href="http://msdn2.microsoft.com/en-us/library/Aa560610.aspx"&gt;http://msdn2.microsoft.com/en-us/library/Aa560610.aspx&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;If you expect to make a lot of http connections fast using Ruby in a Windows XP machine then you better increase that number of ports or you will be around asking yourself what this random EBADF error is all about.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/34829202-247088517251422462?l=piao-tech.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://piao-tech.blogspot.com/feeds/247088517251422462/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://piao-tech.blogspot.com/2007/08/dealing-with-errnoebadf-in-ruby-nethttp.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/34829202/posts/default/247088517251422462'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/34829202/posts/default/247088517251422462'/><link rel='alternate' type='text/html' href='http://piao-tech.blogspot.com/2007/08/dealing-with-errnoebadf-in-ruby-nethttp.html' title='Dealing with Errno::EBADF in ruby net/http'/><author><name>龍神</name><uri>http://www.blogger.com/profile/16648963337079496096</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-34829202.post-3437599123469334571</id><published>2007-06-26T16:40:00.000+09:00</published><updated>2008-03-05T10:00:01.206+09:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Netbeans'/><category scheme='http://www.blogger.com/atom/ns#' term='Doja'/><title type='text'>Doja Development in Netbeans</title><content type='html'>&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://bp3.blogger.com/_99Fzui5MBLY/RoDL_AgN4NI/AAAAAAAAAGU/bXhKvWWvEXo/s1600-h/netbeans.PNG"&gt;&lt;img style="float:left; margin:0 10px 10px 0;cursor:pointer; cursor:hand;" src="http://bp3.blogger.com/_99Fzui5MBLY/RoDL_AgN4NI/AAAAAAAAAGU/bXhKvWWvEXo/s200/netbeans.PNG" border="0" alt=""id="BLOGGER_PHOTO_ID_5080284663001243858" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;p&gt;Back in October 2006 I wrote a three part post (&lt;a href="http://piao-tech.blogspot.com/2006/10/developing-for-japanese-phones-in.html"&gt;one&lt;/a&gt;, &lt;a href="http://piao-tech.blogspot.com/2006/10/developing-for-japanese-phones-in_06.html"&gt;two&lt;/a&gt; and &lt;a href="http://piao-tech.blogspot.com/2006/10/developing-for-japanese-phones-in_11.html"&gt;three&lt;/a&gt;) on how to develop mobile applications for Japanese phones using Netbeans as IDE. When I say Japanese phones I refer to phones provided by the three major cellular network providers in Japan: KDDI, Softbank and NTTDoCoMo.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;Recently I was assigned a new project that requires the implementation of a Doja IApplication for the 903i release of NTTDoCoMo phones. Since these phones support Doja-5.0 profile I started to add support for it into my Netbeans installation and in the way I decided also to upgrade to Java-6u1 and Netbeans 5.51.&lt;/p&gt;&lt;p&gt;After some time setting all up I can say it was worth the effort and this new set up is cleaner and more easy than my previous one. For those interested here is my set up.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;div class="blog_post_subtitle"&gt;Pre-requisites&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;If you want to upgrade to Java-6u1 I strongly recommend you to uninstall all other instances of Java on your system. I had a lot of rare problems until I removed the previous  Java 1.4.2 from my system. Uninstall Netbeans and the mobility pack if you have it.&lt;br /&gt;&lt;br /&gt;Also uninstall all previous Doja toolkits you may have as they are all included in the Doja-5.0 toolkit. &lt;br /&gt;&lt;br /&gt;Download and install Java SDK, Netbeans, Netbeans Mobility Pack and the Doja Toolkit-5.0 in that order. Here are the links:&lt;br /&gt;&lt;ul&gt;&lt;br /&gt;&lt;li&gt;Java Development Platform 6u1. &lt;a href="http://java.sun.com/javase/downloads/index.jsp"&gt;link&lt;/a&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Netbeans and Mobility pack &lt;a href="http://www.netbeans.org/"&gt;link&lt;/a&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Doja Toolkit 5.0. &lt;a href="http://www.nttdocomo.co.jp/service/imode/make/content/iappli/about/tool_foma5.html"&gt;link&lt;/a&gt;&lt;/li&gt;&lt;br /&gt;&lt;/ul&gt;&lt;br /&gt;&lt;br /&gt;&lt;div class="blog_post_subtitle"&gt;Doja Netbeans Pack&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;Once you have all installed you can download my Doja Netbeans pack (&lt;a href="http://www.divshare.com/download/1078912-a55"&gt;doja-netbeans.zip&lt;/a&gt;) that contains some needed configuration files and a single ant task that we will use to generate the JAM file and a nice download html file that are needed for deploying IApplications.&lt;br /&gt;&lt;br /&gt;To use the Doja Netbeans Pack you need to do some manual work. First uncompress the zip file and you will see three files:&lt;br /&gt;&lt;ul&gt;&lt;br /&gt;&lt;li&gt;Doja.xml  -  Contains Doja profile configurations.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;build.xml -  Build script that creates JAM and HTML files for IAppli deployment&lt;/li&gt;&lt;br /&gt;&lt;li&gt;doja-ant-tasks.jar - My custom ant task used by the build script to create the JAM and HTML files&lt;/li&gt;&lt;br /&gt;&lt;/ul&gt;&lt;br /&gt;&lt;div class="blog_post_subtitle"&gt;Adding the Doja Emulator Platform to Netbeans&lt;/div&gt;&lt;br /&gt;Make sure Netbeans is not running and copy the Doja.xml configuration file inside your users .netbeans platform configuration directory. This directory is usually:&lt;br /&gt;&lt;div class="code"&gt;&lt;br /&gt;c:\Document and Settings\username\.netbeans\5.5.1\config\Services\Platforms\org-netbeans-api-java-Platform\&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://bp1.blogger.com/_99Fzui5MBLY/RpDF3Y5uIKI/AAAAAAAAAGc/JwpWqy9lNFs/s1600-h/config.PNG"&gt;&lt;img style="float:right; margin:0 0 10px 10px;cursor:pointer; cursor:hand;" src="http://bp1.blogger.com/_99Fzui5MBLY/RpDF3Y5uIKI/AAAAAAAAAGc/JwpWqy9lNFs/s320/config.PNG" border="0" alt=""id="BLOGGER_PHOTO_ID_5084781534669316258" /&gt;&lt;/a&gt;&lt;br /&gt;After you have copied the Doja.xml file to the correct directory you must open it and edit the platform home element. Simply look at the top of the file the &lt;platform .../&gt; xml tag and change the home="C:\install_path\iDKDoja5.0" with the directory were you installed the Doja toolkit. If you choose default installation when installing the Doja toolkit then you should put home="C:\iDKDoja5.0".&lt;br /&gt;&lt;br /&gt;If everything is ok then when you start Netbeans and create a new Mobile Application you should be able to select the NTT Doja Emulator Platform and one of the FOMA devices. Each device uses an specific Doja Profile version:&lt;br /&gt;&lt;ul&gt;&lt;br /&gt;&lt;li&gt;FOMA904i - Doja-5.0&lt;/li&gt;&lt;br /&gt;&lt;li&gt;FOMA903i - Doja-5.0&lt;/li&gt;&lt;br /&gt;&lt;li&gt;FOMA902i - Doja-4.1&lt;/li&gt;&lt;br /&gt;&lt;li&gt;FOMA901i - Doja-4.0&lt;/li&gt;&lt;br /&gt;&lt;li&gt;FOMA900i - Doja-3.5&lt;/li&gt;&lt;br /&gt;&lt;li&gt;FOMA506i - Doja-3.0&lt;/li&gt;&lt;br /&gt;&lt;li&gt;FOMA505i - Doja-3.0&lt;/li&gt;&lt;br /&gt;&lt;/ul&gt;&lt;br /&gt;You must choose the device depending on what Doja profile the device you are developing for supports. A list of devices and the Doja version they support is available at NTTDoCoMo home page &lt;a href="http://www.nttdocomo.co.jp/service/imode/make/content/spec/iappli/index.html"&gt;here&lt;/a&gt; .&lt;br /&gt;&lt;br /&gt;If you don't see the Mobile Application option when creating a new project make sure you have installed the Netbeans Mobility Pack correctly. If you are able to create Mobile Application projects but you don't get the NTT Doja emulator platform make sure you have copied the Doja.xml file in the correct place and edited the home property correctly.&lt;br /&gt;&lt;div class="blog_post_subtitle"&gt;Setting up the Doja ant task&lt;/div&gt;&lt;br /&gt;Create a new Mobile Application using Netbeans and once created replace the project's build.xml file with the one that came with the Doja Netbeans pack. This modified build.xml script should look like:&lt;br /&gt;&lt;div class="code"&gt;&lt;br /&gt;&amp;lt;?xml version="1.0" encoding="UTF-8"?&amp;gt;&lt;br /&gt;&amp;lt;project name="" default="jar" basedir="."&amp;gt;&lt;br /&gt;    &amp;lt;description&amp;gt;Builds, tests, and runs the project .&amp;lt;/description&amp;gt;&lt;br /&gt;    &amp;lt;import file="nbproject/build-impl.xml"/&amp;gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;    &amp;lt;property name="jam.AppClass" value="HelloNtt" /&amp;gt;&lt;br /&gt;    &amp;lt;property name="jam.AppName" value="HelloNtt" /&amp;gt;&lt;br /&gt;    &amp;lt;property name="jam.PackageURL" value="http://test.mydomain.org" /&amp;gt;&lt;br /&gt;    &amp;lt;property name="jam.Network" value="http" /&amp;gt;&lt;br /&gt;    &amp;lt;property name="jam.SPSize" value="1024" /&amp;gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;    &amp;lt;taskdef name="jamwriter" classname="jp.doja.ant.JamTask"&amp;gt;&lt;br /&gt;        &amp;lt;classpath&amp;gt;&lt;br /&gt;            &amp;lt;pathelement location="C:\path_to_jar\doja-ant-tasks.jar"/&amp;gt;&lt;br /&gt;        &amp;lt;/classpath&amp;gt;&lt;br /&gt;    &amp;lt;/taskdef&amp;gt;&lt;br /&gt;&lt;br /&gt;    &amp;lt;target name="post-jar"&amp;gt;&lt;br /&gt;        &amp;lt;jamwriter /&amp;gt;&lt;br /&gt;    &amp;lt;/target&amp;gt;&lt;br /&gt;&lt;br /&gt;    &amp;lt;target name="run" depends="init,jar"&amp;gt;&lt;br /&gt;    &amp;lt;exec executable="${platform.home}/bin/doja.exe" dir="${dist.dir}"&amp;gt;&lt;br /&gt;        &amp;lt;arg value="-i" /&amp;gt;&lt;br /&gt;        &amp;lt;arg value="${name}.jam" /&amp;gt;&lt;br /&gt;    &amp;lt;/exec&amp;gt;&lt;br /&gt;    &amp;lt;/target&amp;gt;&lt;br /&gt;&lt;br /&gt;    &amp;lt;target name="post-clean"&amp;gt;&lt;br /&gt;         &amp;lt;delete file="${dist.dir}/${name}.jam"/&amp;gt;&lt;br /&gt;    &amp;lt;/target&amp;gt;&lt;br /&gt;&amp;lt;/project&amp;gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;For this build script to work you must search for the &lt;pathelement&gt; tag inside the jamwriter taskdef and modify the location to point to the doja-ant-tasks.jar file that came with the Doja Netbeans Pack. Simply said modify the "C:\path_to_jar\doja-ant-tasks.jar" line to point to the place that file is located in your computer.&lt;br /&gt;&lt;br /&gt;This custom task will create the needed JAM descriptor file and an HTML file you can use to deploy your IApplis. The most relevant entries that go inside the JAM file are already on the build.xml script:&lt;br /&gt;&lt;div class="code"&gt;&lt;br /&gt;&amp;lt;property name="jam.AppClass" value="HelloNtt" /&amp;gt;&lt;br /&gt;&amp;lt;property name="jam.AppName" value="HelloNtt" /&amp;gt;&lt;br /&gt;&amp;lt;property name="jam.PackageURL" value="http://test.mydomain.org" /&amp;gt;&lt;br /&gt;&amp;lt;property name="jam.Network" value="http" /&amp;gt;&lt;br /&gt;&amp;lt;property name="jam.SPSize" value="1024" /&amp;gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;You can add as many entries as you like by simply creating a new &lt;property&gt; tag with the name starting with "jam." followed by the actual property name and the value set to the entry value. If you do not understand what the JAM descriptor file is or what properties are available refer to &lt;a href="http://www.doja-developer.net/_up/features/feature1_2/index.php?id=2"&gt;this tutorial&lt;/a&gt; at the Doja Developers Network. Again the most used ones are the ones presented above.&lt;br /&gt;&lt;div class="blog_post_subtitle"&gt;Final Remarks&lt;/div&gt;&lt;br /&gt;Well we are finished. Now we can create Doja IAppli's easily in Netbeans taking advantage of all the tools Netbeans has to offer for that purpose. We get automatic preverification, several levels of ofuscation, packaging, JAM and download HTML files creation (via custom ant task) and most important device fragmentation control. Actually the only reason I like to use Netbeans for J2ME/Doja development rather than using the native Doja Toolkit or Eclipse is because Netbeans has a nice preprocessor that makes it easy to deal with the &lt;a href="http://www.devx.com/wireless/Article/29449"&gt;device fragmentation&lt;/a&gt; problem.&lt;br /&gt;&lt;br /&gt;To test this setup you can refer to my previous blog post on the topic (see links at the beginning of this post).&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/34829202-3437599123469334571?l=piao-tech.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://piao-tech.blogspot.com/feeds/3437599123469334571/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://piao-tech.blogspot.com/2007/06/doja-development-in-netbeans.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/34829202/posts/default/3437599123469334571'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/34829202/posts/default/3437599123469334571'/><link rel='alternate' type='text/html' href='http://piao-tech.blogspot.com/2007/06/doja-development-in-netbeans.html' title='Doja Development in Netbeans'/><author><name>龍神</name><uri>http://www.blogger.com/profile/16648963337079496096</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://bp3.blogger.com/_99Fzui5MBLY/RoDL_AgN4NI/AAAAAAAAAGU/bXhKvWWvEXo/s72-c/netbeans.PNG' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-34829202.post-5074980512432912811</id><published>2007-06-16T14:13:00.000+09:00</published><updated>2007-06-18T20:36:13.087+09:00</updated><title type='text'>Skype Linux is comming fast!!</title><content type='html'>&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://bp0.blogger.com/_99Fzui5MBLY/RnNw6ggN4MI/AAAAAAAAAGM/DbmhRXZjhl0/s1600-h/skype-1.4..0.47-1"&gt;&lt;img style="float:left; margin:0 10px 10px 0;cursor:pointer; cursor:hand;" src="http://bp0.blogger.com/_99Fzui5MBLY/RnNw6ggN4MI/AAAAAAAAAGM/DbmhRXZjhl0/s320/skype-1.4..0.47-1" border="0" alt=""id="BLOGGER_PHOTO_ID_5076525355436466370" /&gt;&lt;/a&gt;&lt;br /&gt;When the new &lt;a href="http://www.skype.com/download/skype/linux/"&gt;1.4.0.74&lt;/a&gt; release of Skype was released with Feisty Fawn binary packages and a repository I simply jumped in and installed Skype on my system using those repositories.&lt;br /&gt;&lt;br /&gt;Happy with the new release I fired up Skype to be greeted with my old friend, the &lt;a href="http://piao-tech.blogspot.com/2006/10/glibc-detected-skype-free-invalid.html"&gt;***glibc detected ***&lt;/a&gt; bug. &lt;br /&gt;&lt;br /&gt;Sad for the step back I started to read the FAQ on how to report a bug and when I was about to submit the report the little apt-get update icon appeared on my systray. I clicked and saw that a new version of Skype was available to install... that was fast!! . A couple of clicks and I had the new 1.4.0.74-1 release installed and the what is better the bug was gone!. Skype runs just perfect and looks great on my laptop now. At this speed I expect video support to be here very soon.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/34829202-5074980512432912811?l=piao-tech.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://piao-tech.blogspot.com/feeds/5074980512432912811/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://piao-tech.blogspot.com/2007/06/skype-linux-is-comming-fast.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/34829202/posts/default/5074980512432912811'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/34829202/posts/default/5074980512432912811'/><link rel='alternate' type='text/html' href='http://piao-tech.blogspot.com/2007/06/skype-linux-is-comming-fast.html' title='Skype Linux is comming fast!!'/><author><name>龍神</name><uri>http://www.blogger.com/profile/16648963337079496096</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://bp0.blogger.com/_99Fzui5MBLY/RnNw6ggN4MI/AAAAAAAAAGM/DbmhRXZjhl0/s72-c/skype-1.4..0.47-1' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-34829202.post-8185302399931208654</id><published>2007-05-31T18:15:00.000+09:00</published><updated>2008-03-05T10:00:10.558+09:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Tips'/><title type='text'>Komodo - Japanese Encodings</title><content type='html'>&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://bp1.blogger.com/_99Fzui5MBLY/RnNguwgN4KI/AAAAAAAAAF8/8EmUED83sfY/s1600-h/komodo.jpg"&gt;&lt;img style="float:left; margin:0 10px 10px 0;cursor:pointer; cursor:hand;" src="http://bp1.blogger.com/_99Fzui5MBLY/RnNguwgN4KI/AAAAAAAAAF8/8EmUED83sfY/s200/komodo.jpg" border="0" alt=""id="BLOGGER_PHOTO_ID_5076507561386959010" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;p&gt;If you are considering Komodo Edit as editor and you work for a Japanese company you should be aware that the default installation of Komodo does not support Japanese text encodings like cp932 (Windows), EUC-JP and Shift-JIS.&lt;/p&gt;&lt;br /&gt;&lt;p&gt;Fortunately by modifying some configuration files we can make Komodo Edit to recognize and render these text encodings correctly (&lt;a href="http://leechiryo.blogspot.com/2007/02/komodo-ide-40.html"&gt;ref1&lt;/a&gt; and &lt;a href="http://komodonoko.com/node/12"&gt;ref2&lt;/a&gt;). The configuration file you need to modify is called "koEncodingServices.py" and the location depends on the OS you are using:&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;div class="code"&gt;In Mac the file is located in&lt;br /&gt;&lt;br /&gt;Komodo IDE.app/Conten­ts/MacOS/compo­nents/koEncodin­gServices.py &lt;br /&gt;&lt;br /&gt;In Linux and Windows the file is located in&lt;br /&gt;&lt;br /&gt;${INSTALL_DIR}/lib/mozilla/components/koEncodin­gServices.py &lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;p&gt;Change ${INSTALL_DIR} with the root path were you installed Komodo Edit in you machine.&lt;/p&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://bp2.blogger.com/_99Fzui5MBLY/RnNg0AgN4LI/AAAAAAAAAGE/Osb9bKjwdIk/s1600-h/komodo2.jpg"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;" src="http://bp2.blogger.com/_99Fzui5MBLY/RnNg0AgN4LI/AAAAAAAAAGE/Osb9bKjwdIk/s320/komodo2.jpg" border="0" alt=""id="BLOGGER_PHOTO_ID_5076507651581272242" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;p&gt;Close Komodo Edit and using you next favorite text editor open the file and in line 81 add the following three lines (see screenshot):&lt;/p&gt;&lt;br /&gt;&lt;div class="code"&gt;('EUC-JP', 'EUC-JP', 'EUC-JP', '', 1, 'EUC-JP'),&lt;br /&gt;('Shift_JIS', 'Shift_JIS', 'Shift_JIS', '', 1, 'Shift_JIS'),&lt;br /&gt;('cp932', 'Japanese (cp932)', 'CP932', '', 1,'cp932'),&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div class=".blog_subtittle"&gt;Impressions&lt;/div&gt;&lt;br /&gt;&lt;p&gt;The only thing I liked about it is the ability to make it feel like Vim using some &lt;a href="http://aspn.activestate.com/ASPN/docs/Komodo/4.1/komodo-doc-vikeybind.html"&gt;key bindings&lt;/a&gt; with project management enhancements. This only reason was not good enough to make me switch and soon I was back to my Command Prompt + Vim + muCommander in Windows and yakuake + Vim + Konqueror in Linux.&lt;/p&gt;&lt;br /&gt;&lt;p&gt;Komodo felt too cluttered and was way too slow to start and edit with specially on Linux. Finally if you decide to use Komodo Edit for any reason you may as well change the default fonts as they are not too good for programming tasks. You can find the best fonts for programming &lt;a href="http://www.kuro5hin.org/story/2004/12/6/11739/5249"&gt;here&lt;/a&gt;. From the list my favorites are the &lt;a href="http://www.gnome.org/fonts/"&gt;Bistream Vera Sans Mono&lt;/a&gt; and &lt;a href="http://www.donationcoder.com/Software/Jibz/Dina/index.html"&gt;Dina&lt;/a&gt; Fonts that look rather good on Linux and on Windows as well.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/34829202-8185302399931208654?l=piao-tech.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://piao-tech.blogspot.com/feeds/8185302399931208654/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://piao-tech.blogspot.com/2007/05/komodo-japanese-encodings.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/34829202/posts/default/8185302399931208654'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/34829202/posts/default/8185302399931208654'/><link rel='alternate' type='text/html' href='http://piao-tech.blogspot.com/2007/05/komodo-japanese-encodings.html' title='Komodo - Japanese Encodings'/><author><name>龍神</name><uri>http://www.blogger.com/profile/16648963337079496096</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://bp1.blogger.com/_99Fzui5MBLY/RnNguwgN4KI/AAAAAAAAAF8/8EmUED83sfY/s72-c/komodo.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-34829202.post-1257606552878131598</id><published>2007-04-25T17:33:00.000+09:00</published><updated>2008-01-07T23:02:48.542+09:00</updated><title type='text'>Synergy Japanese Keyboard Support (Kana key)</title><content type='html'>For the impatient:&lt;br /&gt;&lt;br /&gt;I patched and compiled Synergy to enable the Kana key used in Japanese keyboards to switch between input methods. I also created the Windows installer for the patched version for those Windows users that do not know what a patch is or what compiling means. You can find the installer &lt;a href="http://www.divshare.com/download/615471-a64"&gt;here&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;Unfortunately for Linux users I have no idea on how to create packages for any distribution so you will have to compile from sources. Fear not as it is not complicated at all and I explain how to do it below.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;A dual screen hack (revisited):&lt;br /&gt;&lt;br /&gt;In one of my &lt;a href="http://piao-tech.blogspot.com/2007/02/dual-screen-hack-x2vnc-and-win2vnc.html"&gt;previous post&lt;/a&gt; I talked about how I used X2VNC/Win2VNC in combination with RealVNC/X11VNC to share a single keyboard and mouse between several computers even if these computers had different operating systems.&lt;br /&gt;&lt;br /&gt;Using the above programs works well but I have been experiencing some problems like not being able to use the Japanese keys on my keyboard and some responsiveness degradation (late mouse reaction) when the machine running the VNC server is under heavy load.&lt;br /&gt;&lt;br /&gt;Due to these small problems I started looking for an alternative and found &lt;a href="http://synergy2.sourceforge.net/"&gt;Synergy&lt;/a&gt;. This application is small and does not require the additional VNC server. Runs in Windows, Linux and Mac and the transition between screens is smooth even if the computers are under heavy load. Another thing I like a lot is the centralized configuration (only one server) that allows to easily configure  more than two computers. Creating a setup with more than three computers using X2VNC/WIN2VNC could be very frustrating. Also there are GUI configuration tools for Windows, Linux and Mac that make even easier to setup (&lt;a href="http://quicksynergy.sourceforge.net/"&gt;here&lt;/a&gt;).&lt;br /&gt;&lt;br /&gt;There are a lot of resources in the Internet that explain how to install and use Synergy to create dual screen systems (&lt;a href="http://synergy2.sourceforge.net/running.html"&gt;here&lt;/a&gt;, &lt;a href="http://www.engadget.com/2005/08/09/how-to-share-your-keyboard-and-mouse-in-realtime-with-synergy/"&gt;here&lt;/a&gt; and &lt;a href="http://www.lifehacker.com/software/productivity/how-to-turn-your-dualmonitor-pc-into-a-dual-macpc-system-106123.php"&gt;here&lt;/a&gt;) so I wont explain it here. What I will explain is how to get the Japanese keys to work with synergy.&lt;br /&gt;&lt;br /&gt;Some videos of Synergy in action can be found &lt;a href="http://brainscat.com/archives/2004/09/23/synergy2-laptop-desktop-heaven"&gt;here&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;B&gt;Japanese Key's support in Synergy&lt;/B&gt;&lt;br /&gt;&lt;br /&gt;The current version of Synergy does not handle the Japanese keys used to change the input method (i.e. ローマ字/漢字). There is a Japanese keyboard (Hankaku/Zenkaku-Kanji and Kana key) &lt;a href="http://sourceforge.net/tracker/index.php?func=detail&amp;aid=1468436&amp;group_id=59275&amp;atid=490469"&gt;patch&lt;/a&gt; in the patches section of the Synergy sourceforge page but no binary releases are available yet. I took the time to patch and compile the source code to enable these keys on my Japanese keyboard in Linux and Windows and here are the instructions on how I did it.&lt;br /&gt;&lt;br /&gt;Instructions for Linux Kubuntu Desktop&lt;br /&gt;&lt;br /&gt;1. Download the source code from &lt;a href="http://sourceforge.net/project/showfiles.php?group_id=59275&amp;release_id=406638"&gt;here&lt;/a&gt;. The last version was 1.3.1 at the time of this writing.&lt;br /&gt;&lt;br /&gt;2. Make sure you have installed the development tools and the XTest development package&lt;br /&gt;&lt;div class="code"&gt;&lt;br /&gt;sudo aptitude install build-essential&lt;br /&gt;sudo aptitude install libxtst-dev&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;3. Unpack and edit the source code&lt;br /&gt;&lt;div class="code"&gt;&lt;br /&gt;tar xvfz synergy-1.3.1.tar.gz&lt;br /&gt;cd synergy-1.3.1&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;4. Edit the source code to add Hankaku/Zenkaku-Kanji and Kana key support&lt;br /&gt;&lt;br /&gt;Open the lib/platform/CMSWindowsKeyState.cpp file and search the following three lines:&lt;br /&gt;&lt;div class="code"&gt;&lt;br /&gt;/* 0x0f2 */ { kKeyNone },               // OEM specific&lt;br /&gt;/* 0x0f3 */ { kKeyNone },               // OEM specific&lt;br /&gt;/* 0x0f4 */ { kKeyNone },               // OEM specific&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;and replace them with these corresponding lines&lt;br /&gt;&lt;div class="code"&gt;&lt;br /&gt;/* 0x0f2 */ { kKeyOEMCopy },     // VK_OEM_COPY&lt;br /&gt;/* 0x0f3 */ { kKeyZenkaku },     // VK_OEM_AUTO&lt;br /&gt;/* 0x0f4 */ { kKeyZenkaku },     // VK_OEM_ENLW&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;Open the lib/synergy/KeyTypes.h file and search for a line like:&lt;br /&gt;&lt;div class="code"&gt;&lt;br /&gt;static const KeyID kKeyDelete = 0xEFFF;   /* Delete, rubout */&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;and add the following below:&lt;br /&gt;&lt;div class="code"&gt;&lt;br /&gt;static const KeyID kKeyOEMCopy = 0xEF27; /* OEMCopy(Kana Key) */&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;Actually you can add this line of code anywhere you want inside the KeyTypes.h file but to keep things in order I add it after the kKeyDelete const declaration.&lt;br /&gt;&lt;br /&gt;5. Make the configure/make/make install dance.&lt;br /&gt;&lt;br /&gt;&lt;div class="code"&gt;&lt;br /&gt;./configure -x-includes /usr/include -x-libraries /usr/lib --prefix=/usr&lt;br /&gt;make&lt;br /&gt;sudo make install&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;6. Synergy is now installed on your Kubuntu system and you can proceed to configure it. Refer to the links in the previous section for instructions.&lt;br /&gt;&lt;br /&gt;Instruction for Windows&lt;br /&gt;&lt;br /&gt;1. To compile Synergy in Windows you need Visual C++ (Express Edition) that can be downloaded for free from &lt;a href="http://msdn.microsoft.com/vstudio/express/visualc/"&gt;here&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;2. To create the installer we need NSIS. Simply download the installable from &lt;a href="http://nsis.sourceforge.net/Download"&gt;here&lt;/a&gt; and install it.&lt;br /&gt;&lt;br /&gt;3. Download the source code (synergy.1.3.1.zip), unpack it somewhere. Edit the file "dist/nullsoft/installer.mak" inside the source code to make sure it points to the correct NSIS installation path. Simply open the installer.mak file with any text editor and make sure the path for makensis is correct:&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;NSIS="C:\Program Files\NSIS\makensis"&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;This example is if you installed NSIS in the default path. &lt;br /&gt; &lt;br /&gt;3. Open the synergy.dsw VC++ project. Say yes to all the requests to convert the project format and edit the source code as directed below&lt;br /&gt;&lt;br /&gt;Open the platform-&gt;Source Files-&gt;CMSWindowsKeyState.cpp file and search these six lines:&lt;br /&gt;&lt;div class="code"&gt;&lt;br /&gt;/* 0x0f2 */ { kKeyNone },               // OEM specific&lt;br /&gt;/* 0x0f3 */ { kKeyNone },               // OEM specific&lt;br /&gt;/* 0x0f4 */ { kKeyNone },               // OEM specific&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;and replace them with these corresponding lines&lt;br /&gt;&lt;div class="code"&gt;&lt;br /&gt;/* 0x0f2 */ { kKeyOEMCopy },     // VK_OEM_COPY&lt;br /&gt;/* 0x0f3 */ { kKeyZenkaku },     // VK_OEM_AUTO&lt;br /&gt;/* 0x0f4 */ { kKeyZenkaku },     // VK_OEM_ENLW&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;Open the libsynergy-&gt;Header File-&gt;KeyTypes.h file and add the following line:&lt;br /&gt;&lt;div class="code"&gt;&lt;br /&gt;static const KeyID kKeyOEMCopy = 0xEF27; /* OEMCopy(Kana Key) */&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;just after this line:&lt;br /&gt;&lt;br /&gt;&lt;div class="code"&gt;&lt;br /&gt;static const KeyID kKeyDelete = 0xEFFF;   /* Delete, rubout */&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;If you followed the Linux instructions you will note that these changes are exactly the same as does we did in Linux.&lt;br /&gt;&lt;br /&gt;4. Make sure the compiler is set to Release configuration (i.e. select release in the project properties) and build the "all" and "installer" projects. To compile right click on the project names (all and installer) and select build from the context menu.&lt;br /&gt;&lt;br /&gt;5. After both builds finish there will be a "SynergyInstaller.exe" file inside the "build" directory inside the source code directory. Execute this file to install Synergy as normal.&lt;br /&gt;&lt;br /&gt;6. Proceed to configure (see references in previous section) and now you will be able to change from romaji to kana using the Kana key available on all japanese keyboards.&lt;br /&gt;&lt;br /&gt;Mac Instructions&lt;br /&gt;&lt;br /&gt;Unfortunately I do not have a Mac to try this patch but there are instructions on how to compile Synergy on a Mac inside the doc/compiling.html file. If someone is successful applying this patch on the Mac I would like to hear about it.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/34829202-1257606552878131598?l=piao-tech.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://piao-tech.blogspot.com/feeds/1257606552878131598/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://piao-tech.blogspot.com/2007/04/synergy-japanese-keyboard-support-kana.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/34829202/posts/default/1257606552878131598'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/34829202/posts/default/1257606552878131598'/><link rel='alternate' type='text/html' href='http://piao-tech.blogspot.com/2007/04/synergy-japanese-keyboard-support-kana.html' title='Synergy Japanese Keyboard Support (Kana key)'/><author><name>龍神</name><uri>http://www.blogger.com/profile/16648963337079496096</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-34829202.post-624910391950011839</id><published>2007-04-22T01:21:00.004+09:00</published><updated>2008-04-09T09:59:59.117+09:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Tips'/><category scheme='http://www.blogger.com/atom/ns#' term='Servers'/><title type='text'>Receive Log reports via Email (Ubuntu)</title><content type='html'>When deploying servers in the hostile Internet a good administrator is faced with the need to monitor all the log files the server produces to ensure it is working correctly and to detect any security treats.&lt;br /&gt;&lt;br /&gt;This can be a really time consuming task as a busy server can produce several megabytes worth of log files per day and if there are more than one server, then checking log files one by one is totally impractical, not to say useless.&lt;br /&gt;&lt;br /&gt;To alleviate the burden of checking big log files every day I installed logwatch and it has proven to be very useful. It gives a very complete summary of all your log files with the most relevant information and very well presented with per service sub-sections. &lt;br /&gt;&lt;br /&gt;In Ubuntu Server installing the logwatch package worked out of the box for almost all my running services (Courier-POP, Postfix, OpenSSH). The relevant command is:&lt;br /&gt;&lt;div class="code"&gt;&lt;br /&gt;sudo aptitude install logwatch&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;The only service it did not work was the web server because logwatch is configured to use Apache log files by default while I use Lighttpd as web server.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;How to Configure Logwatch to parse Lighttpd log files (Ubuntu)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The easiest way to customize logwatch is to create an override.conf file  inside the /etc/logwatch/conf/ directory. To tell logwatch to parse lighttpd log files we create the override.conf file and add the following:&lt;br /&gt;&lt;div class="code"&gt;&lt;br /&gt;logfiles/http: LogFile = lighttpd/*access.log.1&lt;br /&gt;logfiles/http: LogFile = lighttpd/*access.log&lt;br /&gt;logfiles/http: Archive = lighttpd/*access.log.*.gz&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;This is assuming the lighttpd log files are inside "/var/log/lighttpd" directory. If they are not change the paths to reflect the location on your system. You can add as many log files as you want (i.e. virtual domains) by adding all three entries above for each log file.&lt;br /&gt;&lt;br /&gt;Now you will get some nice reports about the web usage in your server. Make sure you read the HOWTO-Customize-LogWatch file to learn more about logwatch. This file is usually inside the "/usr/share/doc/logwatch" directory in .gz format. To read it you can use the command:&lt;br /&gt;&lt;div class="code"&gt;&lt;br /&gt;zcat /usr/share/doc/logwatch/HOWTO-Customize-LogWatch.gz  | less&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Get Logwatch reports to via email&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;By default Logwatch sends the reports it generates to root. To send the reports to a different local user or external email address you can edit the "/etc/aliases" file like:&lt;br /&gt;&lt;div class="code"&gt;&lt;br /&gt;&lt;font face="monospace"&gt;&lt;br /&gt;&lt;font color="#ff6060"&gt;&lt;b&gt;1 &lt;/b&gt;&lt;/font&gt;&lt;font color="#00ffff"&gt;&lt;b&gt;# Added by installer for initial user&lt;/b&gt;&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;font color="#ff6060"&gt;&lt;b&gt;2 &lt;/b&gt;&lt;/font&gt;&lt;font color="#00ffff"&gt;&lt;b&gt;root&lt;/b&gt;&lt;/font&gt;&lt;font color="#ff6060"&gt;&lt;b&gt;:&lt;/b&gt;&lt;/font&gt;&amp;nbsp;&amp;nbsp; &lt;font color="#ff40ff"&gt;&lt;b&gt;myuser, mygmail@gmail.com&lt;/b&gt;&lt;/font&gt;&lt;br&gt;&lt;br /&gt;&lt;/font&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;and then rebuild the aliases database:&lt;br /&gt;&lt;div class="code"&gt;&lt;br /&gt;&lt;font face="monospace"&gt;&lt;br /&gt;&lt;font color="#ff6060"&gt;&lt;b&gt;1 &lt;/b&gt;&lt;/font&gt;sudo newaliases&lt;br&gt;&lt;br /&gt;&lt;/font&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;In the example above all Logwatch reports will be received by the local user "myuser" so you may access the reports via the mbox file at "/var/mail/mysuer" and to the external address mygmail@gmail.com that you may read using the Gmail web interface.&lt;br /&gt;&lt;br /&gt;Important Note: by default the mail transfer agent of (K)Ubuntu does not allow relay of messages to external addresses (i.e. gmail addresses). To change this you may follow the instructions to set a small personal mail server &lt;a href="http://piao-tech.blogspot.com/2008/04/simple-mail-server-kubuntu.html"&gt;here&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Logwatch vs Logcheck&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;I installed both programs and for me Logwatch is far more useful than logcheck. Logcheck will only parse the log files related to security (i.e. auth.log) and simply send you and email with the access denied entries. The information Logcheck provides is no different that I get by looking at the log files directly.&lt;br /&gt;&lt;br /&gt;Logwatch in the other hand provides relevant information not only about security issues but also from all the services running on the server. The information is well summarized and presented in a way it is easy to get a general and a detailed view of the server status and operation. &lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;How to make Webalizer work with Lighttpd in Ubuntu server&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;To get more visually compelling statistics about your web server usage patterns you can use &lt;a href="http://www.google.com/analytics/"&gt;Google Analytics&lt;/a&gt; that is a powerful tool. But if you prefer a simpler alternative but still powerful enough then I recommend installing &lt;a href="http://www.mrunix.net/webalizer/"&gt;Webalizer&lt;/a&gt;. &lt;br /&gt;&lt;br /&gt;In Ubuntu server if you are using Lighttpd instead of Apache make sure to change the configuration file (/etc/webalizer.conf) to point to the corresponding log file (i.e. LogFile /var/log/lighttpd/access.log.1) or it won't work.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Logwatch example report&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;div class="code"&gt;&lt;br /&gt;################### LogWatch 7.1 (11/12/05) #################### &lt;br /&gt;        Processing Initiated: Thu May 31 06:25:02 2007&lt;br /&gt;        Date Range Processed: yesterday&lt;br /&gt;                              ( 20075月-30 )&lt;br /&gt;                              Period is day.&lt;br /&gt;      Detail Level of Output: 5&lt;br /&gt;              Type of Output: unformatted&lt;br /&gt;           Logfiles for Host: makarena&lt;br /&gt;  ################################################################## &lt;br /&gt; &lt;br /&gt; --------------------- courier mail services Begin ------------------------ &lt;br /&gt;&lt;br /&gt; Connections: 100 Times&lt;br /&gt;   Protocol POP3 - 100 Times&lt;br /&gt;      Host 192.33.11.109 - 1 Time&lt;br /&gt;      Host 199.120.17.15 - 8 Times&lt;br /&gt;      Host 195.10.13.49 - 3 Times&lt;br /&gt;      Host 13.9.18.11 - 88 Times&lt;br /&gt; &lt;br /&gt; &lt;br /&gt; &lt;br /&gt; Logins: 96 Times&lt;br /&gt;   Protocol POP3 - 96 Times, 3790856 Bytes&lt;br /&gt;      User paprika - 1 Time, 21511 Bytes&lt;br /&gt;         Host 14.8.13.19 - 1 Time, 21511 Bytes&lt;br /&gt;      User mondongolia - 88 Times, 3389830 Bytes&lt;br /&gt;         Host 13.9.18.11 - 88 Times, 3389830 Bytes&lt;br /&gt;      User juanito3 - 7 Times, 379515 Bytes&lt;br /&gt;         Host 124.10.17.1 - 6 Times, 379515 Bytes&lt;br /&gt;         Host 124.10.13.4 - 1 Time, 0 Bytes&lt;br /&gt; &lt;br /&gt; &lt;br /&gt; &lt;br /&gt; ---------------------- courier mail services End ------------------------- &lt;br /&gt;&lt;br /&gt; &lt;br /&gt; --------------------- Cron Begin ------------------------ &lt;br /&gt;&lt;br /&gt; &lt;br /&gt; &lt;br /&gt; Commands Run:&lt;br /&gt;    User root:&lt;br /&gt;          run-parts --report /etc/cron.hourly: 24 Time(s)&lt;br /&gt;         [ -d /var/lib/php4 ] &amp;&amp; find /var/lib/php4/ -type f -cmin +$(/usr/lib/php4/maxlifetime) -print0 | xargs -r -0 rm: 48 Time(s)&lt;br /&gt;         [ -d /var/lib/php5 ] &amp;&amp; find /var/lib/php5/ -type f -cmin +$(/usr/lib/php5/maxlifetime) -print0 | xargs -r -0 rm: 48 Time(s)&lt;br /&gt;       test -x /usr/sbin/anacron || run-parts --report /etc/cron.daily: 1 Time(s)&lt;br /&gt; &lt;br /&gt; ---------------------- Cron End ------------------------- &lt;br /&gt;&lt;br /&gt; &lt;br /&gt; --------------------
