淡泊以明志,寜靜以致遠

Archive for 7月, 2011

a script for TeX Live and CJK in Archlinux

只是把教程中的操作转换成代码。我认为我第六步用的方法是最笨的。
问题: 怎么在关键词行末添加内容?$替换成 要添加的内容
这个问题在后面的文章中已经得到解决。sed替换指定多行关键词

#!/bin/bash
# to make sure that this script could run successfully, you should have super-rights
# 参考资料 https://wiki.archlinux.org/index.php/TeX_Live_and_CJK

## create working DIR
mkdir /tmp/$USER/fonts -pv
cd /tmp/$USER/fonts 

# the 9 steps

## step1  下载字体Cyberbit.ttf

wget http://http.netscape.com.edgesuite.net/pub/communicator/extras/fonts/windows/Cyberbit.ZIP
wget http://delloye.free.fr/Unicode.sfd
unzip Cyberbit.ZIP
mv Cyberbit.ttf  cyberbit.ttf -v
ttf2tfm cyberbit.ttf -w cyberbit@Unicode@ 1>/dev/null

## step2 复制生成的字体到指定目录 (使用超级权限)

sudo mkdir /usr/share/texmf-dist/fonts/{tfm,enc/pdftex}/cyberbit  -pv
sudo chmod 755 /usr/share/texmf-dist/fonts/{tfm,enc/pdftex}/cyberbit
sudo cp *.tfm /usr/share/texmf-dist/fonts/tfm/cyberbit/ 
sudo cp *.enc /usr/share/texmf-dist/fonts/enc/pdftex/cyberbit/ 
sudo chmod 644 /usr/share/texmf-dist/fonts/{tfm,enc/pdftex}/cyberbit/*

## step3 映像连接字体

wget http://delloye.free.fr/cyberbit.map
sudo mkdir /usr/share/texmf-config/pdftex/config -pv
sudo chmod -R 755 /usr/share/texmf-config/pdftex 

#    复制 .map 文件到目录

cp cyberbit.map /usr/share/texmf-config/pdftex/config/
chmod 644 /usr/share/texmf-config/pdftex/config/cyberbit.map -v 

## step4 下载c70cyberbit.fd

wget http://delloye.free.fr/c70cyberbit.fd

#        目录若不存在,则设立之
mkdir /usr/share/texmf-dist/tex/misc -pv
chmod 755 /usr/share/texmf-dist/tex/misc

#        复制文件到目录
cp c70cyberbit.fd /usr/share/texmf-dist/tex/misc/
chmod 644 /usr/share/texmf-dist/tex/misc/c70cyberbit.fd 

## step5 添加字体进TeX树
#    The font itself is still missing in the TeX-distribution tree:

cp cyberbit.ttf /usr/share/texmf-dist/fonts/truetype/
chmod 644 /usr/share/texmf-dist/fonts/truetype/cyberbit.ttf

## step6 编辑文件 /usr/share/texmf/web2c/texmf.cnf 
# 在行TTFONTS = .;$TEXMF/fonts/truetype//;$OSFONTDIR/TTF// 后添加 ;/usr/share/texmf-dist/fonts/truetype//

cp /usr/share/texmf/web2c/texmf.cnf{,.bak}
sed -e -i 's/TTFONTS\ =\ ..*$/TTFONTS\ =\ .;\$TEXMF\/fonts\/truetype\/\/;\$OSFONTDIR\/\/;\/usr\/share\/texmf-dist\/fonts\/truetype\/\//g' /usr/share/texmf/web2c/texmf.cnf

## step7 设定文件pdftex.cfg ,尽管我不确定是否必要

echo "map +cyberbit.map" >/usr/share/texmf-config/pdftex/config/pdftex.cfg

## step8 直到我们添加以下内容到/usr/share/texmf/fonts/map/ttf2pk/config/ttfonts.map, TeX才能处理CJK输入
#   有则取消注释,无则添加
echo "cyberb@Unicode@ cyberbit.ttf\n cyberbit@Unicode@ cyberbit.ttf" >>/usr/share/texmf/fonts/map/ttf2pk/config/ttfonts.map

## step9
#    To finish the configuration, run
texhash

echo "Hopefully this tutorial will spare you the hours of work I spent configuring CJK in TeX."

修改路由表以下载google.cn的音乐(挂上V.P.N的后果)

挂上V.P.N的上那些经过国家认证的网站很方便,但是想下载点音乐就比较让人困扰了。
上google.cn,就会出现以下内容

暂时没有对您所在的地区提供下载和试听服务
Music streaming/download services are not available in your region

参照google code上面的一个项目,添加了路由。
简单的就是获得google.cn网站所有ip(firefox点http前面那个东西>更多信息>媒体, 然后ping他们吧),然后修改路由
核心命令只有两条
添加

sudo route add -net $IP netmask 255.255.255.0 gw `ip route show | grep '^default' | sed -e 's/default via \([^ ]*\).*/\1/'`

删除

sudo route del -net $IP netmask 255.255.255.0 

