<?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>Tarotoast's Stuff &#187; Internet</title>
	<atom:link href="http://blog.tarotoast.com/category/it/internet/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.tarotoast.com</link>
	<description>Personal blog</description>
	<lastBuildDate>Tue, 04 May 2010 08:49:17 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Flock 1.0</title>
		<link>http://blog.tarotoast.com/2007/10/30/407/#utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=flock-10</link>
		<comments>http://blog.tarotoast.com/2007/10/30/407/#comments</comments>
		<pubDate>Wed, 31 Oct 2007 00:11:41 +0000</pubDate>
		<dc:creator>tarotoast</dc:creator>
				<category><![CDATA[IT]]></category>
		<category><![CDATA[Internet]]></category>
		<category><![CDATA[browser]]></category>
		<category><![CDATA[flock]]></category>
		<category><![CDATA[Ubuntu]]></category>

		<guid isPermaLink="false">http://blog.tarotoast.com/2007/10/30/407/</guid>
		<description><![CDATA[很久沒有試著去用 Flock 了，沒想到現在竟然連 Linux 板都做出來了 1.0 板的 Flock 多了許多服務，但是還是沒有 Gallery 2.0 的支援 絕大部分的服務都是美國的英文語系 不知道 Flock 可不可以放出 API 讓 3rd party 自己寫其他的 social integration 想想，可能性實在太小了 不過台灣是有多少 social networking 的網站可以整合？無名好友？ 現在 Flock (1.0 RC3) 支援的服務如下: People Facebook Flickr Twitter Youtube Media Photobucket Piczo Blogging Blogger Blogsome LiveJournal Typepad WordPress.com Xanga Self-Hosted Blog Online Favorites del.icio.us Magnolia 感覺起來最好用的還是 [...]]]></description>
			<content:encoded><![CDATA[<p>很久沒有試著去用 Flock 了，沒想到現在竟然連 Linux 板都做出來了<br />
1.0 板的 Flock 多了許多服務，但是還是沒有 Gallery 2.0 的支援<br />
絕大部分的服務都是美國的英文語系<br />
不知道 Flock 可不可以放出 API 讓 3rd party 自己寫其他的 social integration<br />
想想，可能性實在太小了<br />
不過台灣是有多少 social networking 的網站可以整合？無名好友？</p>
<p>現在 Flock (1.0 RC3) 支援的服務如下:</p>
<ul>
<li>People</li>
<ul>
<li>Facebook</li>
<li>Flickr</li>
<li>Twitter</li>
<li>Youtube
</li>
</ul>
<li>Media</li>
<ul>
<li>Photobucket</li>
<li>Piczo
</li>
</ul>
<li>Blogging</li>
<ul>
<li>Blogger</li>
<li>Blogsome</li>
<li>LiveJournal</li>
<li>Typepad</li>
<li>WordPress.com</li>
<li>Xanga</li>
<li>Self-Hosted Blog
</li>
</ul>
<li>Online Favorites</li>
<ul>
<li>del.icio.us</li>
<li>Magnolia</li>
</ul>
</ul>
<p>感覺起來最好用的還是 Flickr 的 Media Bar + Blogging 的整合<br />
del.icio.us 的整合也是個很好用的東西<br />
但是最近 Yahoo 的 del.icio.us Firefox Extension 已經把舊版的問題解決<br />
現在的新版不像舊版一樣只能選擇用 del.icio.us 或者 firefox 內建的 Bookmarks</p>
<p>不知道以後可不可以安裝時候勾選有哪些服務想要支援再安裝那些服務的支援
<p style="text-align: right; font-size: 8px">Blogged with <a href="http://www.flock.com/blogged-with-flock" title="Flock" target="_new">Flock</a></p>
<p><!-- technorati tags begin -->
<p style="font-size:10px;text-align:right;">Tags: <a href="http://technorati.com/tag/flock" rel="tag">flock</a>, <a href="http://technorati.com/tag/social%20network" rel="tag">social network</a>, <a href="http://technorati.com/tag/%20taiwan" rel="tag"> taiwan</a>, <a href="http://technorati.com/tag/%20extension" rel="tag"> extension</a>, <a href="http://technorati.com/tag/%20development" rel="tag"> development</a></p>
<p><!-- technorati tags end --></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.tarotoast.com/2007/10/30/407/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Use Shared Host&#8217;s MySQL on VPS</title>
		<link>http://blog.tarotoast.com/2007/04/15/364/#utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=use-of-shared-hosts-mysql-on-vps</link>
		<comments>http://blog.tarotoast.com/2007/04/15/364/#comments</comments>
		<pubDate>Sun, 15 Apr 2007 23:47:33 +0000</pubDate>
		<dc:creator>tarotoast</dc:creator>
				<category><![CDATA[BSD+Linux]]></category>
		<category><![CDATA[IT]]></category>
		<category><![CDATA[Internet]]></category>
		<category><![CDATA[Server Diary]]></category>
		<category><![CDATA[hack]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[ssh tunnel]]></category>
		<category><![CDATA[vps]]></category>

		<guid isPermaLink="false">http://blog.tarotoast.com/2007/04/15/364/</guid>
		<description><![CDATA[On my 1&#038;1 VPS II server, it comes with only 256MB of dedicated memory, which is pathetic. If I run a separate mysqld, it&#8217;s going to take 1xxMB away from this super limit memory pool. It makes sense to me to make use of MySQL databases on another shared hosting account. BlueHost and HostMonster both [...]]]></description>
			<content:encoded><![CDATA[<p>On my 1&#038;1 VPS II server, it comes with only 256MB of dedicated memory, which is pathetic. If I run a separate mysqld, it&#8217;s going to take 1xxMB away from this super limit memory pool. It makes sense to me to make use of MySQL databases on another shared hosting account. BlueHost and HostMonster both comes with firewall enabled by default for their MySQL servers. Going about white listing server&#8217;s IP can be done via:</p>
<ol>
<li>Launching remote firefox session, which takes your patient and the hassle of all those x window configs.</li>
<li>Setup VPN on the server, and use server&#8217;s IP to to whitelist itself.</li>
</ol>
<p>But the connection between the VPS server and Shared Host&#8217;s MySQL database is insecure. It&#8217;s natural to come to this conclusion as the best option: ssh tunnel.</p>
<p>Assuming you have shell access to both VPS and Shared Host, and both are running OpsnSSH.</p>
<p><strong>Setup Public Key Authentication</strong></p>
<ol>
<li>Login to VPS with account you want to create the tunnel</li>
<li>
<pre style="border: 1px inset ; margin: 0px; padding: 6px; overflow: auto; width: 400px; text-align: left">cd ~/.ssh</pre>
<p>(create it if not exist)</li>
<li>
<pre style="border: 1px inset ; margin: 0px; padding: 6px; overflow: auto; width: 400px; text-align: left">ssh-keygen -t dsa</pre>
</li>
<li>Securely transfer id_dsa.pub to the Shared Hosting&#8217;s home directly, something like this:
<pre style="border: 1px inset ; margin: 0px; padding: 6px; overflow: auto; width: 400px; text-align: left">scp id_dsa.pub sharedhost:/home/username/.ssh/server_id_psa.pub</pre>
</li>
<li>Login to Shared Host</li>
<li>
<pre style="border: 1px inset ; margin: 0px; padding: 6px; overflow: auto; width: 400px; text-align: left">cd ~/.ssh
cat server_id_psa.pub >> authorized_keys</pre>
</li>
<li>Switch back to VPS, try logging into Shared Host using public key authentication:
<pre style="border: 1px inset ; margin: 0px; padding: 6px; overflow: auto; width: 400px; text-align: left">ssh username@sharedhost</pre>
<p>If everything is setup properly, no password is prompted.</li>
</ol>
<p>If in doubt, [<a href="http://defindit.com/readme_files/ssh.html">this</a>] is a good place to consult about Public Key Authentication.</p>
<p><strong>Setting up a host name</strong></p>
<p>When MySQL is connecting to localhost, it will try to use socket, regardless of the efforts trying to tell it the service is actually not running on localhost, but rather a tunnel to a remote host. To overcome this issue, create an entry in /etc/hosts:</p>
<pre style="border: 1px inset ; margin: 0px; padding: 6px; overflow: auto; width: 400px; text-align: left">127.0.0.1 localhost mysqlhost</pre>
<p>This points the host name &#8216;mysqlhost&#8217; to 127.0.0.1 which essentially is also localhost, but mysql is too dumb to understand.</p>
<p><strong>Create the tunnel</strong></p>
<ol>
<li>First, stop the local mysqld. As root:</p>
<pre style="border: 1px inset ; margin: 0px; padding: 6px; overflow: auto; width: 400px; text-align: left">service stop mysqld</pre>
</li>
<li>Login to VPS with username previously configured with public key authentication to Shared Host</li>
<li>create tunnel:
<pre style="border: 1px inset ; margin: 0px; padding: 6px; overflow: auto; width: 400px; text-align: left">ssh -f username@sharedhost -N -L 3306:localhost:3306</pre>
<p>This creates a ssh tunnel in background and forward connection to port 3306 on localhost to port 3306 on sharedhost.</li>
<li>Make change in php to reflect the database names, users, password on Shared Host, and most importantly, instead of <b>localhost</b>, use <b>mysqlhost</b> in configuration files.</li>
</ol>
<p><strong>Automate the process</strong></p>
<p>What if the ssh tunnel died? What if the VPS restarts? How to make sure the connection stays live? The answer is to use <b>autossh</b>.</p>
<ol>
<li>As root:</p>
<pre style="border: 1px inset ; margin: 0px; padding: 6px; overflow: auto; width: 400px; text-align: left">yum install autossh</pre>
</li>
<li>Edit /etc/rc.d/rc.local, add this line at the bottom:
<pre style="border: 1px inset ; margin: 0px; padding: 6px; overflow: auto; width: 400px; text-align: left">su VPSusername -c 'autossh -M 5307 -f SHAREDHOSTusername@sharedhost -N -L 3306:*:3306' &#038;</pre>
<p>This tells the server to execute the command in &#8216; &#8216; as VPSusername and put the process into background at startup. autossh will use port 5307 to monitor the ssh tunnel to sharedhost, and reconnect if it drops. Also make sure to disable the local MySQL daemon from starting automatically, or the tunnel cannot be created.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.tarotoast.com/2007/04/15/364/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>OpenVPN on FC4 note</title>
		<link>http://blog.tarotoast.com/2007/04/15/363/#utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=openvpn-on-fc4-note</link>
		<comments>http://blog.tarotoast.com/2007/04/15/363/#comments</comments>
		<pubDate>Sun, 15 Apr 2007 21:19:16 +0000</pubDate>
		<dc:creator>tarotoast</dc:creator>
				<category><![CDATA[BSD+Linux]]></category>
		<category><![CDATA[Internet]]></category>
		<category><![CDATA[Server Diary]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[fc4]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[openvpn]]></category>

		<guid isPermaLink="false">http://blog.tarotoast.com/2007/04/15/363/</guid>
		<description><![CDATA[Server yum install openvpn cp -R /usr/share/openvpn/easy-rsa /etc/openvpn cd /etc/openvpn/easy-rsa vim vars: # easy-rsa parameter settings # NOTE: If you installed from an RPM, # don't edit this file in place in # /usr/share/openvpn/easy-rsa -- # instead, you should copy the whole # easy-rsa directory to another location # (such as /etc/openvpn) so that your [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Server</strong></p>
<ol>
<li>yum install openvpn</li>
<li>cp -R /usr/share/openvpn/easy-rsa /etc/openvpn</li>
<li>cd /etc/openvpn/easy-rsa</li>
<li>vim vars:
<pre style="border: 1px inset ; margin: 0px; padding: 6px; overflow: auto; width: 400px; height: 400px; text-align: left">
# easy-rsa parameter settings
# NOTE: If you installed from an RPM,
# don't edit this file in place in
# /usr/share/openvpn/easy-rsa --
# instead, you should copy the whole
# easy-rsa directory to another location
# (such as /etc/openvpn) so that your
# edits will not be wiped out by a future
# OpenVPN package upgrade.
# This variable should point to
# the top level of the easy-rsa
# tree.

export D=`pwd`

# This variable should point to
# the openssl.cnf file included
# with easy-rsa.

export KEY_CONFIG=$D/openssl.cnf

# Edit this variable to point to
# your soon-to-be-created key
# directory.
#
# WARNING: clean-all will do
# a rm -rf on this directory
# so make sure you define
# it correctly!

export KEY_DIR="/etc/openvpn/keys"

# Issue rm -rf warning

echo NOTE: when you run ./clean-all, I will be doing a rm -rf on $KEY_DIR

# Increase this to 2048 if you
# are paranoid.  This will slow
# down TLS negotiation performance
# as well as the one-time DH parms
# generation process.

export KEY_SIZE=1024

# These are the default values for fields
# which will be placed in the certificate.
# Don't leave any of these fields blank.

export KEY_COUNTRY=US
export KEY_PROVINCE=CA
export KEY_CITY=SANDIEGO
export KEY_ORG="TAROTOAST.COM"
export KEY_EMAIL="chang.peter@gmail.com"</pre>
</li>
<li>chmod 700 *</li>
<li>mkdir /etc/openvpn/keys</li>
<li>make sure in Bash shell (still at /etc/openvpn/easy-rsa directory)</li>
<li>./vars</li>
<li>./clean-all</li>
<li>./build-ca<br />
Enter ROOTCA for common name</li>
<li>./build-key-server server<br />
Enter ROOT for common name</li>
<li>./build-key [computername] &lt;&#8211; repeat for # of computers want to allow connect<br />
Enter [computername] as common name<br />
EX: ./build-key AMD64<br />
EX: ./build-key X40</li>
<li>./build-dh</li>
<li>vim /etc/openvpn/server.conf:
<pre style="border: 1px inset ; margin: 0px; padding: 6px; overflow: auto; width: 400px; text-align: left">
port 1194
proto tcp
dev tun
ca keys/ca.crt
cert keys/server.crt
key keys/server.key
dh keys/dh1024.pem
server 10.11.12.0 255.255.255.0
client-config-dir ccd
push "dhcp-option DNS SERVERIP"
push "dhcp-option DNS SERVERDNS"
ifconfig-pool-persist ipp.txt
push "redirect-gateway"
keepalive 10 120
comp-lzo
persist-key
persist-tun
status server-tcp.log
verb 3</pre>
</li>
<li>Create log files: touch /etc/openvpn/server-tcp.log /etc/openvpn/ipp.txt</li>
<li>vim /etc/init.d/openvpn:<br />
Uncomment line 114
<pre style="border: 1px inset ; margin: 0px; padding: 6px; overflow: auto; width: 400px; text-align: left">/sbin/modprobe tun &gt;/dev/null 2&gt;&amp;1</pre>
<p>Insert after line 115
<pre style="border: 1px inset ; margin: 0px; padding: 6px; overflow: auto; width: 400px; text-align: left">
iptables -t nat -A POSTROUTING -s 10.11.12.3 -j SNAT --to SERVERIP
iptables -t nat -A POSTROUTING -s 10.11.12.4 -j SNAT --to SERVERIP
iptables -t nat -A POSTROUTING -s 10.11.12.5 -j SNAT --to SERVERIP
iptables -t nat -A POSTROUTING -s 10.11.12.6 -j SNAT --to SERVERIP
iptables -t nat -A POSTROUTING -s 10.11.12.7 -j SNAT --to SERVERIP
iptables -t nat -A POSTROUTING -s 10.11.12.8 -j SNAT --to SERVERIP
iptables -t nat -A POSTROUTING -s 10.11.12.9 -j SNAT --to SERVERIP
iptables -t nat -A POSTROUTING -s 10.11.12.10 -j SNAT --to SERVERIP</pre>
</li>
<li>service openvpn start</li>
</ol>
<p><strong>Client (Windows Vista with UAC on)</strong></p>
<ol>
<li>Download and install OpenVPN Gui 1.0.3 with OpenVPN 2.0.9 [<a href="http://openvpn.se/files/install_packages/openvpn-2.0.9-gui-1.0.3-install.exe">Here</a>]</li>
<li>Scary warning will pop up telling you the driver will not work, install it anyway. OpenVPN&#8217;s developers fixed it already.
<li>Make a shortcut on desktop to GUI executable &#8220;C:\Program Files\OpenVPN\bin\openvpn-gui-1.0.3.exe&#8221;</li>
<li>Use WinSCP to download these files onto the client computer:<br />
/etc/openvpn/keys/ca.crt<br />
/etc/openvpn/keys/AMD64.key<br />
/etc/openvpn/keys/AMD64.crt</li>
<li>Put above files along with this VPNServer.ovpn in C:\Program Files\OpenVPN\config<br />
VPNServer.ovpn
<pre style="border: 1px inset ; margin: 0px; padding: 6px; overflow: auto; width: 400px; text-align: left">
client
dev tun
proto tcp
remote SERVERIP 1194
resolv-retry infinite
nobind
persist-key
persist-tun
ca ca.crt
cert AMD64.crt
key AMD64.key
ns-cert-type server
push "dhcp-option DNS SERVERIP"
push "dhcp-option DNS SERVERDNSIP"
comp-lzo
verb 3
route-method exe
route-delay 2
</pre>
</li>
<li>Right click on the shortcut to openvpn-gui-1.0.3.exe, select Run As Administrator</li>
<li>On the taskbar, right click the openvpn gui icon, select connect</li>
</ol>
<p>DONE [aha</p>
<p>The above mostly follows [<a href="http://www.webhostingtalk.com/showthread.php?t=595436">this thread</a>] except some minor changes in client side config.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.tarotoast.com/2007/04/15/363/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Hamachi</title>
		<link>http://blog.tarotoast.com/2006/09/19/277/#utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=hamachi</link>
		<comments>http://blog.tarotoast.com/2006/09/19/277/#comments</comments>
		<pubDate>Wed, 20 Sep 2006 04:45:51 +0000</pubDate>
		<dc:creator>tarotoast</dc:creator>
				<category><![CDATA[IT]]></category>
		<category><![CDATA[Internet]]></category>

		<guid isPermaLink="false">http://blog.tarotoast.com/2006/09/19/277/</guid>
		<description><![CDATA[這是跟 Summer 2006 沒關係的 Post. Hamachi 真是個很神奇的軟體. 印象中餅幹以前好像有為了要搞個 VPN 然後搞那些繁雜的 OpenVPN 的設定還特地寫了一篇 post 來紀錄. 而 Hamachi 這東西則是將些複雜的設定通通透明化. 好用的沒話說阿 XD 簡單介紹一下它在幹麻: Hamachi Client 會在電腦上面安裝個虛擬的 Network Adapter. 第一次安裝時候它會連到 Hamachi Server (不是自己架的, 是 Hamachi 的 server) 取得一個 5 開頭的 IP. 那個 IP 是 non-routable 的 LAN 用 ip, 所以丟在網路上讓人知道也沒關係. 取得 IP 後就可以建立 Network 或者加入 Network 了. 建立/加入 Network: [...]]]></description>
			<content:encoded><![CDATA[<p>這是跟 Summer 2006 沒關係的 Post.</p>
<p>Hamachi 真是個很神奇的軟體. 印象中餅幹以前好像有為了要搞個 VPN 然後搞那些繁雜的 OpenVPN 的設定還特地寫了一篇 post 來紀錄. 而 Hamachi 這東西則是將些複雜的設定通通透明化. 好用的沒話說阿 XD</p>
<p>簡單介紹一下它在幹麻: Hamachi Client 會在電腦上面安裝個虛擬的 Network Adapter. 第一次安裝時候它會連到 Hamachi Server (不是自己架的, 是 Hamachi 的 server) 取得一個 5 開頭的 IP. 那個 IP 是 non-routable 的 LAN 用 ip, 所以丟在網路上讓人知道也沒關係. 取得 IP 後就可以建立 Network 或者加入 Network 了.</p>
<p>建立/加入 Network: 要詳細解釋怎麼運作的可能很複雜, 就別想太多. 重點是不同電腦加入了同樣的 Network 後, 電腦互相就可以在 LAN 上面看到對方了!!! 電腦們到了同一個 LAN 後可以作什麼? 網路的芳鄰啦, 網路遊戲啦, 私人用 web service 啦, 想的到的都做得到.</p>
<p>Hamachi 是個 VPN Solution, 雖然它簡單到很不可斯異, 但是 VPN 就是 VPN. 理論上都很安全的. 目前自己發現最好用的就是家裡電腦透過 hamachi 可以讓我的小黑用遠端桌面控制了 XD</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.tarotoast.com/2006/09/19/277/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>php + curl = convenient</title>
		<link>http://blog.tarotoast.com/2006/07/17/262/#utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=php-curl-convenient</link>
		<comments>http://blog.tarotoast.com/2006/07/17/262/#comments</comments>
		<pubDate>Tue, 18 Jul 2006 02:20:13 +0000</pubDate>
		<dc:creator>tarotoast</dc:creator>
				<category><![CDATA[Footprints + Diary]]></category>
		<category><![CDATA[IT]]></category>
		<category><![CDATA[Internet]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://blog.tarotoast.com/2006/07/17/262/</guid>
		<description><![CDATA[There nothing major or significant going on in my life and therefore I did not bother writing anything down, for quite a while, as you might know. Anyway, today I&#39;m writing a little utility to help fetching images on remote server and store it into sequential names, all within PHP. To initiate a curl request, [...]]]></description>
			<content:encoded><![CDATA[<p>There nothing major or significant going on in my life and therefore I did not bother writing anything down, for quite a while, as you might know. Anyway, today I&#39;m writing a little utility to help fetching images on remote server and store it into sequential names, all within PHP.</p>
<p>To initiate a curl request, you declare one like this:</p>
<blockquote><p>$c = curl_init(&quot;http://server/page.html?getopt=value&quot;);</p></blockquote>
<p>Then set options for this curl request:</p>
<blockquote><p>curl_setopt($c, CURLOPT_RETURNTRANSFER,1); // stops the request from outputting immediately</p>
<p>curl_setopt($c, CURLOPT_USERAGENT, &quot; Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)&quot;); // use a very legit fake useragent</p>
<p>curl_setopt($c, CURLOPT_REFERER, &quot;http://server&quot;); // bypassing measures preventing hotlinking/stealing/whatever u&#39;d like to call it</p></blockquote>
<p>A complete listing of all available curl options is <a href="http://us2.php.net/manual/en/function.curl-setopt.php">here</a>. After the options are set, execute the request and store the result like this:</p>
<blockquote><p>$result = curl_exec($c);</p>
<p>$curlinfo = curl_getinfo($c);</p>
<p>$httperrorcode = $info[&#39;http_code&#39;];</p></blockquote>
<p>If the query is proper, the $httperrorcode should be 200. Assuming you&#39;ve successfully (200) obtained the targeted document, these are helpful methods to use to manipulate/store the data:</p>
<ul>
<li>strlen( $var )</li>
<li>str_replace( &quot;replace this with&quot;, &quot;this&quot;, $from_this )</li>
<li>explode( &quot;seperator&quot;, $turn_into_array )</li>
<li>sizeof( $var )</li>
<li>strstr( $does_this_contain, &quot;this&quot; )</li>
<li>print( $var )</li>
<li>echo( $var )</li>
<li>mkdir( &quot;ABSPATH&quot;, 0777)</li>
<li>$fp = fopen( &quot;ABSFILENAME&quot;, &#39;w&#39; );</li>
<li>fwrite( $fp, $result )</li>
<li>fclose( $fp )</li>
</ul>
<p style="margin-left: 40px">&nbsp;</p>
<p style="margin-left: 40px">&nbsp;</p>
<p>After the whatever-purpose php script is done, simply use the following way to execute under console:</p>
<blockquote><p>php filename.php getopt1=val1 getopt2=val2</p></blockquote>
<p>Of course, you access those val1 and val2 within the program with $_GET[&#39;getopt1&#39;] and etc.&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.tarotoast.com/2006/07/17/262/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>List of actually useful PR 10 pages</title>
		<link>http://blog.tarotoast.com/2006/04/21/255/#utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=list-of-actually-useful-pr-10-pages</link>
		<comments>http://blog.tarotoast.com/2006/04/21/255/#comments</comments>
		<pubDate>Fri, 21 Apr 2006 08:09:08 +0000</pubDate>
		<dc:creator>tarotoast</dc:creator>
				<category><![CDATA[Fun+Humor]]></category>
		<category><![CDATA[IT]]></category>
		<category><![CDATA[Internet]]></category>

		<guid isPermaLink="false">http://blog.tarotoast.com/2006/04/21/255/</guid>
		<description><![CDATA[Here is a list of current (as of last updated time/date) PageRank (PR) 10 pages that are actually useful: Adobe Reader &#8211; Download: Place to get the slowest PDF reader available. Apple iTunes: Place to get the DRM software for the most popular MP3 player. FirstGov.gov: The U.S. Government&#39;s Official Web Portal: Citizens, Get It [...]]]></description>
			<content:encoded><![CDATA[<p>Here is a list of current (as of last updated time/date) <a href="http://www.google.com/technology/">PageRank</a> (PR) 10 pages that are actually <b><i>useful</i></b>:</p>
<ul>
<li><a href="http://www.adobe.com/products/acrobat/readstep2.html">Adobe Reader &#8211; Download</a>: Place to get the slowest PDF reader available.</li>
<li><a href="http://www.apple.com/itunes/">Apple iTunes</a>: Place to get the DRM software for the most popular MP3 player.</li>
<li><a href="http://www.firstgov.gov/">FirstGov.gov: The U.S. Government&#39;s Official Web Portal</a>: Citizens, Get It Done Online!</li>
<li><a href="http://www.google.com/">Google</a>: Handle all your searches nicely without(?) being evil.</li>
<li><a href="http://www.macromedia.com/">Macromedia</a>: There&#39;s an useful &quot;Get Macromedia Flash Player&quot; button at the bottom.</li>
<li><a href="http://www.statcounter.com/">StatCounter</a>: A PR 10 Counter!</li>
<li><a href="http://www.w3.org/">World Wide Web Consortium</a>: Web standards.</li>
<li><a href="http://jigsaw.w3.org/css-validator/">The W3C CSS Validation Service</a>: CSS validation for compatible browsers that are compatible with standards.</li>
</ul>
<p>More useful PR10 pages are to be added.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.tarotoast.com/2006/04/21/255/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>1&amp;1 Server ReImage Notes</title>
		<link>http://blog.tarotoast.com/2006/04/03/249/#utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=11-server-reimage-notes</link>
		<comments>http://blog.tarotoast.com/2006/04/03/249/#comments</comments>
		<pubDate>Tue, 04 Apr 2006 00:14:18 +0000</pubDate>
		<dc:creator>tarotoast</dc:creator>
				<category><![CDATA[IT]]></category>
		<category><![CDATA[Internet]]></category>
		<category><![CDATA[Server Diary]]></category>

		<guid isPermaLink="false">http://blog.tarotoast.com/2006/04/03/249/</guid>
		<description><![CDATA[Recently, 1&#38;1 released Fedora Core 3 with Plesk 7.5 as one of the images server administrator can restore to. Since I&#39;ve messed up the server a lot, instead of spending more time trying to figure out how to fix it and upgrade it, a quicker solution is to reimage it to FC3. This leads to [...]]]></description>
			<content:encoded><![CDATA[<p>Recently, <a href="http://www.1and1.com/?k_id=6606686">1&amp;1</a> released Fedora Core 3 with Plesk 7.5 as one of the images server administrator can restore to. Since I&#39;ve messed up the server a lot, instead of spending more time trying to figure out how to fix it and upgrade it, a quicker solution is to reimage it to FC3. This leads to backuping things up. I tried to get ftpfs working so there would be easy access to 1&amp;1&#39;s backup server, but the process seems like this: I&#39;m getting close the solution, but there is this one problem which leads to another problem, and then as I get close to the solution of this another problem, there&#39;s another one problem that leads to another another problem. You get the idea. Anyway, I ended up using <i>tar</i> and <i>ftp</i> command to manually backup files and upload them onto the backup server.</p>
<p>Directories backuped:</p>
<ul>
<li>/etc</li>
<li>/home/httpd</li>
<li>/var</li>
</ul>
<p>1&amp;1&#39;s FAQ has an article &quot;<a href="http://faq.1and1.com//dedicated_servers/root_server/backup/4.html">What should I backup?</a>&quot; and I think&#8230; yeah&#8230; well&#8230; it&#39;s a 1&amp;1&#39;s FAQ, as long as you&#39;re happy. I use the standard <i>tar zcvf</i> to add each directory info one <i>.tgz</i> file and then upload it onto the backup server. After these, simply go to the admin panel&#39;s Server ReImage page, and select Fedora Core 3 w/ Plesk 7.5, then click the button. In about 40 minutes? Maybe less? The refreshed page finally shows <i>Server Ready</i>.</p>
<p>These are what I really used during restore:</p>
<ul>
<li>/etc/csh.cshrc</li>
<li>/etc/screenrc</li>
<li>/home/httpd</li>
<li>/var/lib/mysql</li>
</ul>
<p>I tried to restore mysql database through the dumped out database via phpmyadmin by uploading them into the sql query window. It doesn&#39;t work (orz). What I found out that worked way easier is to create the database &amp; user via Plesk first, and then copy the old database files onto the new ones. Files are located under /var/lib/mysql/[databasename]/. Since I&#39;m getting my old files back from the FTP backup server, <a href="http://blog.tarotoast.com/2006/04/02/242/">installing FTPFS</a> helps a lot.</p>
<p>Additionally, there are other things to do after the newly reimaged server:</p>
<ul>
<li>Move /opt to allow Plesk 8.0 update: For some mysterious reason, Plesk 8.0 refuse to install unless you have enough space under /opt. Ironically, by default, there is not enough space. So to make Plesk 8.0 happy in this FC3, link /opt to /home/opt.</li>
<li>Change the timezone:  relink the file /etc/localtime to the correct timezone listed under /usr/share/zoneinfo. For mine:<br />
<span style="font-style: italic">ln -sf /usr/share/zoneinfo/US/Pacific /etc/localtime</span></li>
<li>Add ntpdate into root&#39;s cron:<br />
<span style="font-style: italic">0 * * * * /usr/sbin/ntpdate time.ucla.edu</span></li>
<li>Essential packages: <span style="font-style: italic">yum install cvs firefox openssl python-devel subversion vim xterm</span></li>
<li>Essential Packages not available via yum: <a href="http://rpmfind.net/linux/RPM/dag/fedora/3/i386/apt-0.5.15cnc6-4.1.fc3.rf.i386.html">apt</a>, <a href="http://rpmfind.net/linux/RPM/fedora/3/i386/ncftp-3.1.8-2.i386.html">ncftp</a>. rpm -iv files.</li>
</ul>
<p>Also within /etc/my.cnf under [mysql.server], add in:</p>
<p><i>set-variable = max_connections = 300<br />
set-variable = max_user_connections = 300</i></p>
<p>Do they work? I haven&#39;t get a chance to try yet.</p>
<p>To be updated later if new things came across.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.tarotoast.com/2006/04/03/249/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>VoipStunt Paid</title>
		<link>http://blog.tarotoast.com/2006/04/03/246/#utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=voipstunt-paid</link>
		<comments>http://blog.tarotoast.com/2006/04/03/246/#comments</comments>
		<pubDate>Mon, 03 Apr 2006 23:00:32 +0000</pubDate>
		<dc:creator>tarotoast</dc:creator>
				<category><![CDATA[IT]]></category>
		<category><![CDATA[Internet]]></category>

		<guid isPermaLink="false">http://blog.tarotoast.com/2006/04/03/246/</guid>
		<description><![CDATA[在老木來的這個禮拜裡面, 去給 VoipStunt 付費了. 為什麼? 因為老木要打電話回去跟中華電信抱怨說為啥明明廣告說 3G 電話拿到哪裡都可以用, 來美國後竟然不能用. 用電話卡打國際電話回台灣 complain 實在有點小白, 於是興起了用網路電話打的念頭. 但是最近 VoipStunt 的一分鐘限製作的十分徹底, 1 minute, cut. 所以想說用 Skypeout 或者 Voipstunt 選一個. 用上次得到的 $.20 SkypeOut credit 來打回去給老北試, 看起來效果似乎真的跟電話差不多. Voipstunt 則是音質差了那麼一咪咪 (難看的使用介面造成心靈層面的質感問題?), 但基本上效果也是跟電話一樣. 但是 SkypeOut 每分鐘要算錢, VoipStunt 則不用算, 所以結果很明顯了. 根據 VoipStunt 官方網頁的說法是只要帳號裡面有餘額, 就不會有一分鐘的限制. 雖然這麼說, 但是進入付費網頁後, 發現最低也要存入 $10 EUR. 根據 XE.COM (PR9) 網站的資料, $10 EUR [...]]]></description>
			<content:encoded><![CDATA[<p>在老木來的這個禮拜裡面, 去給 VoipStunt 付費了. 為什麼? 因為老木要打電話回去跟中華電信抱怨說為啥明明廣告說 3G 電話拿到哪裡都可以用, 來美國後竟然不能用. 用電話卡打國際電話回台灣 complain 實在有點小白, 於是興起了用網路電話打的念頭. 但是最近 VoipStunt 的一分鐘限製作的<a href="http://blog.tarotoast.com/2006/03/16/230/">十分徹底</a>, 1 minute, cut. 所以想說用 Skypeout 或者 Voipstunt 選一個. 用上次<a href="http://blog.tarotoast.com/2006/02/23/216/">得到</a>的 $.20 SkypeOut credit 來打回去給老北試, 看起來效果似乎真的跟電話差不多. Voipstunt 則是音質差了那麼一咪咪 (難看的使用介面造成心靈層面的質感問題?), 但基本上效果也是跟電話一樣. 但是 SkypeOut 每分鐘要算錢, VoipStunt 則不用算, 所以結果很明顯了.</p>
<p>根據 VoipStunt 官方網頁的說法是只要帳號裡面有餘額, 就不會有一分鐘的限制. 雖然這麼說, 但是進入付費網頁後, 發現最低也要存入 $10 EUR. 根據 XE.COM (PR9) 網站的資料, $10 EUR = $12.13 USD. 那實際上銀行顯示是多少呢?</p>
<p><img src="http://blog.tarotoast.com/wp-content/uploads/2006/04/voipstuntfee.png" id="image247" alt="VoipStunt Fee" /></p>
<p>他還會存了 $0 來跟我講說要 charge 我 $10 Eur + $.36 手續費, 真是貼心阿. $12.43 USD 根據 XE.COM (PR9) 折合新台幣 $405.27.存完後 balance 馬上就變成 $10, 然後討厭的 1 minute limit 也不見了. 除此外基本上都完全一樣. 真的都讓你無限制的打到爆嗎? 會倒吧&#8230; Orz 所以他們有限制在你付費完 120 天內得用完.</p>
<p><img src="http://blog.tarotoast.com/wp-content/uploads/2006/04/voipstunt4month.png" id="image245" alt="VoipStunt 4 month limit" /></p>
<p>那可不可以共用帳號? 答案是&#8230; 否定的. 他不會像 Sype 一樣讓你同時在兩台電腦 Sign in, 然後人家打來時候兩台電腦同時響 (新的版本還會不會不知道耶.. 以前的都會這樣). VoipStunt 的做法則是像一般的 IM, 這台 Sign in, 之前那台就會自動被 Sign Out. 不過只要同時間只有一個人用, 那看來是沒問題的. 所以一個月 $100 台幣可以無限制的打那麼多的國家 (台灣手機參照<a href="http://blog.tarotoast.com/2006/02/05/192/">這篇)</a>, 很划算啦 XD</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.tarotoast.com/2006/04/03/246/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>HOWTO: mount ftpfs under linux</title>
		<link>http://blog.tarotoast.com/2006/04/02/242/#utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=howto-mount-ftpfs-under-linux</link>
		<comments>http://blog.tarotoast.com/2006/04/02/242/#comments</comments>
		<pubDate>Sun, 02 Apr 2006 08:57:23 +0000</pubDate>
		<dc:creator>tarotoast</dc:creator>
				<category><![CDATA[IT]]></category>
		<category><![CDATA[Internet]]></category>
		<category><![CDATA[Server Diary]]></category>

		<guid isPermaLink="false">http://blog.tarotoast.com/2006/04/02/242/</guid>
		<description><![CDATA[1&#38;1&#39;s Dedicate Servers come with a free FTP backup account that is only accessible within the server, and has a capacity matching the server&#39;s harddrive. Wouldn&#39;t it be nice if I don&#39;t have to use text-only ftp command to put, get files from that server? Yeah, mount it as an directory. There are couple options [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.1and1.com/?k_id=6606686">1&amp;1</a>&#39;s Dedicate Servers come with a free FTP backup account that is only accessible within the server, and has a capacity matching the server&#39;s harddrive. Wouldn&#39;t it be nice if I don&#39;t have to use text-only <i>ftp</i> command to put, get files from that server? Yeah, mount it as an directory.<br />
There are couple options available:</p>
<ul>
<li><a href="http://ftpfs.sourceforge.net/">FTP File System (FTPFS)</a></li>
<li><a href="http://lufs.sourceforge.net/lufs/">UserLand FileSystem (LUFS)</a></li>
<li><a href="http://fuse.sourceforge.net/">Filesystem in Userspace (FUSE)</a></li>
</ul>
<p>FTPFS is obsolete. Since FUSE is merged into <a href="http://www.kernel.org/pub/linux/kernel/v2.6/">Linux Kernel</a> 2.6.14, it seems reasonable to choose FUSE than LUFS. So the task now is to recompile a Linux Kernel version 2.6.14 and up with FUSE support. As far as how to compile the kernel, there are <a href="http://www.google.com/search?q=compile+linux+kernel">way too many articles</a> detailing step by step howtos. Since this dedicated server is using FC3, I followed <a href="http://www.mjmwired.net/resources/mjm-kernel-fc3.html">this article</a>. If you have a kernel 2.6.14 and up and want to enable FUSE, simply add this into your kernel&#39;s <span style="font-style: italic">.config</span> file.</p>
<p style="margin-left: 40px; font-style: italic">CONFIG_FUSE_FS=y</p>
<p>Reboot with the new FUSE-enabled kernel, then we&#39;re ready to use all the <a href="http://fuse.sourceforge.net/wiki/index.php/FileSystems">Filesystem based on FUSE</a>. There were quite many. Since the focus is to mount FTP access as a directory, using FTP as keyword and search through the page brings us to two choices:</p>
<ul>
<li><a href="http://wiki.thiesen.org/page/Fuseftp">FuseFTP</a>: Written in Perl.</li>
<li><a href="http://curlftpfs.sourceforge.net/">CurlFtpFs</a>: Using libcurl.</li>
</ul>
<p>CurlFtpFs seems to be more feature-rich, so I went with it. Note that on <a href="http://sourceforge.net/projects/curlftpfs">SF&#39;s Project Detail</a>, the Development Status is 3-Alpha, so use it with your own risk. Since I&#39;m only working on occasional copying and retrieving of backups, and it works fine, I&#39;m happy with it. Installation of CurlFtpFs is simple, given that libcurl and dependencies are installed correctly. These are the steps:</p>
<ul>
<li>Download and extract the latest version of CurlFtpFs <a href="http://curlftpfs.sourceforge.net/">here</a>.</li>
<li>Configure: <i>./configure</i></li>
<li>Compile: <i>make</i></li>
<li>Install: <i>make install</i></li>
</ul>
<p>So it&#39;s done. Mounting procedure is as followed:</p>
<ul>
<li>mkdir MountPoint (eg: <i>mkdir /backup</i>)</li>
<li>curlftpfs -o user=USERNAME:PASSWORD ftp://FTPHost/ MountPoint/<br />
(eg: <i>curlftpfs -o user=testusr:mypass ftp://127.0.0.1/ /backup/</i>)</li>
</ul>
<p>Done. Now that FUSE is installed, here are some other interesting filesystems available under FUSE:</p>
<ul>
<li><a href="http://www.ricardis.tudelft.nl/~vincent/fusesmb/">SMB for FUSE</a></li>
<li><a href="http://richard.jones.name/google-hacks/gmail-filesystem/gmail-filesystem.html">GmailFS</a></li>
<li><a href="http://sourceforge.net/projects/cvsfs">CvsFS</a></li>
<li><a href="http://wayback.sourceforge.net/">User-level Versioning File System</a></li>
<li><a href="http://fuse.sourceforge.net/sshfs.html">SshFS</a></li>
<li><a href="http://btslave.sourceforge.net/">BitTorrent File System</a></li>
<li><a href="http://wikipediafs.sourceforge.net/">WikipediaFS</a></li>
<li><a href="http://flickrfs.sourceforge.net/">Flickrfs</a></li>
<li><a href="http://rohanpm.net/blogfs">BlogFS</a></li>
<li><a href="http://reboot.animeirc.de/cryptofs/">CryptoFS</a></li>
</ul>
<p>I was trying to get Flickrfs working has no success at the authentication part where I need to authorize the Flickr API to access my Flickr photos. If you succeed, please tell me how.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.tarotoast.com/2006/04/02/242/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>How to prepare your site for Digg Effect (Diggstruction)</title>
		<link>http://blog.tarotoast.com/2006/03/19/233/#utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=how-to-prepare-your-site-for-digg-effect</link>
		<comments>http://blog.tarotoast.com/2006/03/19/233/#comments</comments>
		<pubDate>Sun, 19 Mar 2006 22:45:15 +0000</pubDate>
		<dc:creator>tarotoast</dc:creator>
				<category><![CDATA[IT]]></category>
		<category><![CDATA[Internet]]></category>
		<category><![CDATA[Server Diary]]></category>

		<guid isPermaLink="false">http://blog.tarotoast.com/2006/03/19/233/</guid>
		<description><![CDATA[When a site was dugg to the front page of Digg, the amount of requests to the server will usually take down small sites running on relatively low end hardwares (small RAM, slow CPU, HDD). To prevent this from happening to your site (specifically, WP blogs), there are things you can do to maximize what [...]]]></description>
			<content:encoded><![CDATA[<p><img align="right" alt="No more database error due to too many connections." id="image234" title="No more database error due to too many connections." src="http://blog.tarotoast.com/wp-content/uploads/2006/03/wp-dberror.png" />When a site was dugg to the front page of Digg, the amount of requests to the server will usually take down small sites running on relatively low end hardwares (small RAM, slow CPU, HDD). To prevent this from happening to your site (specifically, WP blogs), there are things you can do to maximize what low end hardwares can manage, and therefore prevent the Digg Effect.</p>
<p>From <a href="http://digg.com/links/Firefox_-_living_version">last experiment</a>, I am <a href="http://blog.tarotoast.com/2006/03/05/224/">very aware</a> this $69/mo (now $99/mo) 1&#038;1 Dedicated Root Server with 2.0Ghz Celeron, 512MB RAM and 40GB HDD cannot take on Digg Effect without doing some tweaking. Here are the measures I&#8217;ve gathered:</p>
<p><strong>1) Cache it: <a href="http://mnm.uib.es/gallir/wp-cache-2/">WP-Cache 2.0</a> </strong></p>
<p>A very-easy-to-install-and-use plugin. By creating cached pages, it reduce the php code parsed by the web server, and also eliminate the query to mysql database. Both speeds up the page load dramatically.</p>
<p>You can test to see the difference by doing very simple test, this is what I get:</p>
<p>Without cache:</p>
<p><em>time wget http://blog.tarotoast.com/</em><br />
>> 0.005u 0.007s <strong>0:01.36</strong> 0.0%      0+0k 0+0io 0pf+0w</p>
<p>With cache:</p>
<p><em>time wget http://blog.tarotoast.com/</em><br />
>> 0.003u 0.012s <strong>0:00.02</strong> 50.0%     0+0k 0+0io 0pf+0w</p>
<p>I don&#8217;t really know what all numbers mean, but I know the time for the request is reduce from 1.36 second to .02 second. Keep in mind, however, counter plugins (like <a href="http://andersdrengen.dk/projects/counterize/">Counterize</a>) will not count requests for cached pages (so you don&#8217;t feel as good).</p>
<p><strong>2) Apache 2: <a href="http://httpd.apache.org/docs/2.0/mod/worker.html">MPM Worker</a></strong></p>
<p>Taken directly from Apache&#8217;s website:</p>
<blockquote><p>This Multi-Processing Module (MPM) implements a hybrid multi-process multi-threaded server. By using threads to serve requests, it is able to serve a large number of requests with less system resources than a process-based server. Yet it retains much of the stability of a process-based server by keeping multiple processes available, each with many threads.</p></blockquote>
<p>In order to use the php module, you need to compile it with thread safety.</p>
<p><strong>3) Stress Test with <a href="http://httpd.apache.org/docs/2.0/programs/ab.html">ab</a></strong></p>
<p>ab stands for Apache Benchmarking</p>
<blockquote><p><em>ab -n 100 -c 100 -d http://URL</em></p></blockquote>
<p>This will give you an idea how your webserver can handle traffic.</p>
<p>*Warning: set the number small and increase it slowly.</p>
<p><strong>4) Additional Tweakings</strong></p>
<ul>
<li><a href="http://www.howtoforge.com/configuring_apache_for_maximum_performance">Configuring Apache for Maximum Performance</a>: easy to read article giving a lot of tips in configuring your apache server.</li>
<li><a href="http://eaccelerator.net/">eAccelerator</a>: cache php pages at compiled level, which means your php codes will stil be executed. Much faster than no cache at all.</li>
</ul>
<p><a href="http://digg.com/software/How_to_prepare_your_site_for_Digg_Effect">Digg</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.tarotoast.com/2006/03/19/233/feed/</wfw:commentRss>
		<slash:comments>56</slash:comments>
		</item>
	</channel>
</rss>
