Longtime no post on my blog , and i just brought a nice USB keyboard from local store.

But it really sucks each time i plug in my USB keyboard. Since X11 is on the hood , my customized key mapping will fail to process unless i relaunch corresponding command set in ~/.xinitrc , namely `setxkbmap` in this case.

Digging a bit on Google , i found it possible to monitor USB device changes through well-defined dbus interfaces provided by Hal:

askubuntu.com/questions/27948/usb-device-changes-using-udev-and-d-bus

But since i adores perl , here i will demonstrate an equivalent and functional script written totally in perl , it’s available for downloading here:

http://pastebin.com/1iFnPqSL

Script preview can be found below , now i just unplugged my USB mouse and re-plugged it in , which instantaneously triggered huge outputs in my console:

Redistribution is allowed , and feel free to post a comment here , it’s welcomed ;-P

SRC_URI=http://sciencenews.org/view/generic/id/70083/title/Model_copes_with_chaos_to_deliver_relief
一种通过与混乱对抗以传递安慰的模型

华盛顿 — 把血液或者其他的珍贵物品供给传输到一个,刚刚经受地震或者风暴的区域并不是向问Brown可以做什么那么简单。但是一个新的模型,可以很快的对运输人类援助物品的,最佳路线和策略进行决策,即使当下桥梁损坏或者机场有大雾天气。

这个研究,在2月18号的美国 Advancement of Science 协会年度会议上提出,可以帮助经历自然灾害的区域运输供给,或者当流感来袭,可用于传输疫苗。

有效的的供给链一直都是制造商的一个目标,但是在不可靠的运输网络中–即攻击、需求以及运输路线都是快速变化的–需要一个不同的方式,Massachusetts Amherst大学的Anna Nagurney代表纽约市说到。除了考虑最短路径以谋求最大利益外,她的系统致力于用最小代价清理路径,同时考虑其他因素,如货物价值和不确定的路线带来的隐患。“你不知道需求会在哪里,所以很有技巧性。” Nagurney 说到,“这个是多因素的决策问题”。

文章来源:

http://www.sciencenews.org/view/generic/id/69615/title/News_in_Brief_Atom_%2B_Cosmos

新闻概要: 原子 & 宇宙月球如何获得水资源,本月将会有更多报道

Titan 卫星的卷云

在极度寒冷的土卫Titan上,在烟雾缭绕的大气中,Cassini 宇宙飞船已经测量了,Wispy类云的充足性和他的成分。Cassini在大气中找到的这些卷冰云,可以用于追溯改变冰离子充足性的原因:亚硝酸盐和碳水化合物。在不同唯独和Titan不同的季节下,NASN Goddard太空飞行中心(位于Greenbelt, Md.,)的Carrie Anderson,以及Maryland in Colledge Part大学的Robert Samuelson报道了即将来临的 Icarus. 比如,因为大气总是从温暖的区域,移动到寒冷的区域,处在冬季的北半球现在滞留着比南部更多的冰云. — Ron Cowen

大量的行星诞生

欧洲航天局工作的Herschel光学望远镜已经开始定位那些黑暗的冷云气团,这些气团看起来像是“丝绸之路”质量最大的行星的诞生地。通过测量云团的温度,Herschel已经确认了行星形成以及在行星形成过程中最有可能摆脱光束的的气团。

卫星上的水资源

行星科学家说他们已经发现了新的证据,关于太阳风在产生在卫星上发现的水的过程中所扮演的角色。一份对由印度的  Chandryaan-1 飞船记录数据的分析,强有力的证明了在卫星上的细微沙粒将质子限制在风中,继而在土壤中这些质子和氧气产生了水分子层,Maryland in College Park 大学的Jessica Sunshine以及他的同僚将会在不久之后的 Journal of Geophysical Research – Planets 中报道。同样的产生水的过程也在其他无水、富有硅酸盐的星球上具有可行性,比如 NASA 的 “黎明飞船“ 将要于 2011年中旬访问的Vesta 陨石。

Since last year i checked out the old project relating KDE plasma global menu , namely “Plasma GlobalMenu” , and found it buggy , so i did a modification , and put it here:

