2011-11-16

杂记 20111116 | Misc Notes 20111116

1.SingleCompile 是一个不错的 vim 插件,用于快速编译运行单个文件
2.vim 命令 :cope 查看所有编译错误
3.tsocks 从网络库层面给程序包装一个透明socks代理
4.删除 Messaging Menu 不需要的条目:
mkdir -p ~/.config/indicators/messages/applications-blacklist/
从 /usr/share/indicators/messages/applications 找到不需要的文件,在上面那个目录里创建链接
5.vim 的 wildmode 和 wildemenu 可以定制 vim 自动匹配(例如文件名)的模式
6.easytags 可以让vim根据tags进行语法高亮
7.让vim可以像Visual Studio一样在输入行末的分号或者右大括号时可以自动格式化代码
function! WL_auto_format()
    let curline = getline('.')
    let curcol = col('.')
    if match(curline[curcol :], '\S') == -1 " current char is curline[curcol-1]
        let c = curline[curcol-1]
        if c == ';'
            execute "normal \=$"
        elseif c == '}'
            execute "normal =%%"
        endif
    endif
endfunction

autocmd Filetype c imap ; ;:call WL_auto_format()a
autocmd Filetype c imap } }:call WL_auto_format()a
autocmd Filetype cpp imap ; ;:call WL_auto_format()a
autocmd Filetype cpp imap } }:call WL_auto_format()a

1.SingleCompile is an addon of vim, which makes it easy to compile-and-run a single file
2.:cope, to view all the compilation errors in vim
3.tsocks, an application the wraps network functions of another application, that goes through a socks proxy
4.Remove entries in Messaging Menu:
mkdir -p ~/.config/indicators/messages/applications-blacklist/
then link unwanted items from /usr/share/indicators/messages/applications
5.wildmode and wildemenu: determine how vim will autocomplete (e.g. file names)
6.easytags let vim highlight all the tags
7.Make vim auto formatting codes when ';' or '}' is pressed at the end of a line, like Visual Studio
function! WL_auto_format()
    let curline = getline('.')
    let curcol = col('.')
    if match(curline[curcol :], '\S') == -1 " current char is curline[curcol-1]
        let c = curline[curcol-1]
        if c == ';'
            execute "normal \=$"
        elseif c == '}'
            execute "normal =%%"
        endif
    endif
endfunction

autocmd Filetype c imap ; ;:call WL_auto_format()a
autocmd Filetype c imap } }:call WL_auto_format()a
autocmd Filetype cpp imap ; ;:call WL_auto_format()a
autocmd Filetype cpp imap } }:call WL_auto_format()a

2011-08-03

杂记 20110803 | Misc notes 20110803

1. Linux 查看程序访问的文件(类似filemon/processexplorer):
strace -e trace=file foo

