Skip to main content

Posts

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

最近需要在没有root的机器上配一个自己的编译环境,于是需要改一些环境变量,比如 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:...

杂记 | 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.

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. 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 introdu...

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

杂记 | 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也不会崩溃 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 availabl...

Mutt 初探 | My first attempt at Mutt

早就听说过Mutt,但是之前每个教程都是大长篇的关于mutt, fetchmail/getmail, sendmail的配置,令人畏惧。 最近下决心试试这个所谓最好的邮件客户端,搜了几个教程发现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/usi...

latex 转义字符 | esapce characters in latex

如下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.