http://kde-apps.org/content/show.php?content=129006

And it took me sometime to fix “Beaucoup de bugs” , and finally Thomas merged this application to project “Bespin” , which is a style of KDE , yeah my favorite also. So please try latest svn version of Bespin , ignore my last project, it’s now unmaintained.

So if you want all supported application has an ability of Global Menu , you need to enable Bespin style for all Qt applications , try:

qtconfig

And apply “Bespin” now , there you go.

So , how it looks actually , huh ? Take a look at the snap below:

Editor is “Scite”  , GTK+ based application , and i’m running a program called “Super Xorg TTS Tolz” , clearly i gave a ugly name , but who cares ? All you had to do is double click and select the word you wonna pronounce , and it works , also include a support for transformed verbs , like “flugged” , “playing” etc. My program can recognized them too ;-P , bit of off topic , but you got it.

Do we really need the CapsLock Key , i don’t. Maybe somebody would rather take this as a design fault.

Mapping to CTRL key is a good taste , it’s much more nearer to your finger , thus more convenient.

For Windows System , a easy solution would be save the entries below and import it to window register:

Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout]“Scancode Map”=hex:00,00,00,00,00,00,00,00,02,00,00,00,1d,00,3a,00,00,00,00,00

UNIX is rather simple , for Xorg system , simply try launch this command after Xorg initial process:

setxkbmap -option ctrl:nocaps &

A happy keyboard hacker could play around with standard UNIX keyboard mapping file , which is stored in /usr/share/keymaps/

Remember to put a backup first , before any changes took place:

/usr/share/keymaps/i386/qwerty/us.map.gz

Extract and edit us.map , and seek for the entry about Caps_Lock

Modify this

keycode  58 = Caps_Lock
Well , of course do a substitution , and we got it.
To  keycode  58 = Control
Now put it back to /usr/share/keymaps/i386/qwerty/us.map.gz , run as root to load new keyboard mappings :
# loadkeys us
See it , easy huh ?

Ever think about the usage of likely / unlikely macros in LINUX kernel ?

Now it’s bit different on the latest stable kernel  version 2.6.34 ,  so  it’s defined as:

See include/compiler.h , tripped version.

#  define likely(x)     (__builtin_constant_p(x) ? !!(x) : __branch_check__(x, 1))
#  define unlikely(x)   (__builtin_constant_p(x) ? !!(x) : __branch_check__(x, 0))

You can use the built-in function __builtin_constant_p to determine if a value is known to be constant at compile-time and hence that GCC can perform constant-folding on expressions involving that value. The argument of the function is the value to test. The function returns the integer 1 if the argument is known to be a compile-time constant and 0 if it is not known to be a compile-time constant. A return of 0 does not indicate that the value is not a constant, but merely that GCC cannot prove it is a constant with the specified value of the -O option.

So when __builtin_constant_p(x) is not determinable , gcc can help programmers do branch predication with __branch_check__(x,y). You put a non zero value as y if you expect (x) to be executed ,  and vice-verse.

[TO BE CONTINUED , I'm being busy now !]

很多时候,我们用Firefox或者Chrome浏览器,拷贝出来的ed2k下载链接,因为编码原因,都是如下形式:

ed2k://|file|%5B%E7%8C%AB%E5%B1%8E%E4%B8%80%E5%8F%B7%5D.%5BHYSUB%5D%5B

Cat_Shit_One_THE_ANIMATED_SERIES%5D%5BGB%5D%5BRV10%5D%5B848x480%5D.rmvb

|142742624|88e9dc57065ac50e37b403a80a6f697e|h=53jxtle4htt5qv32wshug63ajswif77v|/

这样在我们复制到aMule里面的时候呢,中文部分就变成了乱码,那么怎么解决呢?

  1. 可以使用Opera浏览器,emerge opera 就可以了;
  2. 我比较倾向于第二种,直接删除这些无聊的UNICODE.

怎么做呢?

  1. 首先复制所有链接,存储到文件里,这里用 /tmp/a
  2. 直接使用代码! sed -i -e ‘s/%[A-Z0-9]\{2\}//g’  -e ‘/^$/d’ /tmp/a

非常简单 !