Felix Yan | 2010-07-21 | 505 views
由于 XMind (脑图软件) 使用一种类似 OpenOffice.org 的文件格式, 我调整了那些脚本, 让它们也能为我的 XMind 脑图文件创建缩略图. 由于 XMind 文件尚无 mime 类型定义, 我们还需要花一些额外的功夫来解决这一问题.
1, 为 XMind 文件设置一个 mime 类型定义.
默认情况下, XMind 文件被识别为可执行/压缩文件(application/zip), 因此我们需要为 XMind 文件指定 mime 类型:
sudo gedit /usr/share/mime/packages/x-xmind.xml
我仅仅把一些东西简单的放在了一起, 让系统把 “.xmind” 为扩展名的文件认为 mime 类型 应用程序/x-xmind(application/x-xmind)
< ?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 类型的数据库:
sudo update-mime-database /usr/share/mime
Read the rest of this entry »
Felix Yan | 2010-07-17 | 262 views
随手写的小程序 很小很实用, 尤其是在压片的时候计算sar值等方面.
第一个: 化简分数
样例输入1: 16/12
样例输出1: 4 : 3
样例输入2: 16*480/(9*704)
样例输出2: 40 : 33
恩, 简单说来, 就是化任意分数为最简分数
第二个: 小数化分数
给一个范围,用范围内的数组成分数,并使这个分数的值最接近所给的小数(如样例给的是1-100和1-1000的范围)
样例输入1: 3.1415926535897 100
样例输出1: 22 : 7
样例输入2: 3.1415926535897 1000
样例输出2: 355 : 113
Read the rest of this entry »
Felix Yan | 2010-07-16 | 207 views
我一直在用 VB6 写的各种需要正则的小程序里引入这个模块, 很简洁很好用:)
使用之前当然需要在 工程 -> 引用 里勾选 Microsoft VBScript Regular Expression 5.5
具体用法嘛…
1, StrReplace(正则替换):
MsgBox StrReplace("1d2e3f","\d","a")
将会输出
adaeaf
2, StrMatch(正则查找):
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 | 325 views
基本功能: 双语字幕中英文分离, 各自成一行
避免srtedit在合并某些字幕后中英文各占不止一行, 导致最终生成的字幕占4行的尴尬情况.
基本示例:
源文件:
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
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 | 322 views
恩,作为笔记系列的文章,内容会比较混乱.
这段时间以来,作为Ubuntu双十版的小白鼠,虽然挂彩数次,不过也在 @yegle @tjmao @poplarch @BOYPT @liangsuilong @jimmy_xu_wrk 等等推友的帮助下搞定重生.
以下是这段时间来发现的好东西:
1, @tualatrix 大大的notify脚本(Felix降碳版)
#!/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 里加入:
complete -o filenames -F _root_command notify
以适应bash的自动完成功能. 原文在此
这玩意着实好用, 不过本猫发现10.04及以上版本会出现找不到notify-send命令,这时只需要
# apt-get install libnotify-bin
就好.
Read the rest of this entry »
Felix Yan | 2010-07-06 | 593 views
虽然我有付费的SSH Tunnel服务用,不过昨天围观到freessh.us改成了每15分钟换一次密码,新密码在其首页上发布,还是猥琐了一把,写了个简单的自动链接脚本:
import urllib,re,os
while True:
a=urllib.urlopen('http://www.freessh.us').read()
a=a.replace('\n','').replace('\r','')
b=re.compile('\>(\w{1,3}\.freessh\.us)\<\/td\>.+?(\w{4,7})\<\/td\>.+?\>(\w{3,7})\<\/td')
for i in b.findall(a):
os.system('plink '+i[0]+' -N -ssh -2 -P 22 -l '+i[1]+' -C -D 7070 -v -pw \"'+i[2]+'\"')
不想围观脚本可以用力点这里下载.
Linux/Windows都可以使用,其他系统没试过.
Linux使用要安装plink:
# apt-get install putty-tools
# yum install putty-tools
Windows使用要安装Python 2.6+并把plink.exe放到同一目录. plink的下载方式参见我的另一篇文章:Plink+Polipo 轻松打造IE可用的SSH Tunnel(Win)
另外BOYPT神牛的博客提供了一种expect+shell脚本的方式达到近似的效果,传送门: http://apt-blog.net/across-the-great-wall-we-can-reach-every-corner-in-the-world