## 2011-04-26

### 路径环境变量中的陷阱 | Traps in path related environment variables

CFLAGS="-I#/include"
LDFLAGS="-L#/lib"
PATH="#/bin"
LD_LIBRARY_PATH="#/lib"
LIBRARY_PATH="#/lib"
MANPATH="#/man"
C_INCLUDE_PATH="#/include"
CPLUS_INCLUDE_PATH="#/include"
PKG_CONFIG_PATH="#/lib/pkgconfig"

It was all because of C_INCLUDE_PATH, usually it is empty, so if I prepend something in the way mentioned above, it'll become "#/include:". The trailing ':' will actually be interpreted as a 'current directory' in the end, that is '.'. And it also happen for a staring ':' and a '::' in the middle.

On the other hand, for programs utilizing automake, we often see a parameter '-I.', which is often appears in the beginning in order to make '.' the first searched directory for header files. However if '.' appears in C_INCLUDE_PATH, gcc will then consider it a 'system standard path', and therefore ignore the parameter '-I.'. In this way the order of searching directories is changed, then issues may appear.
I found this when I was compiling binutils, where the file 'config.h' appears in many directories, such that the order of searching directories is quite important.

To resolve it, simple but trouble, just to check whether the original variable is empty before prepend anything, in order to avoid a trouble-making ':'.

### 杂记 | Misc Notes

1. tidy, csstidy，两个小工具，可以优化html和css
2. perl安装模块： perl -MCPAN -e shell
3. python安装模块： easy_install 或 pip
4. gcc 查看本机CPU类型 gcc -v -mtune=native
5. bash 里面二重替换变量： eval B="$"$A, 举例来说如果A=X,X=100，那么这个语句之后B=100
6. Linux From Scratch: 详解从无到有编译一套Linux，值得一看

1. tidy & csstidy: 2 small tools for optimizing html and css files
2. to install perl modules: perl -MCPAN -e shell
3. to install python modules: use easy_install or pip
4. to view how gcc detects local cpu: gcc -v -mutune=native
5. to recursively substitute variables in bash: eval B="$"$A, for example when A=X and X=100, then the previous statement results in B=100
6. Linux From Scratch: describing how to build a complete Linux from nothing, worth reading.

## 2011-04-18

### solarized 颜色主题 | the solarized color theme

http://ethanschoonover.com/solarized

https://github.com/altercation/solarized

sigurdga的fork: gnome-terminal
https://github.com/sigurdga/gnome-terminal-colors-solarized

seebi的fork: dircolors, tmux
https://github.com/seebi/solarized

https://github.com/coolwanglu/gnome-terminal-colors-solarized

https://github.com/coolwanglu/guake-colors-solarized

1.guake和gnome-terminal用的gconf类似，手工copy一下就行。不过我打算写个脚本，顺便学学git
2.terminal的主题一定要配合dircolors一起用，否则ls出来会很难看
3.vim里有多种选项可以配置主题
4.原来gnome terminal那个是16色的port，我fork并改出一个256色的，另外加入了guake的支持
5.256色是终端不使用这个主题时的临时方法，所以我原来的理解有问题，于是分离出一个单独的guake源

Although I've already mentioned this theme in the previous misc notes, but now I've decided to introduce it again in this separated article.

Actually I saw the name of this theme in a configuration file mentioned in linuxtoy, I found it quite beautiful, then I took some googling.

The contrast of this theme is relatively low, or more precisely, low contrast in lightness, but the colors are still well distinguishable due to the different hue values used.
Another wonderful point of this theme is that, the colors are carefully chosen, such that the foreground colors can always show a good appearance no matter on a dark or light background, cool!

