Felix Yan | 2010-09-02 | 92 views
恩,在开头先提醒各位小白鼠: ppa:network-manager/ppa 和 ppa:xorg-edgers/ppa 是两门毒药, 慎装!!
(因为它们的杯具, Felix 重装系统了 =.=||)
这段时间小纠结了一下路由表/服务器方面的问题, 下面是一部分最近的笔记
照例先给个目录:
1, Ubuntu 10.04 Server 短按电源键热关机:
2, Xorg版本过新导致nvidia驱动不加载的workaround
3, HUST/Tsinghua/SJTU的 6in4 tunnel 开启方法
4, 三种HUST能使用的Linux下的锐捷认证工具(mystar/xrgsu/mentohust)
5, 更通用的路由表脚本
1, Ubuntu 10.04 Server 短按电源键热关机:
Ubuntu 10.04 Server 默认没有安装acpid, 先装上:
1
| sudo apt-get install acpid |
然后编辑 /etc/acpi/events/powerbtn:
1
| sudo vi /etc/acpi/events/powerbtn |
找到下面这行:
1
| action=/etc/acpi/powerbtn.sh |
修改为:
然后重启,就大功告成啦:)
参考: http://linux.chinaunix.net/bbs/thread-1113446-1-1.html
阅读全文(Read the rest of this entry »)
Felix Yan | 2010-08-21 | 805 views
距离上次开放申请已经过去很久啦! 在经过调试和一系列监控后, 服务器运行已经十分稳定, 因此 Felix 决定再次开放申请!
要求:
1,已经申请过牧师VPN的推友不要重复申请
2,请在留言处”Name”填写正确的Twitter ID,并在此页面申请成功之后在Twitter上面@我(felixonmars),不一定要follow我,我看到@之后才会开通VPN帐号
3,为了确保一人一号,我会根据我自己的经验来判断申请人Twitter帐号是否马甲或小号,所以请千万别临时开个小号来重复申请^_^
4,请填写正确的Email地址
5,申请有些繁琐,但这样做是为了方便统计,望谅解
6,审核通过后(通常2天内),我会把服务器和帐号发送到邮箱
7,尽量不要长时间观看Youtube,严禁P2P下载!
8,申请时请注明申请的VPN种类, 当前可以申请的有: OpenVPN(UDP)(推荐) / OpenVPN(TCP)(新增!) / OpenVPN(IPv6)(新增!) / L2TP / PPTP
9,想要自定义密码可以在Twitter上让我fo你,然后DM过来
10,详情请看 http://www.mytuitui.com/archives/vpn-dangma.html (墙外)
第二批还是只有50个 数量有限 先到先得!
最后 感谢牧师 @newsinchina 和 VPN计划 提供资金支持
就是这样, 喵!
阅读全文(Read the rest of this entry »)
Felix Yan | 2010-08-13 | 183 views
首先, 感谢 @BOYPT @jimmy_xu_wrk @tjmao @yegle 等朋友的帮忙!
1, 多网环境, Felix 的环境是 VPN over cernet2 + cernet 双网.
2, 自动路由表, 采用 www.nic.edu.cn 的官方 Free IP 数据.
以下是 Felix 用 Python 写的一个小小的自动生成脚本:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
| import re
import urllib
a=urllib.urlopen('http://www.nic.edu.cn/RS/ipstat/internalip/real.html').read()
b=re.compile("([\d\.]+)\s+[\d\.]+\s+([\d\.]+)")
c=b.findall(a)
m=["#!/bin/bash","OLDGW=$1","NEWGW=$2","route del -net 0.0.0.0 netmask 0.0.0.0","route add -net 0.0.0.0 netmask 0.0.0.0 gw $NEWGW"]
n=["#!/bin/bash"]
for d in c:
m.append("route add -net "+d[0]+" netmask "+d[1]+" gw $OLDGW")
n.append("route del -net "+d[0]+" netmask "+d[1])
e=open('gtwcernet',"w")
e.write("\n".join(m))
e.close()
f=open('gtwcernetd',"w")
f.write("\n".join(n))
f.close() |
会在当前目录生成 gtwcernet 和 gtwcernetd 两个文件
然后给他们加上执行权限
1
2
| chmod +x gtwcernet
chmod +x gtwcernetd |
前一个是启用自动路由表
Usage: gtwcernet <教育网网关> <VPN/电信网网关>
后一个是禁用自动路由表
Usage: gtwcernetd
阅读全文(Read the rest of this entry »)
Felix Yan | 2010-08-06 | 169 views
源脚本来自 http://forums.dropbox.com/topic.php?id=12153, 但是不能支持代理服务器, 主要问题是它的”联网检测”用的是ping, Felix将其改成了wget然后判断页面上是否有forums
Patch 如下:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
| --- a/dbupdate
+++ b/dbupdate
@@ -37,7 +37,7 @@
declare -r useCount="http://bit.ly/dbupdate_count";
declare -r nIcon="/usr/share/icons/hicolor/64x64/apps/dropbox.png";
declare -r userAgent="Mozilla/5.0 (X11; U; Linux i686; $LANG; rv:1.9.1.3) Gecko/20090924 Ubuntu/9.10 (karmic) Firefox/3.5.3";
-declare -r internetTest="ping -c3 -w10 www.dropbox.com | grep -c '64 bytes'" ;
+declare -r internetTest="wget -qO - http://www.dropbox.com | grep -c 'forums'" ;
bit="auto";
testing=0;
q="-q";
@@ -292,7 +292,7 @@
#test connectivity
printf "Checking for connectivity to Dropbox servers...";
-if [ `eval $internetTest` -lt 3 ]; then {
+if [ `eval $internetTest` -lt 1 ]; then {
echo " FAIL.";
echo "Failed to connect to \"www.dropbox.com\"";
exit 1; |
阅读全文(Read the rest of this entry »)
Felix Yan | 2010-07-21 | 165 views
由于 XMind (脑图软件) 使用一种类似 OpenOffice.org 的文件格式, 我调整了那些脚本, 让它们也能为我的 XMind 脑图文件创建缩略图. 由于 XMind 文件尚无 mime 类型定义, 我们还需要花一些额外的功夫来解决这一问题.
1, 为 XMind 文件设置一个 mime 类型定义.
默认情况下, XMind 文件被识别为可执行/压缩文件(application/zip), 因此我们需要为 XMind 文件指定 mime 类型:
1
| sudo gedit /usr/share/mime/packages/x-xmind.xml |
我仅仅把一些东西简单的放在了一起, 让系统把 “.xmind” 为扩展名的文件认为 mime 类型 应用程序/x-xmind(application/x-xmind)
1
2
3
4
5
6
| < ?xml version="1.0" encoding="UTF-8"?>
<mime -info xmlns="http://www.freedesktop.org/standards/shared-mime-info">
</mime><mime -type type="application/x-xmind">
<comment>XMind mindmap</comment>
<glob pattern="*.xmind"/>
</mime> |
保存这个文件之后, 更新 mime 类型的数据库:
1
| sudo update-mime-database /usr/share/mime |
阅读全文(Read the rest of this entry »)
Felix Yan | 2010-07-17 | 141 views
随手写的小程序 很小很实用, 尤其是在压片的时候计算sar值等方面.
第一个: 化简分数
1
2
| 样例输入1: 16/12
样例输出1: 4 : 3 |
1
2
| 样例输入2: 16*480/(9*704)
样例输出2: 40 : 33 |
恩, 简单说来, 就是化任意分数为最简分数
第二个: 小数化分数
给一个范围,用范围内的数组成分数,并使这个分数的值最接近所给的小数(如样例给的是1-100和1-1000的范围)
1
2
| 样例输入1: 3.1415926535897 100
样例输出1: 22 : 7 |
1
2
| 样例输入2: 3.1415926535897 1000
样例输出2: 355 : 113 |
阅读全文(Read the rest of this entry »)
Felix Yan | 2010-07-16 | 78 views
我一直在用 VB6 写的各种需要正则的小程序里引入这个模块, 很简洁很好用:)
使用之前当然需要在 工程 -> 引用 里勾选 Microsoft VBScript Regular Expression 5.5
具体用法嘛…
1, StrReplace(正则替换):
1
| MsgBox StrReplace("1d2e3f","\d","a") |
将会输出
adaeaf
2, StrMatch(正则查找):
1
2
3
4
5
6
7
| Dim mhs As MatchCollection
Set mhs = StrMatch("1d2e3f","\d")
If mhs.Count > 0 Then
For i = 1 To mhs.Count
MsgBox mhs(i).Value
Next i
End If |
具体效果嘛…能猜到了吧? 猜不到的自己试试去… 其他用法请参见MSDN
下面附上模块源码:
阅读全文(Read the rest of this entry »)
Felix Yan | 2010-07-16 | 106 views
基本功能: 双语字幕中英文分离, 各自成一行
避免srtedit在合并某些字幕后中英文各占不止一行, 导致最终生成的字幕占4行的尴尬情况.
基本示例:
源文件:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
| 1
00:01:06,107 --> 00:01:07,483
This is a test
这是一个测试
2
00:01:12,906 --> 00:01:16,450
测试!
快测试呀
3
00:01:18,703 --> 00:01:19,953
测试好了没有?
我问你好了没有?
Is the test OK?
What's the result? |
处理后:
1
2
3
4
5
6
7
8
9
10
11
12
13
| 1
00:01:06,107 --> 00:01:07,483
这是一个测试
This is a test
2
00:01:12,906 --> 00:01:16,450
测试! 快测试呀
3
00:01:18,703 --> 00:01:19,953
测试好了没有? 我问你好了没有?
Is the test OK? What's the result? |
基本功能完好,细节有些小毛病…
阅读全文(Read the rest of this entry »)
Felix Yan | 2010-07-16 | 187 views
恩,作为笔记系列的文章,内容会比较混乱.
这段时间以来,作为Ubuntu双十版的小白鼠,虽然挂彩数次,不过也在 @yegle @tjmao @poplarch @BOYPT @liangsuilong @jimmy_xu_wrk 等等推友的帮助下搞定重生.
以下是这段时间来发现的好东西:
1, @tualatrix 大大的notify脚本(Felix降碳版)
1
2
3
4
5
6
7
8
| #!/bin/bash
# Copyright: TualatriX GPL v3
# Website: http://imtx.cn/archives/1516.html
# Please add the following line to ~/.bashrc to enable the bash completion support
# complete -o filenames -F _root_command notify
$* && \
notify-send "\"$*\" finished successfully" || \
notify-send "\"$*\" failed" |
并在 ~/.bashrc 里加入:
1
| complete -o filenames -F _root_command notify |
以适应bash的自动完成功能. 原文在此
这玩意着实好用, 不过本猫发现10.04及以上版本会出现找不到notify-send命令,这时只需要
1
| # apt-get install libnotify-bin |
就好.
阅读全文(Read the rest of this entry »)
Felix Yan | 2010-07-15 | 638 views
要求:
1,已经申请过牧师VPN的推友不要重复申请
2,请在留言处”Name”填写正确的Twitter ID,并在此页面申请成功之后在Twitter上面@我(felixonmars),不一定要follow我,我看到@之后才会开通VPN帐号
3,为了确保一人一号,我会根据我自己的经验来判断申请人Twitter帐号是否马甲或小号,所以请千万别临时开个小号来重复申请^_^
4,请填写正确的Email地址
5,申请有些繁琐,但这样做是为了方便统计,望谅解
6,审核通过后(通常2天内),我会把服务器和帐号发送到邮箱
7,尽量不要长期观看Youtube,严禁P2P下载!
8,申请时请注明申请的VPN种类, 当前可以申请的有: OpenVPN(推荐) / L2TP / PPTP
9,想要自定义密码可以在Twitter上让我fo你,然后DM过来
10,详情请看 http://www.mytuitui.com/archives/vpn-dangma.html (墙外)
第一批只有50个 数量有限 先到先得!
最后 感谢牧师 @newsinchina 和 VPN计划 提供资金支持
就是这样, 喵!
范例:
felixonmars (Name)
felixonmars@xxx.com (Email)
OpenVPN
第一批活动已经结束! 感谢大家的参与!