<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>atppp&#039;s Blog &#187; howto</title>
	<atom:link href="http://blog.wuxinan.net/archives/tag/howto/feed" rel="self" type="application/rss+xml" />
	<link>http://blog.wuxinan.net</link>
	<description></description>
	<lastBuildDate>Tue, 08 Dec 2009 08:20:42 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.4</generator>
		<item>
		<title>Microsoft Visio save as EPS</title>
		<link>http://blog.wuxinan.net/archives/282</link>
		<comments>http://blog.wuxinan.net/archives/282#comments</comments>
		<pubDate>Fri, 08 Feb 2008 22:04:29 +0000</pubDate>
		<dc:creator>atppp</dc:creator>
				<category><![CDATA[Tech]]></category>
		<category><![CDATA[eps]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[lang:en]]></category>
		<category><![CDATA[latex]]></category>
		<category><![CDATA[visio]]></category>

		<guid isPermaLink="false">http://blog.wuxinan.net/archives/282</guid>
		<description><![CDATA[I wrote the following procedure on 2008.02.08: To convert a Microsoft Visio document to EPS without losing scalable vector format (and without installing 3rd-party software&#8230;): 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 [...]]]></description>
			<content:encoded><![CDATA[<p>I wrote the following procedure on 2008.02.08:</p>
<blockquote><p>To convert a Microsoft Visio document to EPS without losing scalable vector format (and without installing 3rd-party software&#8230;):</p>
<ol>
<li>Install <a href="http://r.office.microsoft.com/r/rlidMSAddinPDFXPS">Microsoft Save as PDF or XPS Add-in for 2007 Microsoft Office programs</a> (only available for Office 2007?).</li>
<li>Save Visio document as PDF in Visio 2007.</li>
<li>Convert PDF to Postscript (.ps) with pdf2ps utility.</li>
<li>Open .ps file with gsview, and select File -&gt; PS to EPS, be sure to check &#8220;Automatically calculate Bounding Box&#8221;.</li>
</ol>
<p>Now you have an EPS file to be embedded into your LaTeX document. Many other converting methods exist, see also <a href="http://www.itee.uq.edu.au/~emmerik/visioeps.html">Visio and EPS</a>.</p></blockquote>
<p>Here are some updates (edited on 2009.01.30):</p>
<ol>
<li>In theory, you should be able to open that saved PDF directly in gsview and convert to EPS, but gsview either crashes or refuses to accept the PDF.</li>
<li>In some cases, e.g. when you compile LaTeX directly to PDF using pdflatex, you just need a PDF figure with correct size. In that case, you can set the document size in Visio: File -&gt; Page Setup -&gt; Page Size (tab) -&gt; Size to fit drawing contents, and then save the Visio document to PDF, which will then be in correct size ready to be embedded into LaTeX.</li>
<li>To create a Postscript file, you don&#8217;t necessarily need to save as PDF and convert to .ps using pdf2ps. All you need to do is to use a postscript printer (most modern printers are, including most PDF writers) and print to file. That would create a postscript file which can then be passed to gsview and converted to EPS by adding a bounding box. Note: this is in fact a generic way of converting anything to (vector-format) EPS/PDF with bounding box.</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://blog.wuxinan.net/archives/282/feed</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Convert WordPress database from Latin1 to UTF-8</title>
		<link>http://blog.wuxinan.net/archives/255</link>
		<comments>http://blog.wuxinan.net/archives/255#comments</comments>
		<pubDate>Sun, 13 Jan 2008 01:39:31 +0000</pubDate>
		<dc:creator>atppp</dc:creator>
				<category><![CDATA[Tech]]></category>
		<category><![CDATA[encoding]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[lang:en]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://blog.wuxinan.net/archives/255</guid>
		<description><![CDATA[Some 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 &#62; m.sql Change encoding settings in m.sql, including [...]]]></description>
			<content:encoded><![CDATA[<p>Some 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):</p>
<ol>
<li>Stop/restrict web service.</li>
<li>Dump the database:
<pre>$ mysqldump --default-character-set=latin1 --databases wordpress &gt; m.sql</pre>
</li>
<li>Change encoding settings in m.sql, including table default encoding and client communication encoding:
<pre>$ replace "CHARSET=latin1" "CHARSET=utf8" \
    "SET NAMES latin1" "SET NAMES utf8" &lt; m.sql &gt; m2.sql</pre>
</li>
<li>Import the &#8220;converted&#8221; sql:
<pre>$ mysql &lt; m2.sql</pre>
</li>
<li>Add the following lines to WordPress wp-config.php
<pre>define('DB_CHARSET', 'utf8');
define('DB_COLLATE', '');</pre>
</li>
<li>Reopen web service. That&#8217;s it.</li>
</ol>
<p>Note: For future convenience, you might as well change the database default encoding to utf8.</p>
<p>Ref to WordPress documentation for details: <a href="http://codex.wordpress.org/Editing_wp-config.php#Database_character_set">here</a> and <a href="http://codex.wordpress.org/Converting_Database_Character_Sets">here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.wuxinan.net/archives/255/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Windows XP 设置开机自动登录</title>
		<link>http://blog.wuxinan.net/archives/95</link>
		<comments>http://blog.wuxinan.net/archives/95#comments</comments>
		<pubDate>Sun, 16 Sep 2007 23:03:18 +0000</pubDate>
		<dc:creator>atppp</dc:creator>
				<category><![CDATA[Tech]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[windows]]></category>

		<guid isPermaLink="false">http://blog.wuxinan.net/?p=95</guid>
		<description><![CDATA[每次要用都忘，记一下：control userpasswords2]]></description>
			<content:encoded><![CDATA[<p>每次要用都忘，记一下：control userpasswords2</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.wuxinan.net/archives/95/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>rsyncrypto: rsync + encryption</title>
		<link>http://blog.wuxinan.net/archives/86</link>
		<comments>http://blog.wuxinan.net/archives/86#comments</comments>
		<pubDate>Fri, 07 Sep 2007 08:04:55 +0000</pubDate>
		<dc:creator>atppp</dc:creator>
				<category><![CDATA[Tech]]></category>
		<category><![CDATA[backup]]></category>
		<category><![CDATA[encryption]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[lang:en]]></category>
		<category><![CDATA[rsync]]></category>

		<guid isPermaLink="false">http://blog.wuxinan.net/?p=86</guid>
		<description><![CDATA[rsyncrypto is basically rsync plus encryption. It&#8217;s not feature-complete I guess, but it works for me. Ubuntu source has binary package but compiling isn&#8217;t hard at all. Alright, so obviously man page has most of what you need, here I&#8217;ll write simple outlines. Suppose your data source folder is ~/src, sync destination is ~/dst (this [...]]]></description>
			<content:encoded><![CDATA[<p>rsyncrypto is basically rsync plus encryption. It&#8217;s not feature-complete I guess, but it works for me. Ubuntu source has binary package but compiling isn&#8217;t hard at all. Alright, so obviously man page has most of what you need, here I&#8217;ll write simple outlines.</p>
<p>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.</p>
<p><span style="text-decoration: underline;">A. Encryption</span></p>
<p>First of all, create backup keys:</p>
<pre>openssl req -nodes -newkey rsa:1536 -x509 \
  -keyout ~/rr/backup.key -out ~/rr/backup.crt</pre>
<p>Then the actual sync command is:</p>
<pre>rsyncrypto --ne-nesting=2 --trim=3 -n ~/rr/map \
  -cvr ~/src/ ~/dst/ ~/rr/keys ~/rr/backup.crt</pre>
<p>This command will encrypt filename and folder structure. So obviously folder modification time will not be preserved, and empty folder will be lost. Parameter <code>--trim</code> depends on your folder location. <code>--ne-nesting</code> 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  &gt; total number of files, <code>--ne-nesting=2</code> is enough for 200,000 files. After this encrypted sync, and suppose you lose everything except files in the ~/dst/, then you&#8217;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 <code>-v</code> 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 &#8211; in which case you may try to fix the file permission problem, or you may run the command by root.</p>
<p>If you want a parameter similar to <code>--delete</code> in rsync, the corresponding parameter in rsyncrypto is <code>--delete-keys</code>. The parameter <code>--delete</code> alone in rsyncrypto does not remove filename mapping in ~/rr/map.</p>
<p><span style="text-decoration: underline;">B. Decryption</span></p>
<p>Suppose you want to cold decrypt to folder ~/rec/. First you need to decrypt filename mapping:</p>
<pre>rsyncrypto -d ~/dst/filemap ~/rec/filemap \
  ~/rec/filemap-keys ~/rr/backup.key</pre>
<p>The above command generates ~/rec/filemap, so then you can decrypt all files:</p>
<pre>rsyncrypto --trim=3 -n ~/rec/filemap \
  -vrd ~/dst ~/rec/files ~/rec/keys ~/rr/backup.key</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.wuxinan.net/archives/86/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>TeraStation Pro II 使用手记</title>
		<link>http://blog.wuxinan.net/archives/74</link>
		<comments>http://blog.wuxinan.net/archives/74#comments</comments>
		<pubDate>Fri, 31 Aug 2007 06:06:22 +0000</pubDate>
		<dc:creator>atppp</dc:creator>
				<category><![CDATA[Tech]]></category>
		<category><![CDATA[backup]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[lang:en]]></category>
		<category><![CDATA[terastation]]></category>

		<guid isPermaLink="false">http://blog.wuxinan.net/?p=74</guid>
		<description><![CDATA[English Translation: A quick summary to get root privilege: compile acp_commander.java and run java acp_commander -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&#8217;s so easy [...]]]></description>
			<content:encoded><![CDATA[<p>English Translation: A quick summary</p>
<ul>
<li>to get root privilege:  compile <a title="acp_commander.txt" href="http://blog.wuxinan.net/wp-content/uploads/2007/08/acp_commander.txt">acp_commander.java</a> and run
<pre>java acp_commander -o -t TeraStation_ip</pre>
<p>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&#8217;s so easy to hack TeraStation, I think it can only be used in trustworthy local network.</li>
<li>Every time you restart TeraStation, you have to use acp_commander to start sshd, but root password is preserved.
<pre>java acp_commander -c 'sshd' -t TeraStation_ip</pre>
</li>
<li>To have special characters in the windows sharing password, just run passwd and smbpasswd under shell.</li>
<li>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.</li>
</ul>
<p>小日本作了一堆 <a href="http://www.buffalotech.com/products/network-storage/terastation/">TeraStation</a> 文件服务器（<a href="http://www.linkstationwiki.net/">民间 wiki</a>，<a href="http://forum.linkstationwiki.net/">民间论坛</a>），卖得还不错。这玩意没什么特别的高科技成分，嵌入式 linux，加一堆软 raid。唯一比较赞的是机箱工艺比较好，体积也比较小。对于一般的应用，默认启动起来的 TeraStation 已经足够能用，但是没有 root 权限总是一件很不愉快的事情。下面简略记一下我对我们买的 TeraStation Pro II 的一些 hack。</p>
<p>默认的 TeraStation 对外只开了 web 管理界面和 smb 文件共享。但是它留了一个洞，可能是为了升级 firmware 方便。有人琢磨出来利用这个洞获得 root 权限，google acp_commander 就可以找到详细说明。acp_commander.java 源代码在 <a title="acp_commander.txt" href="http://blog.wuxinan.net/wp-content/uploads/2007/08/acp_commander.txt">这里</a> 备份一下。acp_commander 可以给 TeraStation 发送命令。执行</p>
<pre>java acp_commander -o -t TeraStation_ip</pre>
<p>清空 root 密码并启动 telnetd，然后 telnet 进去使用空密码登录 root 并设置密码。然后启动 sshd 就可以登录 ssh shell 了。一个要注意的问题是 acp_commander 需要接收 UDP 包，所以执行命令的这台机器需要临时关掉防火墙。</p>
<p>TeraStation 每次重启动会 reset 一些设置，所以需要重新用 acp_commander 来启动 sshd。注意 root 密码是不会被 reset 的，所以以后每次只要启动 sshd 即可，不需要清空 root 密码，也不需要再启动 telnetd 了。</p>
<pre>java acp_commander -c 'sshd' -t TeraStation_ip</pre>
<p>当然最彻底的方法是换掉 TeraStation 的 firmware，人民群众也已经创造了稳定的内核。不过我比较懒，所以还是用老的 firmware，反正我需要的功能都已经有了。另外，因为这个默认的 TeraStation fireware 这么容易被黑掉，所以建议只在可信赖的内网使用小日本的这个玩意儿。</p>
<p>TeraStation 的 web 界面相当的土鳖，不支持含有特殊字符的密码。大概看了一下貌似是因为 cgi 程序懒得处理这些特殊字符所以干脆禁止掉。当然，有了 shell 之后只要在 shell 下执行 passwd 和 smbpasswd 修改即可。ps 发现脚本到处都有日文注释，看来小日本写程序和有些中国人一样，也喜欢用母语注释。</p>
<p>TeraStation 本身支持 rsync 协议但是只是为了 TeraStation 之间备份用。有了 shell 之后可以修改 /etc/rsyncd.conf 来配置 rsync 服务器。当然也可以用 rsync over ssh，但是 TeraStation 的处理器不够强劲，高速解码 ssl 还是会影响一些性能。另外，从 raid 主盘往接在 TeraStation 上的 USB 盘备份可以在 crontab 设置 rsync，这应该是本地备份 TeraStation 最高效的方法。</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.wuxinan.net/archives/74/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>lftp+ssh-socks4 tunnel memo</title>
		<link>http://blog.wuxinan.net/archives/18</link>
		<comments>http://blog.wuxinan.net/archives/18#comments</comments>
		<pubDate>Wed, 31 Jan 2007 08:40:43 +0000</pubDate>
		<dc:creator>atppp</dc:creator>
				<category><![CDATA[Tech]]></category>
		<category><![CDATA[ftp]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[lang:en]]></category>
		<category><![CDATA[network]]></category>
		<category><![CDATA[socks]]></category>
		<category><![CDATA[ssh]]></category>
		<category><![CDATA[tunnel]]></category>

		<guid isPermaLink="false">http://blog.wuxinan.net/?p=18</guid>
		<description><![CDATA[dante-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 [...]]]></description>
			<content:encoded><![CDATA[<p> dante-1.1.19:</p>
<pre>./configure --with-socks-conf=/home/vv/dante-1.1.19/socks.conf</pre>
<p>socks.conf:</p>
<pre>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".
}</pre>
<p>lftp-3.5.9:</p>
<pre>./configure --with-socksdante=/home/vv/dante-1.1.19</pre>
<p>establish ssh-socks4 tunnel:</p>
<pre>$ ssh -N -D4444 vv@**** -p**</pre>
<pre>[vv@XX ~]$ lftp-3.5.9/src/lftp ftp://166.111.18.101/
cd ok, cwd=/
lftp 166.111.18.101:/&gt; set ftp:fix-pasv-address no
lftp 166.111.18.101:/&gt; 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</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.wuxinan.net/archives/18/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>LaTeX quick start</title>
		<link>http://blog.wuxinan.net/archives/271</link>
		<comments>http://blog.wuxinan.net/archives/271#comments</comments>
		<pubDate>Sat, 13 Jan 2007 06:00:34 +0000</pubDate>
		<dc:creator>atppp</dc:creator>
				<category><![CDATA[Tech]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[lang:en]]></category>
		<category><![CDATA[latex]]></category>

		<guid isPermaLink="false">http://blog.wuxinan.net/archives/271</guid>
		<description><![CDATA[There 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 [...]]]></description>
			<content:encoded><![CDATA[<p>There 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:</p>
<ol>
<li>Without saying, you need a PDF viewer, e.g. Adobe Reader.</li>
<li>Install <a href="http://pages.cs.wisc.edu/~ghost/">Ghostscript and GSview</a></li>
<li>Install <a href="http://miktex.org/">MiKTeX</a>. A basic MiKTeX system is enough for most purpose.</li>
<li>Install <a href="http://www.toolscenter.org/">TeXnicCenter</a>. This is an integrated LaTeX editor, by which you will compile your LaTeX source and view result using tools installed above.</li>
<li>When you start TeXnicCenter:
<ol>
<li>A configuration wizard may ask for a LaTeX distribution location, select where file latex.exe is. In my case, it&#8217;s &#8220;C:\Program Files\MiKTeX 2.6\miktex\bin&#8221;.</li>
<li>Next, wizard may ask PDF viewer location, select your viewer. Mine is &#8220;C:\Program Files\Adobe\Reader 8.0\Reader\AcroRd32.exe&#8221;.</li>
<li>Wizard will then create output profiles (compile/view commands) for DVI/PS/PDF.</li>
</ol>
</li>
<li>Compile your first LaTeX:
<ol>
<li>Create a new file and save to a new directory.</li>
<li>Type in a simple document, like:
<pre>\documentclass{article}
\begin{document}
\[
x_{1,2}=\frac{-b\pm\sqrt{b^2-4ac}}{2a}.
\]
I can do math!
\end{document}</pre>
</li>
<li>In the toolbar, select &#8220;LaTeX =&gt; PDF&#8221; output profile, and click &#8220;Build current file&#8221; right next to it.</li>
<li>Click &#8220;View Output&#8221; in the same toolbar. You should have math in your PDF. Congratulation!</li>
</ol>
</li>
</ol>
<p>LaTeX: easy to start, hard to master&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.wuxinan.net/archives/271/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

