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"
当然可能还需要其他的。
如果就按这么写明显有问题,比如PATH原先可能不是空的,所以应该写成PATH="#/bin:$PATH",其他变量也类似。但是这样会有个更严重的问题,困扰了我一天。
问题出在C_INCLUDE_PATH,一般这个变量都是空的,所以按上面的方法添加自定义路径后变成了"#/include:",而这个末尾的":"会被理解为末尾有个当前目录,即'.',开头的':'以及中间的'::'会有同样情况。
另一方面,在使用automake编译的程序中,经常会出现-I.的编译参数,而且通常出现在最开始以保证当前目录是第一个被搜寻的路径。但是如果'.'出现了C_INCLUDE_PATH中,gcc会认为它是系统标准路径,于是命令行中的-I.会被忽略掉。这样搜索路径的顺序就改变了,就会出问题。
我是在编译binutils时发现的问题,很多目录里都有config.h,于是搜索路径的顺序很重要。
解决方法当然也很简单,就是麻烦一些,即判断一下原来的路径是否为空,避免添加多余的分隔符':'。
Recently I need to set up a development environment without root privilege, therefore I need to tweak several environment variables, for example:
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"
and maybe more.
Well there is a problem here, for example PATH may not be empty before we set it, so it would be better to write as PATH="#/bin:$PATH". This is also true for other variables. However this may lead to a more serious problem, which made me spending a whole day before resolving it.
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
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
其实是偶然从linuxtoy里的脚本看到了这个主题名字,感觉很漂亮。然后深入搜了一下。
这个主题对比度相对比较低,或者说亮度上的对比度比较低,而主要靠色相来提高肉眼辨识度。
另外它的一个精妙的地方在于,颜色经过精心挑选,不论是深色背景还是浅色的,前景色都能很好的显示
以下是各种链接,除了我提到了还有一些其他的(我不常用的和没听说过的)
主页:
http://ethanschoonover.com/solarized
主git源: vim,emacs,mutt,gimp palette,Xresources
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
我的fork: 256color for gnome-terminal and guake
https://github.com/coolwanglu/gnome-terminal-colors-solarized
我的fork: Guake
https://github.com/coolwanglu/guake-colors-solarized
说明
1.
2.terminal的主题一定要配合dircolors一起用,否则ls出来会很难看
3.vim里有多种选项可以配置主题
4.
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.
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.
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
2. 禁用一个upstart的服务: echo "manual" >> xxx.conf,natty的upstart版本支持了override文件,于是可以 echo "manual" >> xxx.override
3. bootchart小工具可以分析开机时各程序启动,资源占用等情况,另有pybootchartgui可以将结果转换成图片查看
4. colortest 用于测试终端对颜色支持情况
5. synapse 一个 gnome-do 替代品,不依赖mono,重启compiz也不会崩溃
6. vimperator 最近又用了一下,比以往好了很多,装上以后多了各种快捷键,同时也不影响原来的界面。对gmail和google reader有冲突,之需要按一下ctrl+z
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
最近下决心试试这个所谓最好的邮件客户端,搜了几个教程发现sendmail不怎么要配,而mutt有收邮件功能(我只用gmail),所以只需要配mutt。
研究了两天终于配好了muttrc,而后几天慢慢研究新功能,现在基本功能都会了,确实很好用!
我的.muttrc放在了github上
然后需要提的一些
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
注意"-I %{charset}"这个参数
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,太爽了。
最后是一些link
关于muttrc配置
/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:
About muttrc:
/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
About certificates:
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}
原因是[a]被识别成了\\后跟的长度,于是报错,于是需要把[转义,写成{[}就好了。
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
找到了结果。里面之说说这些是hash,也没说是个怎样的历史缘由。
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
2. 软件 auto-apt, 可以自动安装 ./configure 报出的缺失的依赖包
3. 软件 simple-ccsm, 调节compiz特效一步到位,省时省力
1. In compiz, we can adjust the size of the windows by pressing alt+
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
// 解决困扰我好久的问题 :)
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 转换后,等待的指针动画有问题,很多人也在抱怨。
很久以前我就在用这个主题了,当时从 http://d.hatena.ne.jp/tksmashiw/20080421 找到了解法。最近又想折腾,想起了这个主题和这个网站,看到这个网站很久没更新了,就转过来吧。
主要步骤是
把GreenApparatus.CurXPTheme解压(就是zip)
修改scheme.ini,找到[Wait]段,修改第二行为Frames=107然后[Wait_Script]段第二行改成27-107,40
而后重新打包,再用sd2xc转换就没问题了。
再次感谢原作者。
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.