Convert TEX to PDF

Install TexLive in your OS.

Install latex2pdf which is dependent on TexLive.

cpan App::cpanminus # handy tool to install cpan module
cpanm Template # Template is missing on cygwin

cpanm latex2pdf # finally

Convert now!

pdf2latex cv.tex

Install perl module through source package on cygwin by using cpanm

I failed to install package "Template" by running `cpanm Template'.

It's because the binary package requires gcc4 while on my cygwin only gcc3 available.

So I install it from source package (with some hack, of course),

cpanm --look Template # Download and unpack the distribution and then open the directory with your shellI
cpanm . #install from local directory

Updated: I found the simpler solution was to install gcc4 at cygwin.

How to convert org to PDF

All you need to do is to install TexLive. The org-mode has some handy function to find the TexLive and do the conversion. So all you need to trigger the conversion in Emacs is pressing C-c C-e p'. </p> <p> At Cygwin and Linux, installing TexLive is a piece of cake by using default package system. </p> <p> At Mac, I use <a href="http://www.tug.org/texlive/acquire-netinstall.html">the default TexLive source package</a> (install-tl-unx.tar.gz). After installation, you need set up environment varaibles. </p> <p> If you use Bash (default at my OS X 10.7.3), you can paste below code to you ~/.bashrc: </p> <pre class="src src-sh"><span style="color: #af00ff;">if</span> [[ <span style="color: #cd00cd;">uname -s` == Darwin ]]; then #tex live on OS X export PATH=/usr/local/texlive/2011/bin/universal-darwin:$PATH export MANPATH=/usr/local/texlive/2011/texmf/doc/man:$MANPAH export INFOPATH=/usr/local/texlive/2011/texmf/doc/info:$INFOPATH fi

Install perl module through source package on cygwin by using cpanm

Install source package with some hack,

cpanm --look Template # Download and unpack the distribution and then open the directory with your shellI
#hacking ...

cpanm . #install from local directory

Notes on Emacs chat between John Wiegley and Sacha Chua

See http://sachachua.com/blog/2012/07/transcript-emacs-chat-john-wiegley/ for the video and transcript.

I only record items useful for me.

  • Use gnus heavily
  • ERC in another Emacs instance
  • Look at Magit buffer to get overview
  • Use builit in vc mode, C-x v =' to get diff of current file </li> <li>One single org, other seven are archives </li> <li>Helm (fork of anything.el) </li> <li>Gnus read mail and rss (gwene), Adaptive scoring is good. </li> <li>fetchmail to fetch from Gmail </li> <li>Organize Structure (rename/moving files folders) </li> <li>Twenty items in hot list in org-mode linking to other lists and areas of machine </li> <li>Dropvox to record voice at dropbox.com and org-mode hook to get voice message </li> <li>M-m to callorg-capture'
  • 'Quick Keys' on Mac plus some apple script (Viewing page in Chrome, M-n to activate emacs, put a link)
  • Emacs can view PDF
  • Reading Emacs manual from the scratch
  • Emacspeak to read the manual
  • Ledger for the accounting

How to configure yasnippet 0.7.0 and use it with Auto-Complete-Mode

I will only talk about how to set up yasnippet 0.7.0 or higher version.

If you follow normal install way, setup is simple

See its official documentation.

Install the yasnippet into somewhere and add following code into your .emacs:

(add-to-list 'load-path
              "~/.emacs.d/plugins/yasnippet-x.y.z")
