Microsoft Visio save as EPS
February 8, 2008 2:04 pm | In Tech | 2 Comments | hideTo convert a Microsoft Visio document to EPS without losing scalable vector format (and without installing 3rd-party software…):
- Install Microsoft Save as PDF or XPS Add-in for 2007 Microsoft Office programs (only available for Office 2007?).
- Save Visio document as PDF in Visio 2007.
- Convert PDF to Postscript (.ps) with pdf2ps utility.
- Open .ps file with gsview, and select File -> PS to EPS, be sure to check “Automatically calculate Bounding Box”.
Now you have an EPS file to be embedded into your LaTeX document. Many other converting methods exist, see also Visio and EPS.
Convert WordPress database from Latin1 to UTF-8
January 12, 2008 5:39 pm | In Tech | 2 Comments | hideSome early WordPress databases use raw Latin1 encoding to represent UTF-8 characters. The following seems to be an O.K. way to convert those databases to native UTF-8 databases (at least it works for me, Mysql 5.0.45):
- Stop/restrict web service.
- Dump the database:
$ mysqldump --default-character-set=latin1 --databases wordpress > m.sql
- Change encoding settings in m.sql, including table default encoding and client communication encoding:
$ replace "CHARSET=latin1" "CHARSET=utf8" \ "SET NAMES latin1" "SET NAMES utf8" < m.sql > m2.sql - Import the “converted” sql:
$ mysql < m2.sql
- Add the following lines to WordPress wp-config.php
define('DB_CHARSET', 'utf8'); define('DB_COLLATE', ''); - Reopen web service. That’s it.
Note: For future convenience, you might as well change the database default encoding to utf8.
Windows XP 设置开机自动登录
September 16, 2007 4:03 pm | In Tech | 1 Comment | hide每次要用都忘,记一下:control userpasswords2
rsyncrypto: rsync + encryption
September 7, 2007 1:04 am | In Tech | No Comments | hidersyncrypto is basically rsync plus encryption. It’s not feature-complete I guess, but it works for me. Ubuntu source has binary package but compiling isn’t hard at all. Alright, so obviously man page has most of what you need, here I’ll write simple outlines.
Suppose your data source folder is ~/src, sync destination is ~/dst (this could be a mounted nfs or smb share), and rsyncrypto working directory is ~/rr.
A. Encryption
First of all, create backup keys:
openssl req -nodes -newkey rsa:1536 -x509 \ -keyout ~/rr/backup.key -out ~/rr/backup.crt
Then the actual sync command is:
rsyncrypto --ne-nesting=2 --trim=3 -n ~/rr/map \ -cvr ~/src/ ~/dst/ ~/rr/keys ~/rr/backup.crt
This command will encrypt filename and folder structure. So obviously folder modification time will not be preserved, and empty folder will be lost. Parameter --trim depends on your folder location. --ne-nesting depends on the number of files you will have in the future. In general, you may want less than 1024 files per folder, so you need 1024*16^n > total number of files, --ne-nesting=2 is enough for 200,000 files. After this encrypted sync, and suppose you lose everything except files in the ~/dst/, then you’ll need backup.key to cold decrypt all files. So be sure to keep backup.key at another place, preferably at another physical location. You can put the above command into crontab if -v is removed. Also, syncing files without ownership might result in errors, and it may be hard to debug because rsyncrypto does not have very friendly error messages - in which case you may try to fix the file permission problem, or you may run the command by root.
If you want a parameter similar to --delete in rsync, the corresponding parameter in rsyncrypto is --delete-keys. The parameter --delete alone in rsyncrypto does not remove filename mapping in ~/rr/map.
B. Decryption
Suppose you want to cold decrypt to folder ~/rec/. First you need to decrypt filename mapping:
rsyncrypto -d ~/dst/filemap ~/rec/filemap \ ~/rec/filemap-keys ~/rr/backup.key
The above command generates ~/rec/filemap, so then you can decrypt all files:
rsyncrypto --trim=3 -n ~/rec/filemap \ -vrd ~/dst ~/rec/files ~/rec/keys ~/rr/backup.key
C. Windows sharing time precision
When you sync to or from windows sharing, you need a parameter similar to --modify-window=2 in rsync, but unfortunately rsyncrypto doesn’t have it. You can change source code in file.cpp, search for st_mtime, and change
dststat.st_mtime!=status.st_mtime
to
abs(dststat.st_mtime-status.st_mtime)>2
There’s another similar line you need to change in the same file.
Tags: backup, encryption, howto, lang:en, rsync
TeraStation Pro II 使用手记
August 30, 2007 11:06 pm | In Tech | 1 Comment | hideEnglish Translation: A quick summary
- to get root privilege: compile acp_commander.java and run
java -jar acp_commander.jar -o -t TeraStation_ip
You may need to temporarily disable firewall on the machine that executes this command. You can then telnet in with empty root password, and set a password. Start sshd to have secure connection. Because it’s so easy to hack TeraStation, I think it can only be used in trustworthy local network.
- Every time you restart TeraStation, you have to use acp_commander to start sshd, but root password is preserved.
- To have special characters in the windows sharing password, just run passwd and smbpasswd under shell.
- TeraStation supports rsync but rsync is only intended to be used between TeraStations. You could change /etc/rsyncd.conf to configure rsyncd server. Also, you can setup crontab job to rsync from TeraStation main disk to a USB disk plugged into TeraStation. This is obviously the best local backup method.
小日本作了一堆 TeraStation 文件服务器(民间 wiki,民间论坛),卖得还不错。这玩意没什么特别的高科技成分,嵌入式 linux,加一堆软 raid。唯一比较赞的是机箱工艺比较好,体积也比较小。对于一般的应用,默认启动起来的 TeraStation 已经足够能用,但是没有 root 权限总是一件很不愉快的事情。下面简略记一下我对我们买的 TeraStation Pro II 的一些 hack。
默认的 TeraStation 对外只开了 web 管理界面和 smb 文件共享。但是它留了一个洞,可能是为了升级 firmware 方便。有人琢磨出来利用这个洞获得 root 权限,google acp_commander 就可以找到详细说明。acp_commander.java 源代码在 这里 备份一下。acp_commander 可以给 TeraStation 发送命令。执行
java -jar acp_commander.jar -o -t TeraStation_ip
清空 root 密码并启动 telnetd,然后 telnet 进去使用空密码登录 root 并设置密码。然后启动 sshd 就可以登录 ssh shell 了。一个要注意的问题是 acp_commander 需要接收 UDP 包,所以执行命令的这台机器需要临时关掉防火墙。
TeraStation 每次重启动会 reset 一些设置,所以需要重新用 acp_commander 来启动 sshd。注意 root 密码是不会被 reset 的,所以以后每次只要启动 sshd 即可,不需要清空 root 密码,也不需要再启动 telnetd 了。当然最彻底的方法是换掉 TeraStation 的 firmware,人民群众也已经创造了稳定的内核。不过我比较懒,所以还是用老的 firmware,反正我需要的功能都已经有了。另外,因为这个默认的 TeraStation fireware 这么容易被黑掉,所以建议只在可信赖的内网使用小日本的这个玩意儿。
TeraStation 的 web 界面相当的土鳖,不支持含有特殊字符的密码。大概看了一下貌似是因为 cgi 程序懒得处理这些特殊字符所以干脆禁止掉。当然,有了 shell 之后只要在 shell 下执行 passwd 和 smbpasswd 修改即可。ps 发现脚本到处都有日文注释,看来小日本写程序和有些中国人一样,也喜欢用母语注释。
TeraStation 本身支持 rsync 协议但是只是为了 TeraStation 之间备份用。有了 shell 之后可以修改 /etc/rsyncd.conf 来配置 rsync 服务器。当然也可以用 rsync over ssh,但是 TeraStation 的处理器不够强劲,高速解码 ssl 还是会影响一些性能。另外,从 raid 主盘往接在 TeraStation 上的 USB 盘备份可以在 crontab 设置 rsync,这应该是本地备份 TeraStation 最高效的方法。
Tags: backup, howto, lang:en, terastation
lftp+ssh-socks4 tunnel memo
January 31, 2007 1:40 am | In Tech | No Comments | hidedante-1.1.19:
./configure --with-socks-conf=/home/vv/dante-1.1.19/socks.conf
socks.conf:
route {
from: 0.0.0.0/0 to: 0.0.0.0/0 via:127.0.0.1 port = 4444
protocol: tcp # server supports tcp and udp.
proxyprotocol: socks_v4 # server supports socks v4 and v5.
method: none #username # we are willing to authenticate via
# method "none", not "username".
}
lftp-3.5.9:
./configure --with-socksdante=/home/vv/dante-1.1.19
establish ssh-socks4 tunnel:
$ ssh -N -D4444 vv@**** -p**
[vv@XX ~]$ lftp-3.5.9/src/lftp ftp://166.111.18.101/ cd ok, cwd=/ lftp 166.111.18.101:/> set ftp:fix-pasv-address no lftp 166.111.18.101:/> ls drwxrwxr-x 6 HAPPY HAPPY 416 Dec 30 16:59 incoming -rw-r–r– 1 HAPPY HAPPY 218031 Jan 31 06:08 ls-lR.gz drwxrwxr-x 5 HAPPY HAPPY 120 Nov 24 2005 pub -rw-r–r– 1 HAPPY HAPPY 107198 Jan 31 06:08 tree.txt
LaTeX quick start
January 12, 2007 10:00 pm | In Tech | No Comments | hideThere are many different ways to compile a LaTeX source file to a PDF. Following is one of the many ways to create a such LaTeX working environment on a completely new Windows box:
- Without saying, you need a PDF viewer, e.g. Adobe Reader.
- Install Ghostscript and GSview
- Install MiKTeX. A basic MiKTeX system is enough for most purpose.
- Install TeXnicCenter. This is an integrated LaTeX editor, by which you will compile your LaTeX source and view result using tools installed above.
- When you start TeXnicCenter:
- A configuration wizard may ask for a LaTeX distribution location, select where file latex.exe is. In my case, it’s “C:\Program Files\MiKTeX 2.6\miktex\bin”.
- Next, wizard may ask PDF viewer location, select your viewer. Mine is “C:\Program Files\Adobe\Reader 8.0\Reader\AcroRd32.exe”.
- Wizard will then create output profiles (compile/view commands) for DVI/PS/PDF.
- Compile your first LaTeX:
- Create a new file and save to a new directory.
- Type in a simple document, like:
\documentclass{article} \begin{document} \[ x_{1,2}=\frac{-b\pm\sqrt{b^2-4ac}}{2a}. \] I can do math! \end{document} - In the toolbar, select “LaTeX => PDF” output profile, and click “Build current file” right next to it.
- Click “View Output” in the same toolbar. You should have math in your PDF. Congratulation!
LaTeX: easy to start, hard to master…
yum upgrade fc5 to fc6 mini howto
October 29, 2006 3:30 am | In Tech | No Comments | hide发信人: atppp (Big Mouse), 信区: LinuxApp
标 题: yum upgrade fc5 to fc6 mini howto
发信站: 水木社区 (Sun Oct 29 18:06:42 2006), 站内
0. 默念自己是老鸟,什么困难都不怕。
1. 把 fc5 升级到最新,特别是 boot 进最新 kernel 2.6.18-1.2200.fc5
2. 找个快且全的 fc6 源
3. 下到 fedora-release-6-4.noarch.rpm fedora-release-notes-6-3.noarch.rpm
rpm -Uvh 上
4. /etc/yum.repos.d/ 里面捣鼓一下指定 rpm 源,
mirrorlist 判断出来的不一定最快最新
5. yum upgrade,解决 conflict
6. reboot into new kernel。如果起不来了,不要打我。。。
7. 自己编译安装的程序可能需要重新编译安装
8. 确认所有服务正常
9. 没了,我刚刚升完…
–
※ 来源:·水木社区 newsmth.net·[FROM: 128.12.150.*]
This weblog is licensed under a
Creative Commons License.
Powered by WordPress. Theme based on Pool by Borja Fernandez.