2. mod_python 编译出错:
参考 http://blogold.chinaunix.net/u/19834/showart_2127433.html
connobject.c142行 !(b == APR_BRIGADE_SENTINEL(b) 改为!(b == APR_BRIGADE_SENTINEL(bb)

3. virtualbox 修改 host key: file -> preferences -> input

4. live meseenger 显示所有好友离线: 去控制面板->添加删除程序->修复live meseenger
也有说删除appdata的

5. linux 手动添加dns:
修改/etc/dhcp/dhclient.conf (可能还需要/etc/dhcp3/dhclient.conf),加入
prepend domain-name-servers 8.8.8.8;

6. Windows 7 godmode
建立文件夹,改名为GodMode.{ED7BA470-8E54-465E-825C-99712043E01C}



1. Monitor files accessed by a process on Linux (like filemon/processexplorer)
strace -e trace=file foo

2. cannot compile mod_python
from http://blogold.chinaunix.net/u/19834/showart_2127433.html
at connobject.c line 142 change !(b == APR_BRIGADE_SENTINEL(b) to !(b == APR_BRIGADE_SENTINEL(bb)

3. Change host key in virtualbox: file -> preferences -> input

4. All contacts in live messenger appear offline: control panel -> add/remove programs -> repair live messenger
Some says deleting appdata also works

5. Manually add dns on Linux
In /etc/dhc/dchlient.conf (probably also /etc/dhcp3/dhclient.conf), add a line
prepend domain-name-servers 8.8.8.8;

6. God mode in Windows 7
Create a folder and rename it to GodMode.{ED7BA470-8E54-465E-825C-99712043E01C}

2011-07-20

VirtualBox 在副屏上全屏显示 | Show VirtualBox in fullscreen on a secondary screen

链接: http://tipstank.com/2010/06/04/virtualbox-full-screen-second-monitor/

全屏后点下方自动隐藏菜单的View -> Virtual Screen 1 -> Use Host Screen 2



Link: http://tipstank.com/2010/06/04/virtualbox-full-screen-second-monitor/

Turn on fullscreen mode, in the auto-hide menu at the bottom, follow View -> Virtual Screen 1 -> Use Host Screen 2

2011-07-19

杂记 | Misc Notes

1. fontregister: Windows 下没有管理员权限时安装字体的小工具
2. 在Windows下Putty用Linux字体时可能需要选上Cleartype选项
3. x11vnc: 可以在终端开一个vnc server连接到一个已有的X会话上去
4. pomodoro: 工作25分钟,休息5分钟。一个有趣的工作模式
5. network-manager的共享网络模式(shared to other computers)似乎变的好用了(以前我这完全不能用)
6. Firefox添加书签时没有“在边栏显示”的选项,但是去书签管理看属性还是有的。



1. fontregister: a tool that allows you to register new fonts in Windows without admin privilege.
2. In putty on Windows, you may need to choose the "Cleartype" option when using Linux fonts
3. x11vnc: to create a vnc server that connects to a existing X session
4. pomodoro: work for 25 minutes, then rest for 5 minutes. A good way of time managing.
5. The "shared to other computers" mode in network-manager works well now.
6. In recent Firefox, there's no "load this bookmark in the sidebar" option when you add a new bookmark. However you can still find it, by checking the properties of an existing bookmark in the bookmark manager.

2011-05-03

杂记 | Misc Notes

1.gnome-shell 默认按一下winkey会出main menu, 这问题不大,但是其他我设的winkey+..的快捷键很多不能用了。比如f和空格都不行,但是t可以,很诡异。 解决办法是
system settings -> region and language -> layouts -> options -> alt/win key behaior -> meta is mapped to win keys

2.python的urllib记得是直接直接支持https的,但是不能验证证书(据说以后会实现的)。于是我找到了m2cypto这个模块,里面包装了urllib,证书有问题时会抛异常,但是证书没问题时会卡死。。。后来想了想,还是调用wget比较靠谱

3.gnome 3的控制面板里找不到startup applications了,但是可以直接运行gnome-session-properties

4.maximus:一个小软件,可以去掉最大化窗口的标题栏,配合gnome shell很不错。

5./usr/share/gnome-shell/js/ui/dateMenu.js还有panel.js可以对gnome shell顶部条进行hack,比如我把Activities改了名,自定义了时钟格式,去掉了accessibility图标。



1. By deault press the winkey once in gnome-shell will call up the main menu, this is not a big problem, but some shortcuts 'winkey + somekey' I set are not functional. For example 'f' and 'space' do not work, however 't' works, weird. To solve it:
system settings -> region and language -> layouts -> options -> alt/win key behaior -> meta is mapped to win keys

2. The urllib in python support https links, but it does not validate the certificates (some say that this will be implemented in the future). So I found the m2cypto module, it wraps urllib, and an exception will be thrown when there is problem with the certificate, however it sometimes went stuck when nothing wrong... Later I realized that it would be good just to call 'wget'

3. I cannot find 'Startup Application' in the gnome control center, but I can still run gnome-session-properties

4. maximus: a small tool that eliminate the title bar of maximized windows, looks quite good with gnome-shell.

5. Through the files /usr/share/gnome-shell/js/ui/dateMenu.js & panel.js we can hack the top bar of gnome shell, for example I renamed 'Activities', customized the datetime format, and removed the accessibility icon.

2011-04-26

路径环境变量中的陷阱 | 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:

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

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

尽管之前杂记里提了一下,但是现在还是特别再记录一下。

其实是偶然从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 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也不会崩溃

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

早就听说过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/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

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

经常换鼠标主题,经常好奇的看看里面内容,然后经常发现里面诡异的名字,比如这个:'00008160000006810000408080010102'

一直找不到这种名字的命名规范,最近要做一个主题转换脚本,于是仔细搜了一下。在

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

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 转换后,等待的指针动画有问题,很多人也在抱怨。

很久以前我就在用这个主题了,当时从 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.

2011-03-27

guake 类quake的下拉终端 | guake: a quake-alike drop-down terminal

平时需要个顺手的终端,希望呼之即来,挥之即去的。gnome-terminal 本身不错,但是呼叫用鼠标太慢了,最近考虑绑定个super+t之类的,但是每次开启也比较慢,另外不好隐藏,而且如果运行一个程序就想隐藏了,一会儿再回来找它看结果也不方便。

于是就想起了guake,以前装过,没好好设置,这次设了一下,还不错,主要是设了透明,去了tab和滚动条,失焦自动隐藏,绑定呼出/隐藏快捷键为super+`。

于是感觉生活太美好了,而且这样呼出一个terminal确实如quake系fps游戏一样,感觉在和系统核心打交道。

[Update] 刚看了一下guake源码,原来还有很多隐藏的gconf可以调整。现在把resizer也去了,完美了~



I really need a handy terminal in my daily life, I want it to appear as soon as I call it, and I want it to disappear when I do not need it any more. gnome-terminal itself is good, I've been using it, but maybe it is not quite suitable for this task, as it's too slow to call it, and I've considered to bind a shortcut super+t to call it, but it will not be convenient when I run something on it, hide it and want to see the result later.

The I recalled guade, I had tried it before, but without a deeper look. This time I went through the settings and make it a really handy terminal. Basically I adjusted the transparent background, hide the tar bar and scroll bar, make to auto-disappear when losing focus, and at last I bind the shortcut calling/hiding it to be super+`.

Then my life changed! It really likes those terminals in those fps game in quake style, and it dos make feeling communicating with the core of the system.

[Update] I found several hidden gconf settings after a quick browse of its source code. Now I've hidden the resizer, making guake perfect!

tesseract 一个ocr软件 | tesseract: an ocr application

最近需要写bot,要搞验证码,于是想到了ocr,搜到了几个,然后就找到了tessearact。看上去还不错,用了用确实不错。



Recent I needed to write a bot for some automation works, I needed to break some captchas, then I thought about an ocr appliction. I found a number of them from google, then I pick up tesseract among them. It looks good, and is really good as I have been using it.

vim 让背景透明 | make transparent background in vim

gnome-terminal 背景默认是透明的了(至少是ubuntu下),guake也可以弄成透明的,但是vim我用了colorscheme torte,结果背景是一坨黑,很不爽。

最近研究了一下,命令应该是hi Normal ctermbg=NONE,而且应该放到torte.vim里(直接放vimrc中colorscheme的后面没有用,没有再仔细研究)。于是把torte.vim放到~/.vim/colors里,改名,把Normal一行的ctermbg设成None。就好了。 (当然vimrc里要加载这个新的颜色)

另外改guibg后gvim会报错,也没有再自己研究。我基本也不用gvim。



The background color of gnome-terminal has already been transparent, and so has guade. But (maybe since) I use 'colorscheme torte' for vim, the background is a huge black block, ugly...

So I check the help page in vim and found the command should be 'hi Normal ctermbg=None', it's no use if put below the 'colorscheme' scheme in .vimrc, I have to change the color file. So I move the torte.vim in to my ~/.vim/colors, changed its name,and changed ctermbg to be 'NONE' at the line containing 'Normal'. Then it's done (of course you need to load this new scheme file in vimrc)

Besides, gvim will show an error dialog if I set guibg to be NONE, don't know why but ok for me as usually I don't use gvim.

2011-02-13

Windows 7 不能自动给移动硬盘分配盘符 | Windows 7 won't assign a volume letter for removable hard disks automatically

症状:
插上移动硬盘后,显示连接了usb设备,但是在我的电脑里看不到新盘符。
用计算机管理里面的磁盘管理可以手动设置盘符,然后可以使用。

解法:
以管理员权限运行命令mountvol /e



Symptom:
A new volume won't appear in 'my computer' after plugging in a removable hard disk, but it shows that a new usb device has been plugged in.
A volume letter can be manually assigned through the disk management in computer management console, then the removable disk can be used normally.

Solution:
run as adin: mountvol /e

2011-01-21

ubuntu 下挂载ipad | Mounting ipad on Ubuntu

默认情况下插上ipad会报个dbus错误。

应当安装ifuse这个包,但是官方源的目前不够新。

按ifuse官网说法,添加ppa ppa:pmcenery/ppa,更新一下就好了。




In default installation, after plugged in an ipad, a dialog will show saying something wrong with dbus.

The package ifuse would be necessary for accessing ipad, but the one in the official repository is not new enough.

According the the web page of ifuse, just to add the ppa ppa:pmcenery/ppa, then perform an upgrade.

2011-01-20

ios 游戏修改 | Cheating games in iOS

以前看网页都说是只能破解才能修改,今天发现其实不是

用iphone explorer可以看到app信息,这就够了,游戏的存档也都在这里。目前像megajump, run as hell都没问题,所以存档类的修改都ok了。

二进制不知道是不是也能修改,看样子是可以。

但是锁定变量这种修改应该就不行了吧。



It was said in several web pages that game files can be modified only in jailbroken ios, but today I found that this is not true.

We can explorer the files for apps with iphone explorer, and this is enough. I've successfully modified savegames of megajump and run as hell.

I'm not sure if we can modified the binary files of the games, seems to be ok.

But maybe we can not lock any variables.

2011-01-05

启用compiz和fglrx时的vnc问题 | Problem of vnc server with compiz and fglrx enabled

困扰了我近两年的问题。

远程连vnc回我的电脑,第一个画面能看到,鼠标也可以动,但是键盘按没反应,画面也不会再动。
一开始以为是网络问题,或者是设置了view only,但是本机上看,鼠标和键盘都得到了响应,所以只是屏幕刷新的问题。

这个问题我一直不知道原因。 但是最近新装的ubuntu,一开始是可以连得,没有问题,我还以为是更新了解决了这个问题。但是最近又不行了,我才开始想最近改了什么设置。 最后发现原来是启动了fglrx,关了radeon。 改回radeon后vnc又复活了。

于是查了一下, 果然是个bug,见https://bugs.launchpad.net/ubuntu/+source/xorg-server/+bug/353126, 而且nvidia的闭源驱动也有这个问题,我以前是用的nvidia的卡,只是一直用它的驱动,所以没有发现这个问题。



A problem that has been bothering me for nearly two years.

So the problem is, when trying to remotely connect to the vnc server enabled on my computer, I can see only the first screenshot, without further update, the mouse pointer is moving, but keyboard events are not responded.
I thought at first this must be something wrong with the network, or maybe "view only" is set on the server, however on my computer I see that mouse and keyboard are working properly, so it's only the problem of screen updating.

I didn't know the reason all the time until now. Recently I have a new Ubuntu installed on my computer, in the first few days vnc server was working well, and I had thought that this problem had been solved in this new version of Ubuntu. However vnc failes again these days, and I begin trying to remember what I have changed in the system. In the end I found that I've enabled fglrx and disabled radeon. And vnc come back to alive after switching back to radeon.

Later I found that it's indeed a bug, see https://bugs.launchpad.net/ubuntu/+source/xorg-server/+bug/353126, which also affects the nvidia proprietary driver. I was using nvidia cards before, but I had always been using its proprietary driver, and that's why I didn't find the cause before.

2011-01-01

ubuntu 10.10 ptrace权限的变动 | change in behavior of ptrace in ubuntu 10.10

最近有人在scanmem提交bug,说非root不能attach其他进程。当时我用的ubuntu 10.04,没能重现这个问题。最近用上10.10,发现确实有这个问题,于是考虑到是不是ubuntu的变动。简单搜了一下,在https://wiki.ubuntu.com/SecurityTeam/Roadmap/KernelHardening#ptrace%20Protection找到了原因,是10.10里故意这么设置的,目的是保护进程。

其作用的是/proc/sys/kernel/yama/ptrace_scope这个sysctl值,以前是0,ubuntu 10.10里默认是1。

于是scanmem以后需要root权限了。

而这个事情对于ubuntu是个好事情。



Recent some one has posted a bug in scanmem, that the program can no longer attach to other processes without run as root. At the moment I was still using ubuntu 10.04, where I couldn't reproduce the bug. Now I've been using 10.10 and I did confirm that bug. So I think this must be something changed in ubuntu. After a brief searching, I found the reason at https://wiki.ubuntu.com/SecurityTeam/Roadmap/KernelHardening#ptrace%20Protection, so that was changed intended, in order to protect the processes.

The key value is the sysctl value "/proc/sys/kernel/yama/ptrace_scope", which is 0 by default before, but now 1 by default.

So in the future scanmem will need to run as root.

And this is quite a good news for ubuntu.