(require 'yasnippet) ;; not yasnippet-bundle

(yas/initialize)

(yas/load-directory "~/.emacs.d/plugins/yasnippet-x.y.z/snippets")

If you use elpa package system, setup is even simpler

After installation, you only need two lines in .emacs.

(require 'yasnippet)

(yas/initialize)

Yasnippet 0.7.0 have already defined two locations for the snippets, "~/.emacs.d/yasnippet-install-path/yasnippet-x.y.z/snippets" and "~/.emacs.d/snippets". Yasnippet will load snippets in BOTH directories at startup.

So you only put your own snippets in "~/.emacs.d/snippets" and done. No need to tweak .emacs at all. To verify my claim, you can C-h v yas/snippet-dirs' to check value of "yas/snippet-dirs". Please note "yas/root-directory" is the alias of "yas/snippet-dirs". </p> </div> </div> <div id="outline-container-3" class="outline-3"> <h3 id="sec-3">The real world setup is NOT simple</h3> <div class="outline-text-3" id="text-3"> <p>I will explain the reasons at first and give my complete yasnippet configuration code at the end of the this post. </p> </div> <div id="outline-container-3-1" class="outline-4"> <h4 id="sec-3-1">Two snippets may share the same key, so I need activateyas/dropdown-prompt'

One issue is I need a user-friendly dropdown window popped up when the key I input has several candidates. For example, when I type "inc" in C code. There are two candicates #include "…"' and#include <…>' available. A handy dropdown popup will help me to choose one of them as efficient as possible.

The good news is such fancy popup is a standard component of yasnippet. It's called yas/dropdown-prompt'. Yasnippet's default algorithm will activate it at highest prority. </p> <p> The bad news is for some wierd reason yasnippet won't load that dropdown-list by default. So you need manually load that component by one line of elisp code(require 'dropdown-list)'.

yas/dropdown-prompt' is not perfect</h4> <div class="outline-text-4" id="text-3-2"> <p>I cannot scroll down the dropdown window when there are more candidates it can display. That's especially annoying when callingyas/insert-snippet'. In this case, we need use yas/completing-prompt' instead. I will show the fix at the end of this article. </p> </div> </div> <div id="outline-container-3-3" class="outline-4"> <h4 id="sec-3-3">Yasnippets conflicts with other plugins</h4> <div class="outline-text-4" id="text-3-3"> <p>I use <a href="http://cx4a.org/software/auto-complete/">Auto Complete Mode</a> (version 20120327 in elpa). There are two issuses when using it with yasnippets. </p> <p> First, it use TAB key to do the auto-complete thing while yasnippet also uses TAB key. So I need re-configure hotkeys of yasnippets. </p> <p> Second, yansippet changed its APIyas/get-snippet-tables' since version 0.7.0. This make the auto-complete cannot use yasnippet at all. This issue is reported and fixed by tkf. Actually all you need do is simple:
cd auto-complete-install-dir

rm auto-complete-config.elc

curl -L https://raw.github.com/tkf/auto-complete/337caa2ccc254a79f615bb2417f0d2fb9552b547/auto-complete-config.el > auto-complete-config.el

My final yasnippet setup

(require 'yasnippet)

(yas/initialize)

;; default TAB key is occupied by auto-complete

(global-set-key (kbd "C-c ; u") 'yas/expand)

;; default hotkey C-c &amp; C-s is still valid

(global-set-key (kbd "C-c ; s") 'yas/insert-snippet)

;; give yas/dropdown-prompt in yas/prompt-functions a chance

(require 'dropdown-list)

;; use yas/completing-prompt when ONLY when `M-x yas/insert-snippet'

;; thanks to capitaomorte for providing the trick.

(defadvice yas/insert-snippet (around use-completing-prompt activate) "Use </span><span style="color: #008787;">yas/completing-prompt</span><span style="color: #87005f;">' foryas/prompt-functions' but only here..." (let ((yas/prompt-functions '(yas/completing-prompt))) ad-do-it))

在我的Mac OS X 10.7.3上为heroku开发rails程序

rails版本为3.1,OS X版本10.7.3,postgresql版本9.1.3j

数据库必须用postgresql

heroku官方主页反对开发版本用sqlite3而生产版本用postgresql.

在OS X 10.7.3上安装postgresql

首先,检查你的OS X版本,从10.7开始OS X自带postgresql

sw_vers -productVersion

如果要安装最新版的postgresql,必须删除老版本的数据库。具体做法参考这篇文章,实际上也就是一行命令:

curl http://nextmarvel.net/blog/downloads/fixBrewLionPostgres.sh | sh

强烈推荐用homebrew安装数据库,

brew install postgresql

具体安装细节请参考postgresql官方wiki.

检测已安装的postgresql

这里是一些数据库基本操作的官方文档. 可以psql -l看一些已有数据库列表.

数据库用postgresql的rails项目

rails new myapp --database=postgresql

如果是从一个已经使用sqlite的项目切换数据库,就必须改config/database.yml,有一些catch,请参考stackoverflow上的讨论.

然后,createdb myapp_development创建postgresql数据库,rake db:migrate建立数据库schema并导入数据在本地数据库.简单测试可证明数据库和web程序可以无缝工作.

最后不要忘记git commit最新代码.

部署web程序到heroku

请参考heroku官方文档,提醒一下不要忘记运行heroku run rake db:migrate,否则数据库是空的.

部署结束后可以运行heroku open打开浏览器访问web程序首页.

如打开网站有问题,可以heroku logs查看日志.

针对Ruby on Rails开发的Emacs插件

我主要用两个插件rinariyari.

rinari支持在rails项目中多个文件快速跳转,另外它提供的grep工具我发觉也很有用.快捷键很容易记.

yari对ruby自带的ri工具提供一个emacs界面,优点是兼容最新的ruby,操作简单,只要使用一个函数yari-anything即可.但是其官方文档推荐的yari-anything的快捷键F1在有些远程terminal下有问题.我改成了C-c ; r.

阅读了rails中使用bootstrap相关文章的小结

Luca Pette的Twitter Bootstrap on Rails比较简单,直接使用了bootstrap的css,没用less,测试了simple_form,show_for,kaminari(分页数据)三个应用。要点在于kaminari有点兼容性问题,用twitter-bootstrap-kaminari-views解决这个问题,其他没难度。

@metaskill的LESS Is More - Using Twitter's Bootstrap In The Rails 3.1 Asset Pipeline讲了如何用bootstrap的less函数和变量,我很有兴趣,根据我的经验能通过less语法调用twitter的函数比较有价值。安装gem less-rails-bootstrap就行了,调用bootstrap的函数的技术细节省略,基本就是less语法。

Adding Twitter's Bootstrap CSS to your Rails app的作者也读了以上两篇文章,要点在于确认了@metaskill的方法,less的一些详细的例子。也提到了可以用sass,但我没有深入读下去。

Twitter Bootstrap Basics at railscasts.com非常好,一个完整的例子。Comments也不错,一些html细节。要点在于用了gemtwitter-bootstrap-rails,看起来很强大。

结论,看来我需要转向less而不是sass,因为bootstrap用less。

关于"一年成为Emacs高手(像神一样使用编辑器)"一文的答疑

我陆续收到Email,一些读者使用了我推荐的Emacs牛人配置后,Emacs启动或者使用还是有问题,

主要原因是,

  • 牛人如Steve Purcell用Emacs的最新版本24.x,而读者使用的是主流版本23.x。
  • 对于Emacs的一些基本命令还是不熟悉
  • 对github不是很熟悉

我建议不要丧失信心,事实上你离成为高手只有一步之遥了,以下是我的建议,

  • 还是要按照我原文所说,至少要读一下Emacs自带教程,启动emacs时可带"-Q"参数快速启动。
  • 学点github和git的操作很有帮助,如我原文所说。
  • 牛人Steve Purcell的配置还是很好改的,我一直在同步,可以轻易改为支持Emacs23 前提是你对于git和Emacs比较熟悉,当然这个前提需要你花点时间
  • 如果直接用Steve Purcell的配置有难度,可以考虑Emacs Starter Kit作为起步 Emacs Starter Kit有两个版本,一个版本支持Emacs24,一个版本支持Emacs22和Emacs23 我个人还是强烈建议最终使用Steve Purcell的配置。
  • M-x list-packages一次,如果你的Emacs在启动时下载软件由于网络问题有点卡的话
  • tsocks和export http_proxy=http://127.0.0.1:8000有时候是用的 在中国,技术人必须懂什么叫代理