注意: IP要修改成最后一位是0的,如74.125.127.0 否则会报错,添加/删除路由失败,原因不解释

写成shell代码脚本

#!/bin/bash
 #若 ip1=ip2,则会提出警告,不过不用管它。
 export PATH="/bin:/sbin:/usr/sbin:/usr/bin"
 OLDGW=`ip route show | grep '^default' | sed -e 's/default via \([^ ]*\).*/\1/'`
 # get google.cn music ip
 Web1="google.cn"
 Web2="lh5.googleusercontent.com" # 5可以换成3/4/6随便一个。
 ip1=$(ping ${Web1} -c 1| awk '{print $3}' | awk -F '(' '{print $2}' | awk -F ')' '{print $1}' | grep '^$' -v | sed -e 's/\.[0-9]*$/\.0/')
 ip2=$(ping ${Web2} -c 1| awk '{print $3}' | awk -F '(' '{print $2}' | awk -F ')' '{print $1}' | grep '^$' -v | sed -e 's/\.[0-9]*$/\.0/')
 echo "What do you want to do?(type 1 or 2)"
 select var in "add" "del";do
 break;
 done
 case $var in
 add)
 # add route
 sudo route add -net $ip1 netmask 255.255.255.0 gw $OLDGW
 sudo route add -net $ip2 netmask 255.255.255.0 gw $OLDGW
 ;;
 del)
 # del route
 sudo route del -net $ip1 netmask 255.255.255.0
 sudo route del -net $ip2 netmask 255.255.255.0
 ;;
 *)
 echo "bye"
 ;;
 esac

练习,练习,再练习。每天一到两小时,定会修成正果。

the ip of shell.cjb.net

because the well-known reason, most people in timezone gmt+8 can not get the true ip of shell.cjb.net.
the ip of it is 216.194.70.6.
add the line below to the hosts file
216.194.70.6 shell.cjb.net

gnome3的fallback mode 删除面板上的快速启动等项目

最近安装了gnome3和gnome-shell, 无奈硬件加速跑不起来, 用不了gnome-shell. 所以强制fallback mode. 结果我在面板上的项目遇到麻烦–无法删除那些一时冲动添加的快速启动项目.
经过探索,终于可以删除.方法如下:

打开dconf-editor
[bash]dconf-editor[/bash]

转到相应项目上
org=>gnome=>gnome-panel=>layout
//这是面板布局,删除项目也主要在这里, 删除面板都可以呢.

org=>gnome=>gnome-panel=>layout=>objects
//是布局里的一些项目的配置, 这里可以知道object和面板上的一些对应关系.object和面板上的快速启动图标, 从右到左有个对应关系.

好了, 要删就点object-id-list里对应的object,把它去了就行了.
例如
[‘menu-bar’, ‘clock’, ‘notification-area’, ‘user-menu’, ‘window-list’, ‘workspace-switcher’, ‘object-10’, ‘object-11’, ‘object-12’, ‘object-15’, ‘object-16’, ‘object-17’, ‘object-18’, ‘object-19’, ‘object-20’, ‘object-21’, ‘object-9’, ‘object-13’, ‘object-14’, ‘object-22’]

要删除 ‘object-22’ 把”, ‘object-22’“去掉,并回车.

阅读了一些相关资料,原来在fallback mode里对panel里的项目像以前的版本那样操作,都要按住Alt键。如Alt+右键面板,就会出现面板的一些相关操作。
gnome3的fallback mode被骂得惨了。why-gnome-3s-fallback-mode-sucks/
以下为引用

This “We are not designing a desktop for people who …” has become a new meme. GNOME 3 is not designed for people

who want to minimize windows
who want to change the theme, icons or fonts
who want to configure power management actions
who want to use panel applets/extensions that can easily be added or removed
who want to select their native language on the login screen instead of having to re-login after they have changed it in the control center
who want to use their keyboard layout so they can actually log in
who want to shutdown their computers from within a GNOME session

GNOME developer quote of the day
PS:mark一下gnome-shell的一些技巧

关于翻译

linux下的终端模拟机可谓无数,gnome-terminal konsle xterm xfce-terminal sakura urxvt roxterm……我都用过。唯独最喜欢roxterm,可惜roxterm有没中文界面,只好自己动手。
开始的时候,我总是认为翻译会比较难。经过几小时的摸索,我慢慢地学习了怎么翻译。事实上,在之前我就有安装过i18l的软件了,迟迟不肯动手,直到翻译roxterm.
term比较常见,遇到的那些术语不会太难,基本都懂。最大的问题似乎是:英文意思,一看就懂在脑海里,但是要转成比较流畅的中文还存在难度。也许太久不搞翻译了,水平都直线下降了。
好吧,最后附上roxterm.mo roxterm的大部分界面都翻译成中文了,剩下部分说明就先放着。
使用方法:
[bash]
tar xvf roxterm.mo.zh-CN.tar.gz
mv zh-CN.mo /usr/share/locale/zh_CN/LC_MESSAGES/roxterm.mo[/bash]

roxterm.mo_.zh-CN.tar.gz