<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="wordpress/2.1" -->
<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/"
	>

<channel>
	<title>Taoyuan Nights</title>
	<link>http://www.taoyuan-nights.com</link>
	<description>... Life in Taoyuan, Taiwan.</description>
	<pubDate>Mon, 17 Nov 2008 16:30:19 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.1</generator>
	<language>en</language>
			<item>
		<title>A cute, kludgey coding trick.</title>
		<link>http://www.taoyuan-nights.com/archives/240</link>
		<comments>http://www.taoyuan-nights.com/archives/240#comments</comments>
		<pubDate>Tue, 04 Nov 2008 13:50:46 +0000</pubDate>
		<dc:creator>Mu</dc:creator>
		
		<category><![CDATA[Random]]></category>

		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.taoyuan-nights.com/archives/240</guid>
		<description><![CDATA[Today, a student told me she had to run a series of tests on pictures, with particular filenames&#8230; for example, files numbered 13, 17, 21, 23, and so on.
So, I explained that in BASH, we can do this quite easily:
for i in 13 17 21 23 ; do
commandname   $i
done
However, she explained that each [...]]]></description>
			<content:encoded><![CDATA[<p>Today, a student told me she had to run a series of tests on pictures, with particular filenames&#8230; for example, files numbered 13, 17, 21, 23, and so on.</p>
<p>So, I explained that in BASH, we can do this quite easily:</p>
<p><PRE>for i in 13 17 21 23 ; do<br />
commandname   $i<br />
done</PRE></p>
<p>However, she explained that each of these pictures has a corresponding data value that has to be entered, and that doesn&#8217;t relate to the picture directly. For example, 13 might have the value 93, 17 might have the value 90, 21 might have the value 99 and so on. We need to enter these tuples in order to write the script.</p>
<p>Now, you could set up some list, and iterate through it, but it&#8217;s a nightmare if you want to add or delete a value, because you need to make sure your two lists don&#8217;t accidentally get out of sync as you add or remove numbers from them. </p>
<p>Unlike PERL, I don&#8217;t believe BASH has sufficiently complex data types that you could pass (13,93) as a single value. So&#8230; here&#8217;s a quick and ugly way to do this in a single loop without using a more complex datatype. </p>
<p><PRE>for i in 1393 1790 2199 2389 ; do<br />
$a=$((i/100))<br />
$b=$((i%100))<br />
commandname  $a $b<br />
done</PRE></p>
<p>In a situation where names are needed rather than numbers, you could use  &#8220;firstpart-lastpart&#8221; style items in the for loop declaration, and then use the regular expression features built into BASH to split it apart as you iterate.</p>
<p>So, what&#8217;s the advantage of doing things this way? It&#8217;s easy to remember and you can code it in about 5 seconds flat. </p>
<p>The disadvantages? Read an article about <I><a href="http://en.wikipedia.org/wiki/Strongly-typed_programming_language">Strong typing</a></I>!</p>
	<hr noshade style="margin:0;height:1px" />
	  <a href="http://www.taoyuan-nights.com/archives/240">Permalink</a> |
	  <a href="http://del.icio.us/post?url=http://www.taoyuan-nights.com/archives/240&amp;title=A cute, kludgey coding trick.">Add to del.icio.us</a> | 
	  <a href="http://www.taoyuan-nights.com">Click here to visit Taoyuan Nights for more articles like this.</a>
	  <BR>]]></content:encoded>
			<wfw:commentRss>http://www.taoyuan-nights.com/archives/240/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Sharing email between two (or more) places with IMAP.</title>
		<link>http://www.taoyuan-nights.com/archives/186</link>
		<comments>http://www.taoyuan-nights.com/archives/186#comments</comments>
		<pubDate>Sun, 22 Jul 2007 15:21:37 +0000</pubDate>
		<dc:creator>Mu</dc:creator>
		
		<category><![CDATA[Science, Tech, Health]]></category>

		<category><![CDATA[Random]]></category>

		<category><![CDATA[Programming]]></category>

		<category><![CDATA[Survival]]></category>

		<guid isPermaLink="false">http://www.taoyuan-nights.com/archives/186</guid>
		<description><![CDATA[Do you ever find yourself wanting to access your email from both home and the office - but at the same time, hating the crappy webmail client that seems like the only way of doing it? In fact, there is a much nicer solution than &#8216;POP3&#8242; email (outlook express), or webmail, which surprisingly few people [...]]]></description>
			<content:encoded><![CDATA[<p>Do you ever find yourself wanting to access your email from both home and the office - but at the same time, hating the crappy webmail client that seems like the only way of doing it? In fact, there is a much nicer solution than &#8216;POP3&#8242; email (outlook express), or webmail, which surprisingly few people seem to know about. It&#8217;s called IMAP. However, I should probably begin by describing how POP3 and webmail work. </p>
<p><UL> <LI> <B> POP3, the Post Office Protocol</B>, is an old technology for email which is based on the idea of &#8216;visiting the postoffice&#8217; to collect your mail. A POP3 server is a computer program that is always available on the internet, and which gradually stores up a collection of emails for you as they arrive. A bit like the business &#8216;PO box&#8217; service still provided by many post offices in real life. </p>
<p>Every now and then, your computer at home connects to the POP3 server and says &#8216;Have I got any new mail?&#8217;. The POP3 server then sends through a photocopy of the emails it has received, and (optionally) clears out the folder. That means your computer becomes the new home for all your emails. After all, who stores their postal mail at the postoffice? </p>
<p>There are a few problems with this. First of all, it&#8217;s just a single giant box for new emails. You can&#8217;t put anything in it yourself (unless you send yourself an email); and you can&#8217;t organise your emails into different types or put them into different folders. It&#8217;s simply an &#8216;always-available&#8217; dumping ground for email, so that you can receive email even when your home computer isn&#8217;t turned on.</p>
<p>Also, you can&#8217;t store your sent-mail in your POP3 inbox. There are ways round this; you can always send a duplicate copy of outgoing mail to a second POP3 inbox, but that can get a little bit confusing, especially if you send things from different identities, i.e. your official &#8216;office&#8217; persona, your &#8216;home&#8217; persona, and your wacky &#8216;World of Warcraft&#8217; persona. </p>
<p>Finally, it&#8217;s annoying to share email between several computers using POP3. You can&#8217;t always be sure that both computers have the same emails downloaded. Imagine I go to the office, collect my email, and delete some spam. By the time I go home, I realise I left the computer on at home, and it also downloaded a copy of the spams, but now they&#8217;re not deleted! </p>
<p>Or, maybe I organise my emails neatly into a folder. The problem is, on the office computer the emails are neatly organised into a folder, but at home they&#8217;re still sitting in my main INBOX, making a mess! Argh! If only you could easily keep things organised and up-to-date, across all of your computers&#8230; </LI></p>
<p><LI> <B>Webmail</B> was introduced as a way of overcoming this problem, as well as the problem of accessing email from a temporary location such as an internet cafe where you can&#8217;t install your own programs. By storing both your &#8216;email program&#8217; and &#8216;email archives&#8217; on a web server, all you need is a web browser to access your mail from any location. The problem now is simply that the interface is limited, in terms of speed and &#8216;niceness&#8217;, by the limits of web browsers. Also, usually, webmail is not very well integrated with your home computer. By this, I mean that you can&#8217;t simply drag and drop files to and from emails in your webmail. Instead, you have to take a few extra clicks to save them. But webmail at least offers a standardised way of accessing your email from two or more places. </LI><br />
</UL></p>
<p>The third option that most people don&#8217;t know about is <B>IMAP</B>. IMAP was designed as a technology to make it easy to share your emails between different locations, and it is built into most modern email programs. It stores your emails on a centralised server, but in a way that is accessed a little like a POP3 mailbox rather than webmail. However, now you can seperate your mailbox into folders, and you can store your sent emails, all in the same inbox, and all with a single password. In fact, a set of IMAP folders in Outlook (or any other mail program) can be accessed exactly like a set of mail folders stored on your local computer. </p>
<p>This is remarkably handy. It means you can have an organised system for emails and files, shared between two or more places, but with a nice, fast  graphical interface (Mail.app, Outlook Express). In practice, to make it run quickly, email is &#8216;cached&#8217; on your home computer. In other words, a spare copy is sent to your computer from the IMAP server, so you can read your email even when your computer is not connected to the internet. But, the &#8216;official copy&#8217; is stored on the IMAP server. That way, if you delete an email from your office, it&#8217;s also deleted when you log into email from home. If you organise your email on your office computer, then when you get home, the emails there have been automatically re-organised too, to match your office.</p>
<p>IMAP has a few other nice features that people don&#8217;t always notice. For example, instead of having to check your email every few minutes (we call this a <I>pull</I> technology in computing), IMAP contacts your computer to say &#8216;hey, I&#8217;ve got something new for you!&#8217; (you guessed it - <I>push</I> technology). This means more work for the email server, but from your perspective, it means your emails always arrive instantly. Brilliant!</p>
<p>After setting up your new IMAP account (exactly like setting up POP3 - just enter the details in the IMAP section), you may want to make sure you&#8217;re not shouting everything to the world, everytime you send an email. By enabling &#8217;secure/SSL SMTP&#8217; and &#8217;secure/SSL IMAP&#8217; in your email program, you can be sure that both your outgoing and incoming email is communicated securely in a way that no-one else can read. Perfect!</p>
<p>Since I centralised my own email system on secure IMAP/SMTP, life has been so much easier! I use <A HREF="http://www.asmallorange.com">ASO</A> who can provide about 75MB of space for around $25 US per year. This is overkill for most people&#8217;s needs; though 400MB is available for just a few dollars more. ASO, incidentally, are by far and away the most impressive webhosting/emailhosting company I&#8217;ve had the pleasure of dealing with in the last 10 years. Great prices, great services, great customer service. You think this sounds like an ad? So be it - they deserve a free ad! :)</p>
<p>I can even use my email system as a way of storing files I want to access from both the office and my home. I find it&#8217;s very convenient, since I can drag and drop things quickly in my email program, and by paying for a decent-quality internet account with ASO, I get super fast email, too. </p>
<p>My email client is <I>mail.app</I>, the default mail program on the Apple mac, which has incredibly powerful email searching and organising features thanks to a technology called &#8220;Spotlight&#8221; on the Apple mac. On a Windows computer, <I>Thunderbird</I> is a really nice free program that seems more reliable than Outlook Express.</p>
<p>Anyway, in summary: if your POP3 email is always a mess; or if you&#8217;re using a webmail system, but deep down, you hate it; then consider using secure IMAP as an easy, fast, and secure way of organising and sharing your emails between several locations. It&#8217;s great!</p>
	<hr noshade style="margin:0;height:1px" />
	  <a href="http://www.taoyuan-nights.com/archives/186">Permalink</a> |
	  <a href="http://del.icio.us/post?url=http://www.taoyuan-nights.com/archives/186&amp;title=Sharing email between two (or more) places with IMAP.">Add to del.icio.us</a> | 
	  <a href="http://www.taoyuan-nights.com">Click here to visit Taoyuan Nights for more articles like this.</a>
	  <BR>]]></content:encoded>
			<wfw:commentRss>http://www.taoyuan-nights.com/archives/186/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Thanks for the memory&#8230;</title>
		<link>http://www.taoyuan-nights.com/archives/148</link>
		<comments>http://www.taoyuan-nights.com/archives/148#comments</comments>
		<pubDate>Mon, 26 Mar 2007 00:17:10 +0000</pubDate>
		<dc:creator>Mu</dc:creator>
		
		<category><![CDATA[Science, Tech, Health]]></category>

		<category><![CDATA[Random]]></category>

		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.taoyuan-nights.com/archives/148</guid>
		<description><![CDATA[Memory is what tells a man that his wife&#8217;s birthday was yesterday.
~Mario Rocco

In fact, the type of memory I&#8217;m thinking of just now is computer memory. In the last 2 months, the price of DRAM chips has more than halved. I hadn&#8217;t noticed, since I haven&#8217;t been particularly looking to upgrade my computer, but this [...]]]></description>
			<content:encoded><![CDATA[<p><I>Memory is what tells a man that his wife&#8217;s birthday was yesterday.<br />
~Mario Rocco<br />
</I></p>
<p>In fact, the type of memory I&#8217;m thinking of just now is computer memory. In the last 2 months, the price of DRAM chips has more than halved. I hadn&#8217;t noticed, since I haven&#8217;t been particularly looking to upgrade my computer, but this means it&#8217;s now an excellent time to make your computer that bit faster under Macos or Windows.</p>
<p>Usually, the price of memory follows a predictable curve. It starts out very high, and continually falls towards a quarter or even a tenth of its original price over a year or two. After hovering at the same low price for 6 months, prices rise again, as supply is cut off, when new memory technologies begin to be produced in the DRAM factories. </p>
<p>To be honest, there is hardly any reason to have less than 2GB of memory in your desktop or laptop at present prices. It will have an incredible impact on system performance, especially if you leave your computer on, or in sleep mode, instead of restarting.</p>
<p>One of the best sources for computer memory is &#8220;Crucial&#8221; in the US. They have a fantastic track record for distributing very high quality memory, direct from the manufacturer Micron. High quality memory is important; a large percentage of unreliability found in computers, comes from having unreliable memory. Just one &#8216;bit&#8217; that doesn&#8217;t work correctly can ruin the stability of the whole machine, since computing is a very precise science.</p>
<p>If you&#8217;re scared of choosing the right sort of memory for your computer, Crucial also offer a &#8216;memory selector&#8217; which chooses the right type of memory for your computer or motherboard. I strongly recommend using this, to avoid incompatibility problems. You can find Crucial&#8217;s online stores in the <a href="http://www.crucial.com/">US</a>, <a href="http://www.crucial.com/eu/">EU</a> and <a href="http://www.crucial.com/uk/">UK</a>. Shoppers in Asia should use the US store.</p>
<p>As with most international retailers, beware of buying from the UK store. The $ to £ conversion rate is often unrepresentative of the real foreign exchange rate. Price drops usually hit the US long before they hit the UK, too. </p>
<p>2GB of DDR2, 667Mhz suitable for a MacBook is currently $145.99 at the US site.<br />
1GB of DDR2, 667Mhz suitable for a MacBook is currently $73.99 at the US site.<br />
These prices are as of 26 March 2007. In late January, 2GB was around $300.</p>
<p>You can also buy memory more cheaply (but of lower average quality) at <a href="http://www.newegg.com/">NewEgg.com</a>. However, I don&#8217;t recommend doing that.</p>
<p><I>(When buying memory for an Apple computer, or any laptop with an Intel motherboard, be sure to get a pair of &#8216;matching&#8217; DIMMs. Memory access can double in speed for certain uses, if the timing to both chips is the same. In general this is a good policy for ensuring a stable, reliable computer anyway).</I></p>
	<hr noshade style="margin:0;height:1px" />
	  <a href="http://www.taoyuan-nights.com/archives/148">Permalink</a> |
	  <a href="http://del.icio.us/post?url=http://www.taoyuan-nights.com/archives/148&amp;title=Thanks for the memory...">Add to del.icio.us</a> | 
	  <a href="http://www.taoyuan-nights.com">Click here to visit Taoyuan Nights for more articles like this.</a>
	  <BR>]]></content:encoded>
			<wfw:commentRss>http://www.taoyuan-nights.com/archives/148/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