Here are some links, and note that the repositories may provide more than what I mention here (those I don't use or never heard about)

Homepage：
http://ethanschoonover.com/solarized

Main git repository: vim,emacs,mutt,gimp palette,Xresources
https://github.com/altercation/solarized

sigurdga's fork: gnome-terminal
https://github.com/sigurdga/gnome-terminal-colors-solarized

seebi's fork: dircolors, tmux
https://github.com/seebi/solarized

My fork: 256color for gnome-terminal and guake
https://github.com/coolwanglu/gnome-terminal-colors-solarized

My fork: Guake
https://github.com/coolwanglu/guake-colors-solarized

Notes:
1.guake uses a similar gconf schema with gnome-terminal, so a copy&paste works. Well I have planned to write a script for this, and learn some git by the way.
2.the theme for gnome-terminal should be used along with dircolors, otherwise the output of 'ls' would be a mess
3.there are some options for the vim theme
4.The gnome-terminal port above is a 16colors version, so I forked and made a 256colors version, also I added support for guake.
5.The '256color' version is a workaround for terminal applications, when this theme is not used in the terminal, so I did not understand it correctly. Now I've created a separated repository for Guake.

### gmail 修改姓名显示 | change display name in gmail

mail settings -> accounts and import -> send email as -> edit info

When sending email, I want my Chinese name displayed with my email address, but by default the first name appears first, to change this:

mail settings -> accounts and import -> send email as -> edit info

## 2011-04-17

### 杂记 | Misc Notes

1. Firefox 全屏时显示地址栏和标签栏，设置browser.fullscreen.autohide=false

2. 禁用一个upstart的服务: echo "manual" >> xxx.conf，natty的upstart版本支持了override文件，于是可以 echo "manual" >> xxx.override

3. bootchart小工具可以分析开机时各程序启动，资源占用等情况，另有pybootchartgui可以将结果转换成图片查看

4. colortest 用于测试终端对颜色支持情况

5. synapse 一个 gnome-do 替代品，不依赖mono，重启compiz也不会崩溃

7. solarized 一个很不错的颜色主题，可以用于vim mutt terminal等等，很不错。也有对gnome-teriminal的移植，但是我这里显示效果不是很好

8. Terminus 一个很不错的终端字体，适用于小字号

1. To show the location bar and tab bar when Firefox is in fullscreen mode, set browser.fullscreen.autohide=false

2. To disable an upstart service: echo "manual" >> xxx.conf. Staring from Natty, upstart has supported the override files, so we may use: echo "manual" >> xxx.override

3. bootchart is a small tool to visualize the performance (of programs, resources) in the boot process, and pybootchartgui is available to convert result into images.

4. colortest is something useful to test the color capabilities of terminals

5. synapse is an alternate of gnome-do, which does not depend on mono, and does not crash when restarting compiz

6. vimperator: has been using it again, now it's much better than before, with many convenient shortcuts, while keeping the old interfaces. It conflicts with the key binds in gmail and google reader, but can be resolved by pressing ctrl+z

7. solarized is a great color scheme for vim mutt terminal etc. There's also a port for gnome-terminal, which unfortunately does not look good on my machine

8. Terminus is a good font family for terminals, best in small font sizes.

## 2011-04-16

### Mutt 初探 | My first attempt at Mutt

1.取消命令需要按Ctrl+g
2.默认w3m不能很好的识别编码，解决方法是在~/.mailcap里加入一行
text/html; /usr/bin/w3m -I %{charset} -dump -T text/html '%s'; copiousoutput; description=HTML Text; nametemplate=%s.html

3.需要用smime_keys init建立需要的有关smime证书的目录，然后信任的根证书放在mutt的变量smime_ca_location里。我放到了~/.smime/ca-bundle.crt
4.mailto的配置，gnome有个小bug，preferred application选了mutt后不能默认勾上run in terminal，导致mutt不能正常运行。解决办法就是选custom，勾上run in terminal再选mutt
5.搜到了muttator，里面说mutt如何如何不好，呵呵。这个thunderbird插件也挺有趣的，回头再看看。
6.在全屏的guake里开一个tmux，然后再在tmux里开mutt，太爽了。

/usr/share/doc/mutt/*
http://crunchbanglinux.org/wiki/howto/howto_setup_mutt_with_gmail_imap
http://wiki.muttqq:s.org/?UserStory/GMailOverIMAP
https://github.com/redondos/mutt
http://therandymon.com/woodnotes/mutt/using-mutt.html
http://muttrcbuilder.org

http://equiraptor.com/smime_mutt_how-to.html
http://wiki.cacert.org/EmailCertificates
http://gagravarr.org/writing/openssl-certs/email.shtml
http://gagravarr.org/writing/openssl-certs/others.shtml
http://wiki.mutt.org/?MuttGuide/UseGPG
http://kb.wisc.edu/middleware/page.php?id=4091

I've heard about Mutt long before, but in whichever tutorial there were always super long configuration files about mutt, fetchmail/getmail and sendmail, quite scaring...

Recently I've made up my mind to learn this so-called the best email client, after minutes of searching I found out that there had been no need to configure sendmail, and since mutt had already supported retrieving emails (I use gmail only), I only need to configure mutt itself.

I spent two days before I completed my muttrc, after that I learned more things through using it. Now I've been familiar with most basic operations, indeed Mutt is a great email client!

I've put my .muttrc on my github page.

And something more:

1.To cancel a command, press ctrl+g
2.By default w3m cannot recognize the encodings well, to resolve this, add a line in ~/.mailcap:
text/html; /usr/bin/w3m -I %{charset} -dump -T text/html '%s'; copiousoutput; description=HTML Text; nametemplate=%s.html
pay attention on the parameter "-I %{charset}"
3.Use 'smime_keys init' to create directories needed for smime handling, then put trusted certificates in the 'smime_ca_location' (a variable in mutt). I put mine in ~/.smime/ca-bundle.crt
4.About mailto handling, there's a bug in GNOME that 'run in terminal' is not ticked by default in preferred application (when you select mutt), which causes mutt not be able to run correctly. To resolve this, select 'custom program', tick 'run in terminal', then select (back) 'mutt'
5.I found 'muttator' when I was searching for something about mutt, there is an article on its homepage about why Mutt sucks, quite interesing. I might try this addon of Thunderbird later.
6.Now I'm using mutt inside tmux, which is run in a fullscreen guake, so cool!

Some useful links here:
/usr/share/doc/mutt/*
http://crunchbanglinux.org/wiki/howto/howto_setup_mutt_with_gmail_imap
http://wiki.muttqq:s.org/?UserStory/GMailOverIMAP
https://github.com/redondos/mutt
http://therandymon.com/woodnotes/mutt/using-mutt.html
http://muttrcbuilder.org

http://equiraptor.com/smime_mutt_how-to.html
http://wiki.cacert.org/EmailCertificates
http://gagravarr.org/writing/openssl-certs/email.shtml
http://gagravarr.org/writing/openssl-certs/others.shtml
http://wiki.mutt.org/?MuttGuide/UseGPG
http://kb.wisc.edu/middleware/page.php?id=4091

### latex 转义字符 | esapce characters in latex

\begin{eqnarray}  a &=& b \\  [a] &=& [b] \\\end{eqnarray}

The following Latex code won't compile:

\begin{eqnarray}  a &=& b \\  [a] &=& [b] \\\end{eqnarray}

and the reason is that [a] is recognized as the length parameter of \\. So [ should be escaped, if written as {[} there won't be error any more.

## 2011-04-05

### X11 鼠标主题中的诡异名字 | Weird names in X11 cursor themes.

http://fedoraproject.org/wiki/Artwork/EchoCursors/NamingSpec

I used to change mouse cursor theme, and often I would like to peek at the contents in the packages. Well I always see weird names such as '00008160000006810000408080010102'.

I've got no idea about this kind of names. Recently as I'm making a cursor theme converter, I googled for a while, then found something useful at:

http://fedoraproject.org/wiki/Artwork/EchoCursors/NamingSpec

It says these names are hashes, but the reasons are not mentioned.

## 2011-04-03

### 最近发现的小技巧 | Tips I found recently

1. compiz 可以用alt+中键调整窗口大小，特别适合用窄边框的我，在也不用在那一个像素周围纠结了。
2. 软件 auto-apt， 可以自动安装 ./configure 报出的缺失的依赖包
3. 软件 simple-ccsm, 调节compiz特效一步到位，省时省力

1. In compiz, we can adjust the size of the windows by pressing alt+ , which is quite suitable for people like me who are using thin window borders. Now I'm free from struggling at that 1 pixel.
2. The software 'auto-apt' can install those missing packages reported by ./configure
3. The software 'simple-ccsm' can set the effects of compiz within one-click.

### [转] That mysterious J

// 原文链接： http://blogs.msdn.com/b/oldnewthing/archive/2006/05/23/604741.aspx
// 解决困扰我好久的问题 :)

In e-mail from Microsoft employees, you may find a stray J like this one at the end of a message from Rico Mariani. Some of you might see it; others might not. What's the deal with the J?

The J started out its life as a smiley-face. The WingDings font puts a smiley face where the letter J goes. Here, let me try: J results in J. As the message travels from machine to machine, the font formatting may get lost or mangled, resulting in the letter J appearing when a smiley face was intended. (Note that this is not the same as the smiling face incorporated into Unicode as U+263A, which looks like this: ☺. Some of you might see it; others might not.)

I recall a story (possibly apocryphal) of somebody who regularly exchanged a lot of e-mail with Microsoft employees and who as a result started signing their own messages with a J, figuring this was some sort of Microsoft slang. The Microsoft employees who got the J-messages scratched their heads until they were able to figure out how their correspondent arrived at this fabulous deduction.

And now, the mysterious J has come full circle, because some people use it ironically, intentionally just writing a J without setting the font, in the same way people making fun of "leet" writing may "accidentally" type "1"s (or even more absurdly, the word "one") into a row of exclamation points.

### Green Apparatus 转换为 Linux 鼠标指针主题的修正 | Fix converting Green Apparatus to Linux mouse cursor theme

Green Apparatus 是一个经典的 CursorXP 鼠标主题，有这很有创意的动画和很棒的美工。虽然 CursorXP 是给 Windows 的，但是网上有个 sd2xc 脚本可以把 CursorXP 主题转换成 X11 主题，很不错。

Green Apparatus is a great CursorXP theme, the artwork is awesome and the animation is creative. Although CursofXP is for Windows only, there has been a script called sd2xc which can convert them into X11 themes.

However there's a problem, that the animatino of the wait cursor does not work well, many people had been complaining about this.

I used this theme long before, I found the fix at http://d.hatena.ne.jp/tksmashiw/20080421. Recently I want to tweak my machine again, and I remembered this theme and that website. I found that web site had not been updated for a long time, so I note the steps here.

So what we need to do
unpack GreenApparatus.CurXPTheme, which is actually a zip archive
edit scheme.ini, in the [Wait] section, change the 2nd line to Frames=107, then in the [Wait_Script] section, change the 2nd line to 27-107,40
repack, and convert with sd2sc

Thanks to the original author again.