<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>Polymath Programmer</title>
	
	<link>http://polymathprogrammer.com</link>
	<description>Mathematics. Programming. Entrepreneurship.</description>
	<lastBuildDate>Fri, 03 Feb 2012 13:34:36 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/PolymathProgrammer" /><feedburner:info uri="polymathprogrammer" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
		<title>Prepaid Postpaid Convergence</title>
		<link>http://feedproxy.google.com/~r/PolymathProgrammer/~3/bLSAs20Xjvk/</link>
		<comments>http://polymathprogrammer.com/2012/02/03/prepaid-postpaid-convergence/#comments</comments>
		<pubDate>Fri, 03 Feb 2012 13:34:36 +0000</pubDate>
		<dc:creator>Vincent</dc:creator>
				<category><![CDATA[Curiosita]]></category>
		<category><![CDATA[business]]></category>
		<category><![CDATA[convergence]]></category>
		<category><![CDATA[payment]]></category>
		<category><![CDATA[postpaid]]></category>
		<category><![CDATA[prepaid]]></category>

		<guid isPermaLink="false">http://polymathprogrammer.com/?p=3358</guid>
		<description><![CDATA[What&#8217;s one of the most important concerns of any business? Getting paid. What&#8217;s the next most important concern of any business? Getting paid on time. There&#8217;s this concept called the &#8220;prepaid postpaid convergence&#8221;, which hailed from the telecommunications industry (where I spent the majority of my professional life in). You&#8217;re probably on a postpaid mobile [...]]]></description>
			<content:encoded><![CDATA[<p>What&#8217;s one of the most important concerns of any business? Getting paid.</p>
<p>What&#8217;s the next most important concern of any business? Getting paid <em>on time</em>.</p>
<p>There&#8217;s this concept called the &#8220;prepaid postpaid convergence&#8221;, which hailed from the telecommunications industry (where I spent the majority of my professional life in). You&#8217;re probably on a postpaid mobile phone plan, where you&#8217;re charged for what you used in the previous month. Or you might be on a prepaid plan, where you dump a bunch of cash into your plan/phone/card/thingy and you can text and call until your money runs out.</p>
<p>This is a particular problem in the telecommunications industry because billing customers is challenging. It&#8217;s difficult to bill in one generic way to handle both prepaid and postpaid charges.</p>
<p>Think of it this way. I could dump $50 into my prepaid card and not use my phone for 6 months. But for 6 months, the company has to keep track of that $50. The worst thing is, depending on the billing requirements and laws in the country, the company may not include that $50 as &#8220;revenue earned&#8221;. The company can only include any monetary amount after I used some of that prepaid cash. Say I used $11.25, then the company &#8220;earned&#8221; $11.25 (even though I&#8217;ve paid $50 upfront).</p>
<p>Prepaid billed amounts are &#8220;future money&#8221;. Postpaid billed amounts are &#8220;past money&#8221;.</p>
<p>There are 3 general payment modes:</p>
<ul>
<li>You used a product/service but haven&#8217;t paid yet.</li>
<li>You pay at the point of usage.</li>
<li>You pay first, but haven&#8217;t used the product/service.</li>
</ul>
<p>The timing is important. For the purposes of this article, we won&#8217;t be strict about the point of usage and point of payment. In some restaurants, you get to eat first before you pay. I will consider that as &#8220;payment at the point of usage&#8221;, unless you intend to get a free meal and bolt the moment you get a chance to.</p>
<p>So why is this important to you?</p>
<h3>The business models are different</h3>
<p>Let&#8217;s consider the Apple App Store. You find an app you like. You purchase it. 2 business models come into play.</p>
<p>First, Apple charges you <em>immediately</em> on your credit card. You pay immediately upon purchasing the app. Apple gets the $0.99 from the credit card company, and can report that $0.99 on their profit/revenue report.</p>
<p>Second, the credit card company bills you the next month, including that $0.99 app you bought. You&#8217;ve enjoyed using the app first, before actually paying for it.</p>
<p>Apple and the credit card company have 2 different business models, even though the &#8220;product&#8221; is the same. (technically, the credit card company isn&#8217;t selling the app, they&#8217;re selling you the service of having a credit card, but to you it&#8217;s the same thing)</p>
<p>Web hosting companies use the prepaid model (that I know of). They may charge you for 3 years worth of hosting your website. You pay for 3 years first, then you get to have your website hosted. Even if you decide to cancel after 6 months, and you might get a 2.5 year refund back (depending on whether the web hosting company has this policy. Please check), but you still had to have paid for 3 years upfront.</p>
<p>I&#8217;m assuming you&#8217;re a developer. The trend is that the Internet is going to be a big thing. Let&#8217;s say you&#8217;re a startup founder. Choose your business model wisely, because it&#8217;s going to be hard to change it.</p>
<p>The Amazon S3 service lets you store stuff. You pay for what you use (the more data transfers made, the more you pay). This is postpaid.</p>
<p>iStockphoto lets you buy credits which you can then use to buy images. You pay first (in a large lump sum) then you buy images with the credits (that were bought with cash). This is prepaid.</p>
<h3>Prepaid has this annoying thing&#8230;</h3>
<p>It&#8217;s called &#8220;keeping track&#8221;.</p>
<p>Let&#8217;s say a text message costs $0.10, and you bought a prepaid card for $10. That means you can make 100 text messages.</p>
<p>A postpaid customer will be billed $0.70 for the 7 messages she sent in the last month. She will also be billed $1.00 for the 10 messages she sent this month (in the next month).</p>
<p>You on the other hand, won&#8217;t be billed. Because you already paid $10. Theoretically, you could hold onto that $10 value in your phone card for eternity. Depending on the billing requirements, the telecommunications company might include that $10 as revenue. But since you haven&#8217;t actually sent any text messages (or phone calls), it&#8217;s kinda shady since the company hasn&#8217;t rendered any services to you yet they &#8220;earned&#8221; $10 for nothing. In any case, you&#8217;ve paid $10 for nothing (since you didn&#8217;t use it).</p>
<p>The worst part is the telecommunications company has to store that $10 as a line entry in a database somewhere. And without any corresponding entries to &#8220;deduct&#8221; that amount. That database entry will stay there forever without resolution. The telecommunications company now officially hates you.</p>
<p>This is why most prepaid items have an expiry date, even if they&#8217;re virtual products and won&#8217;t decay over time. For example, iStockphoto credits last 1 year. Vouchers from movie theatres, supermarkets, restaurants also typically have a 1 year expiry date. They&#8217;re vouchers, it&#8217;s not like they&#8217;re going to wither away. But companies need to keep track of them.</p>
<p>When the prepaid items expire, the companies can then include the value of the items into revenue, because the customer at that point can no longer use the item, hence it&#8217;s taken as the customer had already used it.</p>
<p>Imagine you have to write a program and design a database to support the prepaid billing structure. Your program has to keep track of anything the prepaid customer does, and deduct the corresponding amount from the stored value in a database. Every single text message and phone call the customer makes, the program has to go check if there&#8217;s enough in customer&#8217;s stored value. Technically, there&#8217;s a switchboard that bars the customer from making a text message or phone call <em>before</em> the text message or phone call can be made (that&#8217;s the hardware check). Then your program breathes a sigh of relief when the stored value is gone or expired&#8230; And then the customer tops up his stored value with $50. Your program grows an unreasonable hatred for this customer.</p>
<h3>Final thoughts</h3>
<p>A postpaid model requires you to trust that the customer will pay you. A prepaid model lets you get money first, but keeping track might pose a small challenge.</p>
<p>With the Internet being real-time, the better model for online products and services is the &#8220;pay immediately&#8221; model. You don&#8217;t have to keep track of inventory (if at all) and you get the money immediately to your bottom line.</p>
<p>I know there&#8217;s also the subscription model. But do you charge customers for the month they haven&#8217;t yet used, or for the month they&#8217;ve already used?</p>
<p>I&#8217;m pretty sure I left something out, or haven&#8217;t explained something properly, so leave a comment or send me an email.</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/PolymathProgrammer?a=bLSAs20Xjvk:4bOBuKtcHHk:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/PolymathProgrammer?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/PolymathProgrammer?a=bLSAs20Xjvk:4bOBuKtcHHk:I9og5sOYxJI"><img src="http://feeds.feedburner.com/~ff/PolymathProgrammer?d=I9og5sOYxJI" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/PolymathProgrammer?a=bLSAs20Xjvk:4bOBuKtcHHk:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/PolymathProgrammer?d=qj6IDK7rITs" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/PolymathProgrammer/~4/bLSAs20Xjvk" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://polymathprogrammer.com/2012/02/03/prepaid-postpaid-convergence/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://polymathprogrammer.com/2012/02/03/prepaid-postpaid-convergence/</feedburner:origLink></item>
		<item>
		<title>Image rotation with bilinear interpolation and alpha progressive borders</title>
		<link>http://feedproxy.google.com/~r/PolymathProgrammer/~3/du0DkXS7mbI/</link>
		<comments>http://polymathprogrammer.com/2012/02/02/image-rotation-bilinear-interpolation-alpha-progressive-borders/#comments</comments>
		<pubDate>Thu, 02 Feb 2012 14:10:02 +0000</pubDate>
		<dc:creator>Vincent</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[alpha]]></category>
		<category><![CDATA[bilinear interpolation]]></category>
		<category><![CDATA[border]]></category>
		<category><![CDATA[edge pixel]]></category>
		<category><![CDATA[image rotation]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[progressive]]></category>

		<guid isPermaLink="false">http://polymathprogrammer.com/?p=3350</guid>
		<description><![CDATA[So a blog reader, Fabien Auréjac, emailed me an improvement over the code I posted on image rotation. Here&#8217;s the one with bilinear interpolation, and here&#8217;s the one with bilinear interpolation and no clipping. Fabien translated the core of my code into PHP. The improvement was on assigning alpha values to the edge pixels after [...]]]></description>
			<content:encoded><![CDATA[<p>So a blog reader, Fabien Auréjac, emailed me an improvement over the code I posted on image rotation. Here&#8217;s <a href="http://polymathprogrammer.com/2008/10/06/image-rotation-with-bilinear-interpolation/">the one with bilinear interpolation</a>, and here&#8217;s <a href="http://polymathprogrammer.com/2010/04/05/image-rotation-with-bilinear-interpolation-and-no-clipping/">the one with bilinear interpolation and no clipping</a>.</p>
<p>Fabien translated the core of my code into PHP. The improvement was on assigning alpha values to the edge pixels after rotation. Edge pixels are pixels beside the &#8220;blank&#8221; pixels (I used black in my code, for instance). The alpha values mean the edge pixels are &#8220;softer&#8221; and thus the resulting image looks smoother.</p>
<p>I suppose if you really want to, you could also &#8220;dumb down&#8221; the values of the red, green and blue colour components for more softening (in addition to the alpha component). I say &#8220;dumb down&#8221; because the blank pixels I used are black (meaning zero for the RGB values). You&#8217;re free to go ahead and do more interpolation.</p>
<p>Fabien has given permission for me to post the code here. I&#8217;ll leave it as an exercise for you to translate to your programming language.</p>
<div class="codediv">
<pre>
$distOmbre=3;
$flouOmbre=4;
$angleRot=60;
$img=imagecreatefromjpeg("media/diapo-Chinon.jpg");
$size=getimagesize("media/diapo-Chinon.jpg");
$LsupH=($size[0]&gt;$size[1])?1:0;
$angleBool=(int)($angleRot/90)%2==0?0:1;
if (($angleBool+$LsupH)%2==0) {
	$largeur=round(abs($size[0]*sin($angleRot%90*pi()/180))+abs($size[1]*sin((90-$angleRot%90)*pi()/180)));
	$hauteur=round(abs($size[0]*cos($angleRot%90*pi()/180))+abs($size[1]*cos((90-$angleRot%90)*pi()/180)));
} else {
	$largeur=round(abs($size[0]*cos($angleRot%90*pi()/180))+abs($size[1]*cos((90-$angleRot%90)*pi()/180)));
	$hauteur=round(abs($size[0]*sin($angleRot%90*pi()/180))+abs($size[1]*sin((90-$angleRot%90)*pi()/180)));
}
$largeur+=$distOmbre+$flouOmbre*2;
$hauteur+=$distOmbre+$flouOmbre*2;
$angleRot*=pi()/180;
$imgRot=imagecreatetruecolor($largeur, $hauteur);
imagealphablending($imgRot, true);
imageantialias($imgRot, true);
for ($i=0; $i&lt;$hauteur; $i++) {
	for ($j=0; $j&lt;$largeur; $j++) {
		// convert raster to Cartesian
        $x = $j - $largeur*0.5;
        $y = $hauteur*0.5 - $i;

        // convert Cartesian to polar
        $fDistance = sqrt($x * $x + $y * $y);
   	 	$fPolarAngle = atan2($y, $x);

        // the crucial rotation part
        // "reverse" rotate, so minus instead of plus
        $fPolarAngle -= $angleRot;
		 // convert polar to Cartesian
        $fTrueX = $fDistance * cos($fPolarAngle);
        $fTrueY = $fDistance * sin($fPolarAngle);

        // convert Cartesian to raster
        $fTrueX = $fTrueX + $size[0]*0.5;
        $fTrueY = $size[1]*0.5 - $fTrueY;

        $iFloorX = (int)(floor($fTrueX));
        $iFloorY = (int)(floor($fTrueY));
        $iCeilingX = (int)(ceil($fTrueX));
        $iCeilingY = (int)(ceil($fTrueY));
        //echo $fTrueX." ".$fTrueY." ".$iFloorX." ".$iCeilingX." ".$iFloorY." ".$iCeilingY."&lt;br&gt;";
		if ($iFloorX &gt;= 0 &#038;&#038; $iCeilingX &gt;= 0 &#038;&#038; $iFloorX &lt; $size[0] &#038;&#038; $iCeilingX &lt; $size[0] &#038;&#038; $iFloorY &gt;= 0 &#038;&#038; $iCeilingY &gt;= 0 &#038;&#038; $iFloorY &lt; $size[1] &#038;&#038; $iCeilingY &lt; $size[1]) {
			$fDeltaX = $fTrueX - $iFloorX;
			$fDeltaY = $fTrueY - $iFloorY;
			$clrTopLeft = imagecolorat($img, $iFloorX, $iFloorY);
			$colorsTopLeft = imagecolorsforindex($img, $clrTopLeft);
			$clrTopRight = imagecolorat($img, $iCeilingX, $iFloorY);
			$colorsTopRight = imagecolorsforindex($img, $clrTopRight);
			$clrBottomLeft = imagecolorat($img, $iFloorX, $iCeilingY);
			$colorsBottomLeft = imagecolorsforindex($img, $clrBottomLeft);
			$clrBottomRight = imagecolorat($img, $iCeilingX, $iCeilingY);
			$colorsBottomRight = imagecolorsforindex($img, $clrBottomRight);
			// linearly interpolate horizontally between top neighbours
			$fTopRed = (1 - $fDeltaX) * $colorsTopLeft['red'] + $fDeltaX * $colorsTopRight['red'];
			$fTopGreen = (1 - $fDeltaX) * $colorsTopLeft['green'] + $fDeltaX * $colorsTopRight['green'];
			$fTopBlue = (1 - $fDeltaX) * $colorsTopLeft['blue'] + $fDeltaX * $colorsTopRight['blue'];
			// linearly interpolate horizontally between bottom neighbours
			$fBottomRed = (1 - $fDeltaX) * $colorsBottomLeft['red'] + $fDeltaX * $colorsBottomRight['red'];
			$fBottomGreen = (1 - $fDeltaX) * $colorsBottomLeft['green'] + $fDeltaX * $colorsBottomRight['green'];
			$fBottomBlue = (1 - $fDeltaX) * $colorsBottomLeft['blue'] + $fDeltaX * $colorsBottomRight['blue'];
			// linearly interpolate vertically between top and bottom interpolated results
			$iRed = (int)(round((1 - $fDeltaY) * $fTopRed + $fDeltaY * $fBottomRed));
			$iGreen = (int)(round((1 - $fDeltaY) * $fTopGreen + $fDeltaY * $fBottomGreen));
			$iBlue = (int)(round((1 - $fDeltaY) * $fTopBlue + $fDeltaY * $fBottomBlue));
			// make sure colour values are valid
			if ($iRed &lt; 0) $iRed = 0;
			if ($iRed &gt; 255) $iRed = 255;
			if ($iGreen &lt; 0) $iGreen = 0;
			if ($iGreen &gt; 255) $iGreen = 255;
			if ($iBlue &lt; 0) $iBlue = 0;
			if ($iBlue &gt; 255) $iBlue = 255;
			if ($iFloorX &gt; 0 &#038;&#038; $iCeilingX &gt; 0 &#038;&#038; $iFloorX &lt; $size[0]-1 &#038;&#038; $iCeilingX &lt; $size[0]-1 &#038;&#038; $iFloorY &gt; 0 &#038;&#038; $iCeilingY &gt; 0 &#038;&#038; $iFloorY &lt; $size[1]-1 &#038;&#038; $iCeilingY &lt; $size[1]-1) {
				$colorallocation=imagecolorallocate($imgRot, $iRed, $iGreen, $iBlue);
				imagesetpixel($imgRot, $j, $i, $colorallocation);
			} else if ($iFloorX == 0 &#038;&#038; $iFloorY &gt;= 0 &#038;&#038; $iCeilingY &gt;= 0 &#038;&#038; $iFloorY &lt; $size[1] &#038;&#038; $iCeilingY &lt; $size[1]) {//left
				$alpha=round((1-abs($fDeltaX))*127);
				$colorallocation=imagecolorallocatealpha($imgRot, $iRed, $iGreen, $iBlue, $alpha);
				imagesetpixel($imgRot, $j, $i, $colorallocation);
			} else if ($iFloorX &gt;= 0 &#038;&#038; $iCeilingX &gt;= 0 &#038;&#038; $iFloorX &lt; $size[0] &#038;&#038; $iCeilingX &lt; $size[0] &#038;&#038; $iFloorY == 0) {//top
				$alpha=round((1-abs($fDeltaY))*127);
				$colorallocation=imagecolorallocatealpha($imgRot, $iRed, $iGreen, $iBlue, $alpha);
				imagesetpixel($imgRot, $j, $i, $colorallocation);
			} else if ($iCeilingX == $size[0]-1 &#038;&#038; $iFloorY &gt;= 0 &#038;&#038; $iCeilingY &gt;= 0 &#038;&#038; $iFloorY &lt; $size[1] &#038;&#038; $iCeilingY &lt; $size[1]) {//right
				$alpha=round(abs($fDeltaX)*127);
				$colorallocation=imagecolorallocatealpha($imgRot, $iRed, $iGreen, $iBlue, $alpha);
				imagesetpixel($imgRot, $j, $i, $colorallocation);
			} else if ($iFloorX &gt;= 0 &#038;&#038; $iCeilingX &gt;= 0 &#038;&#038; $iFloorX &lt; $size[0] &#038;&#038; $iCeilingX &lt; $size[0] &#038;&#038; $iCeilingY == $size[1]-1) {//bottom
				$alpha=round(abs($fDeltaY)*127);
				$colorallocation=imagecolorallocatealpha($imgRot, $iRed, $iGreen, $iBlue, $alpha);
				imagesetpixel($imgRot, $j, $i, $colorallocation);
			}
		}
	}
}
</pre>
</div>
<p>Fabien is French (I think), which is why you get variable names such as distOmbre (shadow distance?), flouOmbre (fuzzy shadow?), largeur (width), hauteur (height). And this one took me a bit more time to translate&#8230; LsupH is probably &#8220;width greater than height?&#8221;. The &#8220;L&#8221; probably refers to &#8220;largeur&#8221;, and &#8220;H&#8221; refers to &#8220;hauteur&#8221;.</p>
<p>Reading international programming code is fun. *smile*</p>
<p>There&#8217;s also an interesting piece of code:</p>
<div class="codediv">
<pre>
$size=getimagesize("media/diapo-Chinon.jpg");
$LsupH=($size[0]&gt;$size[1])?1:0;
$angleBool=(int)($angleRot/90)%2==0?0:1;
if (($angleBool+$LsupH)%2==0) {
	$largeur=round(abs($size[0]*sin($angleRot%90*pi()/180))+abs($size[1]*sin((90-$angleRot%90)*pi()/180)));
	$hauteur=round(abs($size[0]*cos($angleRot%90*pi()/180))+abs($size[1]*cos((90-$angleRot%90)*pi()/180)));
} else {
	$largeur=round(abs($size[0]*cos($angleRot%90*pi()/180))+abs($size[1]*cos((90-$angleRot%90)*pi()/180)));
	$hauteur=round(abs($size[0]*sin($angleRot%90*pi()/180))+abs($size[1]*sin((90-$angleRot%90)*pi()/180)));
}
</pre>
</div>
<p>So here&#8217;s your mission, should you choose to accept it (I recently watched Mission Impossible&#8230;). <strong>What is Fabien trying to accomplish in that section of code?</strong> Hint: it has something to do with getting a &#8220;nice&#8221; resulting image width and height.</p>
<p>I&#8217;ll tell you a more &#8220;elegant&#8221; alternative to that code section. But it&#8217;ll involve some mathematics. And drawings. Prepare for poorly drawn diagrams&#8230;</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/PolymathProgrammer?a=du0DkXS7mbI:j81XOCW7hI0:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/PolymathProgrammer?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/PolymathProgrammer?a=du0DkXS7mbI:j81XOCW7hI0:I9og5sOYxJI"><img src="http://feeds.feedburner.com/~ff/PolymathProgrammer?d=I9og5sOYxJI" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/PolymathProgrammer?a=du0DkXS7mbI:j81XOCW7hI0:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/PolymathProgrammer?d=qj6IDK7rITs" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/PolymathProgrammer/~4/du0DkXS7mbI" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://polymathprogrammer.com/2012/02/02/image-rotation-bilinear-interpolation-alpha-progressive-borders/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://polymathprogrammer.com/2012/02/02/image-rotation-bilinear-interpolation-alpha-progressive-borders/</feedburner:origLink></item>
		<item>
		<title>Singularity Magazine February 2012</title>
		<link>http://feedproxy.google.com/~r/PolymathProgrammer/~3/59yziygqj8g/</link>
		<comments>http://polymathprogrammer.com/2012/02/01/singularity-magazine-february-2012/#comments</comments>
		<pubDate>Wed, 01 Feb 2012 13:16:27 +0000</pubDate>
		<dc:creator>Vincent</dc:creator>
				<category><![CDATA[Singularity]]></category>
		<category><![CDATA[art]]></category>
		<category><![CDATA[artist]]></category>
		<category><![CDATA[emotional labour]]></category>
		<category><![CDATA[february]]></category>
		<category><![CDATA[magazine]]></category>
		<category><![CDATA[singularity]]></category>

		<guid isPermaLink="false">http://polymathprogrammer.com/?p=3344</guid>
		<description><![CDATA[In this issue, we talk about what it means to be an artist. Hint: it has to do with emotional labour. Download the February issue (about 1.8 MB). Subscribe to the magazine for free. Follow me on Twitter or on YouTube.]]></description>
			<content:encoded><![CDATA[<p><a href="http://polymathprogrammer.com/issues/singularity201202.pdf" onClick="_gaq.push(['_trackEvent', 'Singularity', 'Download', '201202']);"><img src="http://polymathprogrammer.com/images/blog/201202/singularity201202.jpg" alt="Singularity Magazine February 2012" /></a></p>
<p>In this issue, we talk about what it means to be an artist. Hint: it has to do with emotional labour.</p>
<p><a href="http://polymathprogrammer.com/issues/singularity201202.pdf" onClick="_gaq.push(['_trackEvent', 'Singularity', 'Download', '201202']);">Download the February issue</a> (about 1.8 MB).</p>
<p><a href="http://polymathprogrammer.com/singularity/">Subscribe to the magazine for free.</a></p>
<p>Follow me on <a href="http://twitter.com/orcasquall">Twitter</a> or on <a href="http://www.youtube.com/orcasquall">YouTube</a>.</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/PolymathProgrammer?a=59yziygqj8g:EFsaImbghS0:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/PolymathProgrammer?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/PolymathProgrammer?a=59yziygqj8g:EFsaImbghS0:I9og5sOYxJI"><img src="http://feeds.feedburner.com/~ff/PolymathProgrammer?d=I9og5sOYxJI" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/PolymathProgrammer?a=59yziygqj8g:EFsaImbghS0:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/PolymathProgrammer?d=qj6IDK7rITs" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/PolymathProgrammer/~4/59yziygqj8g" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://polymathprogrammer.com/2012/02/01/singularity-magazine-february-2012/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://polymathprogrammer.com/2012/02/01/singularity-magazine-february-2012/</feedburner:origLink></item>
		<item>
		<title>Students don’t graduate because…</title>
		<link>http://feedproxy.google.com/~r/PolymathProgrammer/~3/HJCGsjYFG24/</link>
		<comments>http://polymathprogrammer.com/2012/01/30/students-dont-graduate-because/#comments</comments>
		<pubDate>Mon, 30 Jan 2012 11:02:15 +0000</pubDate>
		<dc:creator>Vincent</dc:creator>
				<category><![CDATA[Curiosita]]></category>
		<category><![CDATA[degree]]></category>
		<category><![CDATA[education]]></category>
		<category><![CDATA[hope]]></category>
		<category><![CDATA[student]]></category>
		<category><![CDATA[teaching]]></category>

		<guid isPermaLink="false">http://polymathprogrammer.com/?p=3335</guid>
		<description><![CDATA[&#8230; because they&#8217;ve lost hope. They&#8217;ve lost hope that: they can fulfill degree requirements (some subjects are tough!) they can actually graduate (more importantly) they can graduate in a shorter time so they pay less tuition fees they can get a good job with that degree And so they give up. They&#8217;ve lost hope. They [...]]]></description>
			<content:encoded><![CDATA[<p>&#8230; because they&#8217;ve lost hope.</p>
<p>They&#8217;ve lost hope that:</p>
<ul>
<li>they can fulfill degree requirements (some subjects are tough!)</li>
<li>they can actually graduate</li>
<li>(more importantly) they can graduate in a shorter time so they pay less tuition fees</li>
<li>they can get a good job with that degree</li>
</ul>
<p>And so they give up. They&#8217;ve lost hope. <a href="http://polymathprogrammer.com/2012/01/20/belief-is-everything/">They don&#8217;t believe anymore</a>.</p>
<p>A degree can still be useful. But the current educational and economic outlook doesn&#8217;t exactly inspire a lot of confidence in the immediate use of a degree.</p>
<p>Educational institutes mostly teach students towards knowledge that&#8217;s known. I mean, your professor won&#8217;t set a question that he can&#8217;t answer, right? The world we now live in rewards those who solve the unknown, possibly even seeking questions that weren&#8217;t ever asked.</p>
<p>Teachers need to start teaching students to face the unknowable. They need to instill hope in the next generation.</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/PolymathProgrammer?a=HJCGsjYFG24:NVClATkyvlM:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/PolymathProgrammer?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/PolymathProgrammer?a=HJCGsjYFG24:NVClATkyvlM:I9og5sOYxJI"><img src="http://feeds.feedburner.com/~ff/PolymathProgrammer?d=I9og5sOYxJI" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/PolymathProgrammer?a=HJCGsjYFG24:NVClATkyvlM:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/PolymathProgrammer?d=qj6IDK7rITs" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/PolymathProgrammer/~4/HJCGsjYFG24" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://polymathprogrammer.com/2012/01/30/students-dont-graduate-because/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://polymathprogrammer.com/2012/01/30/students-dont-graduate-because/</feedburner:origLink></item>
		<item>
		<title>Congratulations on becoming rich!</title>
		<link>http://feedproxy.google.com/~r/PolymathProgrammer/~3/F6qOWx401DQ/</link>
		<comments>http://polymathprogrammer.com/2012/01/26/congratulations-becoming-rich/#comments</comments>
		<pubDate>Thu, 26 Jan 2012 14:16:23 +0000</pubDate>
		<dc:creator>Vincent</dc:creator>
				<category><![CDATA[Curiosita]]></category>
		<category><![CDATA[chinese]]></category>
		<category><![CDATA[chinese new year]]></category>
		<category><![CDATA[greetings]]></category>
		<category><![CDATA[holiday]]></category>
		<category><![CDATA[new year]]></category>
		<category><![CDATA[orcasquall]]></category>
		<category><![CDATA[video]]></category>

		<guid isPermaLink="false">http://polymathprogrammer.com/?p=3333</guid>
		<description><![CDATA[In which I teach you 3 Chinese New Year greetings. Also, this was unscripted (mostly). I also can&#8217;t do one-take videos&#8230;]]></description>
			<content:encoded><![CDATA[<p><iframe width="560" height="315" src="http://www.youtube.com/embed/itARidDqdcI" frameborder="0" allowfullscreen></iframe></p>
<p>In which I teach you 3 Chinese New Year greetings. Also, this was unscripted (mostly). I also can&#8217;t do one-take videos&#8230;</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/PolymathProgrammer?a=F6qOWx401DQ:Z_EmofFLKXM:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/PolymathProgrammer?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/PolymathProgrammer?a=F6qOWx401DQ:Z_EmofFLKXM:I9og5sOYxJI"><img src="http://feeds.feedburner.com/~ff/PolymathProgrammer?d=I9og5sOYxJI" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/PolymathProgrammer?a=F6qOWx401DQ:Z_EmofFLKXM:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/PolymathProgrammer?d=qj6IDK7rITs" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/PolymathProgrammer/~4/F6qOWx401DQ" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://polymathprogrammer.com/2012/01/26/congratulations-becoming-rich/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://polymathprogrammer.com/2012/01/26/congratulations-becoming-rich/</feedburner:origLink></item>
		<item>
		<title>Belief is everything</title>
		<link>http://feedproxy.google.com/~r/PolymathProgrammer/~3/f-JE6JzSAuA/</link>
		<comments>http://polymathprogrammer.com/2012/01/20/belief-is-everything/#comments</comments>
		<pubDate>Fri, 20 Jan 2012 12:57:54 +0000</pubDate>
		<dc:creator>Vincent</dc:creator>
				<category><![CDATA[Curiosita]]></category>
		<category><![CDATA[belief]]></category>
		<category><![CDATA[possibility]]></category>
		<category><![CDATA[self-confidence]]></category>

		<guid isPermaLink="false">http://polymathprogrammer.com/?p=3322</guid>
		<description><![CDATA[You might be surprised that I&#8217;ve learnt many life lessons from books. Specifically, fantasy fiction. Today, I&#8217;m going to tell you one of them. Warning: There will be spoilers, even though I&#8217;ve summarised a fair chunk of the book. The following comes from the book Sword of Shannara by Terry Brooks. If you don&#8217;t want [...]]]></description>
			<content:encoded><![CDATA[<p>You might be surprised that I&#8217;ve learnt many life lessons from books. Specifically, fantasy fiction. Today, I&#8217;m going to tell you one of them.</p>
<p>Warning: There will be spoilers, even though I&#8217;ve summarised a fair chunk of the book. The following comes from the book Sword of Shannara by Terry Brooks. If you don&#8217;t want spoilers, you should stop reading&#8230; now.</p>
<h3>Gifted wrongly</h3>
<p>I will be summarising extensively. There was this great druid. There was also this great evil (isn&#8217;t there always&#8230;). With some thought, the druid figured out how to defeat the great evil, and he forged a sword with which to do battle.</p>
<p>The druid decided to give the sword to another. I can&#8217;t remember why, whether out of sacrifice (didn&#8217;t want to get all the credit), or that he couldn&#8217;t fight anymore (old age). I&#8217;m sure a Shannara fan will happily correct me in the comments&#8230;</p>
<p>But the druid made a fatal mistake. He gifted the magic sword to the king of the elven people.</p>
<p>The king himself wasn&#8217;t the mistake. The position of kingship <em>was</em>.</p>
<p>The king went to do battle with the great evil and won. But a quiet cloak of belief had already settled onto the elven people. <strong>That the magic sword will only work for the king.</strong></p>
<p>As a consequence of that belief, the elven people also believed that only the heirs of the king could successfully wield the great magic sword. This was wrong. The magic sword would work for any elf with the right purpose of heart. The druid had not forged any special condition into the sword.</p>
<p>But with mass belief, the unintended condition wrapped itself together with the magic. And eventually, it became true. Only heirs from the line of the original king could wield the magic sword.</p>
<h3>Belief is everything</h3>
<p>And that was one of my first life lessons. Belief is everything. Beliefs are powerful.</p>
<p>If you don&#8217;t believe that something will work, then it probably won&#8217;t.</p>
<p>If you believe you can fashion a database to support the technical aspects of your program, then yes, you probably will come up with a design to suit your needs.</p>
<p>Disbelief closes off possibilities.</p>
<p>A corollary of that is about mass belief. If many people believe in something, then that something has a lot of power. Religion, superstitions, doomsday announcements, electromagnetic waves. I&#8217;m not talking about proofs and so on, particularly with science. I&#8217;m talking purely about beliefs. Say some scientific experiment can be replicated with the same results. That convinces people of the validity of the theory behind the experiment, and thus belief in that theory. It&#8217;s still belief.</p>
<p>This gave me confidence and understanding of certain human endeavors. Why do some people succeed at businesses? Many people believe that starting your own business is risky. And they&#8217;d be right. And those people who succeed? Those people believe they can succeed in making their business work, overriding the disbelief from the people around them.</p>
<p>Belief is everything.</p>
<p>It&#8217;s how I&#8217;ve upheld my own beliefs in the face of every belief thrown at me from everyone around me. My family. My friends. Even strangers.</p>
<p>Of course, you don&#8217;t have to listen to me. &#8220;Everything&#8221; is an <a href="http://polymathprogrammer.com/2011/12/27/absolutes-are-relative/">absolute term</a>. But that means you <em>do</em> believe in something, just not my version.</p>
<p>Just in case you&#8217;re interested in what the magic sword can do, it does one thing only. <strong>It reveals the truth</strong>. That great evil grew powerful because of the fear from the people. Yes, the belief that the great evil is indeed very powerful and can do great harm, made the evil even more powerful. The magic sword unveiled the truth, that the great evil was simply a malevolent shadow of a man.</p>
<p>Politicians, scammers and liars of all sorts would fear the Sword of Shannara indeed.</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/PolymathProgrammer?a=f-JE6JzSAuA:IpDnruRbPTk:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/PolymathProgrammer?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/PolymathProgrammer?a=f-JE6JzSAuA:IpDnruRbPTk:I9og5sOYxJI"><img src="http://feeds.feedburner.com/~ff/PolymathProgrammer?d=I9og5sOYxJI" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/PolymathProgrammer?a=f-JE6JzSAuA:IpDnruRbPTk:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/PolymathProgrammer?d=qj6IDK7rITs" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/PolymathProgrammer/~4/f-JE6JzSAuA" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://polymathprogrammer.com/2012/01/20/belief-is-everything/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://polymathprogrammer.com/2012/01/20/belief-is-everything/</feedburner:origLink></item>
		<item>
		<title>Quadratic Bezier curve control point calculation demo</title>
		<link>http://feedproxy.google.com/~r/PolymathProgrammer/~3/WgRho5hxKyM/</link>
		<comments>http://polymathprogrammer.com/2012/01/16/quadratic-bezier-curve-control-point-calculation-demo/#comments</comments>
		<pubDate>Mon, 16 Jan 2012 11:07:55 +0000</pubDate>
		<dc:creator>Vincent</dc:creator>
				<category><![CDATA[Mathematics]]></category>
		<category><![CDATA[bezier]]></category>
		<category><![CDATA[control point]]></category>
		<category><![CDATA[curve]]></category>
		<category><![CDATA[demo]]></category>
		<category><![CDATA[quadratic]]></category>
		<category><![CDATA[video]]></category>

		<guid isPermaLink="false">http://polymathprogrammer.com/?p=3319</guid>
		<description><![CDATA[MacGile made a video to demonstrate the calculation of control points of a quadratic Bezier curve. The algorithm is based on what I wrote here. That looks awesome! Thanks MacGile!]]></description>
			<content:encoded><![CDATA[<p>MacGile made a video to demonstrate the calculation of control points of a quadratic Bezier curve. The algorithm is based on <a href="http://polymathprogrammer.com/2010/05/03/reverse-engineering-quadratic-bezier-curves/">what I wrote here</a>.</p>
<p><iframe width="420" height="315" src="http://www.youtube.com/embed/s1ALgNnRi6Q" frameborder="0" allowfullscreen></iframe></p>
<p>That looks awesome! Thanks MacGile!</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/PolymathProgrammer?a=WgRho5hxKyM:lvyOoOkvTfk:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/PolymathProgrammer?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/PolymathProgrammer?a=WgRho5hxKyM:lvyOoOkvTfk:I9og5sOYxJI"><img src="http://feeds.feedburner.com/~ff/PolymathProgrammer?d=I9og5sOYxJI" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/PolymathProgrammer?a=WgRho5hxKyM:lvyOoOkvTfk:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/PolymathProgrammer?d=qj6IDK7rITs" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/PolymathProgrammer/~4/WgRho5hxKyM" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://polymathprogrammer.com/2012/01/16/quadratic-bezier-curve-control-point-calculation-demo/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://polymathprogrammer.com/2012/01/16/quadratic-bezier-curve-control-point-calculation-demo/</feedburner:origLink></item>
		<item>
		<title>Launching SpreadsheetLight</title>
		<link>http://feedproxy.google.com/~r/PolymathProgrammer/~3/QqWiv76hdAI/</link>
		<comments>http://polymathprogrammer.com/2012/01/10/launching-spreadsheetlight/#comments</comments>
		<pubDate>Tue, 10 Jan 2012 04:15:51 +0000</pubDate>
		<dc:creator>Vincent</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[library]]></category>
		<category><![CDATA[openxml]]></category>
		<category><![CDATA[software]]></category>
		<category><![CDATA[spreadsheet]]></category>

		<guid isPermaLink="false">http://polymathprogrammer.com/?p=3306</guid>
		<description><![CDATA[I am excited to tell you that my spreadsheet software library is available! For the initial launch version (I decided to go for version 1. Why do people launch with versions 0.8? I don&#8217;t know&#8230;), you get comprehensive support for styles, rich text formatting, 47 named cell styles, themes (either one of the 20 built-in [...]]]></description>
			<content:encoded><![CDATA[<p>I am excited to tell you that my spreadsheet software library is available!</p>
<p><a href="http://polymathprogrammer.com/store/spreadsheetlight/"><img src="http://polymathprogrammer.com/spreadsheetlight/SpreadsheetLightBox.jpg" alt="SpreadsheetLight" /></a></p>
<p>For the initial launch version (I decided to go for version 1. Why do people launch with versions 0.8? I don&#8217;t know&#8230;), you get comprehensive support for styles, rich text formatting, 47 named cell styles, themes (either one of the 20 built-in themes or create-your-own). Well, like I said, comprehensive styling support.</p>
<p>There&#8217;s also the (hum-drum) support for merging cells and freezing panes. I actually explored how to split panes. I certainly wrote about it in my <a href="http://polymathprogrammer.com/store/spreadsheet-open-xml/">Open XML guide</a>, but it turns out that there&#8217;s a tiny rectangle at the top-left corner that Microsoft Excel didn&#8217;t tell me about. The size of that tiny rectangle is dependent on the font you use, and even the screen resolution of your computer screen.</p>
<p>While I could add a function that allows you to just input the size in EMUs (<a href="http://polymathprogrammer.com/2009/10/22/english-metric-units-and-open-xml/">English Metric Units</a>), I decided that if I can&#8217;t do it well, I don&#8217;t want to do it. At least for the initial launch.</p>
<p>Row heights and column widths were also big time drains. It turns out that they&#8217;re also dependent on the font and screen resolution of your computer screen. I was trying to calculate the standard row heights and column widths for the fonts in the built-in themes, and I thought I had them. I wrote a program using SpreadsheetLight to generate spreadsheets with different minor fonts, and I wrote a program to read in those spreadsheets and get the &#8220;standard&#8221; row height and column width. I spent 3 hours collecting data.</p>
<p>Then on a whim, I switched my computer screen&#8217;s resolution from 120 DPI to 96 DPI (my eyesight&#8217;s not that good ok? I need bigger text&#8230;), and whoa! All that data doesn&#8217;t apply anymore&#8230; All in all, I think I spent 6 or 7 days trying to figure out a general calculation formula. I failed. I don&#8217;t know how Excel does it.</p>
<p>I also surprised myself by including extensive support for pictures. I thought you just insert a picture into the worksheet and that&#8217;s it! It turns out there&#8217;s a ton of post-insertion manipulations you can do. For example, if your picture has transparent areas, you could set a background fill, and that background colour will be visible through the picture. Also, you can rotate the picture in 3D.</p>
<p>SpreadsheetLight is licensed under the MIT license. I decided to use one of the available software licenses instead of making up one of my own. As far as I can tell, the MIT license allows the recipient of the software to use the software in personal or commercial products. It&#8217;s also categorised as free software, as in freedom of use, not free as in cost. I don&#8217;t want to deal with per-client, or per-server, or per-developer or per-what-not licensing restrictions.</p>
<p>Even if you&#8217;re not interested in spreadsheet software, <a href="http://polymathprogrammer.com/store/spreadsheetlight/">have a look at SpreadsheetLight</a>. Tell some other programmer about it. Tell your manager about it. It took me slightly over 2 months of intense coding, and I want someone in the world out there to have an easier life because of SpreadsheetLight. Thanks!</p>
<p>Oh, and the image art is designed by Charlie Pabst from <a href="http://www.charfishdesign.com/">Charfish Design</a>. While I have a fair competence in image work, I decided to get a professional designer to help me. It&#8217;s a business and professional product. I&#8217;m not going to risk the product&#8217;s success so I could stoke my ego&#8230;</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/PolymathProgrammer?a=QqWiv76hdAI:TnYu6Ei-sGM:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/PolymathProgrammer?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/PolymathProgrammer?a=QqWiv76hdAI:TnYu6Ei-sGM:I9og5sOYxJI"><img src="http://feeds.feedburner.com/~ff/PolymathProgrammer?d=I9og5sOYxJI" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/PolymathProgrammer?a=QqWiv76hdAI:TnYu6Ei-sGM:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/PolymathProgrammer?d=qj6IDK7rITs" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/PolymathProgrammer/~4/QqWiv76hdAI" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://polymathprogrammer.com/2012/01/10/launching-spreadsheetlight/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://polymathprogrammer.com/2012/01/10/launching-spreadsheetlight/</feedburner:origLink></item>
		<item>
		<title>Named cell styles are still explicitly declared</title>
		<link>http://feedproxy.google.com/~r/PolymathProgrammer/~3/soOMIlfEVbA/</link>
		<comments>http://polymathprogrammer.com/2012/01/05/named-cell-styles-explicitly-declared/#comments</comments>
		<pubDate>Thu, 05 Jan 2012 05:12:14 +0000</pubDate>
		<dc:creator>Vincent</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[excel]]></category>
		<category><![CDATA[named cell style]]></category>
		<category><![CDATA[spreadsheet]]></category>
		<category><![CDATA[style]]></category>

		<guid isPermaLink="false">http://polymathprogrammer.com/?p=3258</guid>
		<description><![CDATA[Styling cells in Microsoft Excel has its difficulties (as I&#8217;ve written before). The biggest one is keeping track of all the indices. In Open XML SDK, you have the ability to have a named cell style. At first glance, you might think that&#8217;s awesome. You just use a named cell style, and all the related [...]]]></description>
			<content:encoded><![CDATA[<p>Styling cells in Microsoft Excel has its difficulties (<a href="http://polymathprogrammer.com/2009/12/21/advanced-styling-in-excel-open-xml/">as I&#8217;ve written before</a>). The biggest one is keeping track of all the indices. In Open XML SDK, you have the ability to have a named cell style.</p>
<p>At first glance, you might think that&#8217;s awesome. You just use a named cell style, and all the related styles are applied. It&#8217;s like there&#8217;s a red car that uses hybrid fuels. &#8220;Yes, I would like to have a red car that uses hybrid fuels.&#8221; Not quite.</p>
<p>You see, the named cell style is dependent on the implementing spreadsheet software. For example, Microsoft Excel has the &#8220;Normal&#8221;, &#8220;Bad&#8221;, &#8220;Good&#8221; and &#8220;Neutral&#8221; named cell styles. But Google Spreadsheets and OpenOffice.org Calc do not have to have those named cell styles, or even style it the same as Microsoft Excel. This is where Open XML SDK isn&#8217;t quite &#8220;open&#8221;&#8230; After much research and work, I discovered the SDK is basically Open-XML-ising Microsoft Excel (and Word and PowerPoint). I&#8217;m neutral on the stands of open source and &#8220;forcing standards&#8221;. I just use whatever there is, and make something within the limitations.</p>
<p>Because of the dependency, the underlying individual styles need to be declared explicitly. Actually more so because of the dependency.</p>
<p>So for my spreadsheet software library <strong>SpreadsheetLight</strong>, I used Excel as the guideline.</p>
<p>In researching Excel named cell styles, I had to look at the underlying XML files (because Open XML spreadsheets are made of XML files). While the Open XML SDK comes with a document explorer (the Productivity Tool), I needed to make notes and also that I felt the need to see the XML file itself, rather than using the explorer tool.</p>
<p>This gave me a problem because while XML files are supposed to be human-readable, it doesn&#8217;t make it easy to read. The &#8220;natural&#8221; XML file has no indents. Oh my Godiva chocolate, it&#8217;s so hard to read&#8230; Then I remembered I had an XML tool, <strong>XML Studio</strong>. I fired that up and a few clicks later, the XML file had nice indents and I could find out where the individual style tags were. XML Studio was amazing to use.</p>
<p><strong>Disclaimer</strong>: I was given a free developer license of XML Studio by <a href="http://www.liquid-technologies.com/">Liquid Technologies</a>. But the software is really useful if you work with XML files a lot.</p>
<p>After doing my notes for a while, I discovered even that&#8217;s not enough. There were too many individual styles! I needed the indices for those styles, because only the index was referenced in the final style (CellFormat classes). I didn&#8217;t really feel up to annotating the indices&#8230; until I remembered my partially completed <a href="http://polymathprogrammer.com/soxdecompiler/">Open XML spreadsheet decompiler tool</a>. When I created that tool, one of my aims was to put in comments on the index of the individual styles.</p>
<p>Note to Liquid Technologies: You might want to consider putting in XML comments on the index of an XML child tag with respect to its parent. But I don&#8217;t know if that&#8217;s useful to programming spheres other than Open XML&#8230;</p>
<p>Anyway, my hard work paid off, and SpreadsheetLight allows you to apply named cell styles. Here&#8217;s how the spreadsheet looks like:<br />
<img src="http://polymathprogrammer.com/images/blog/201201/applyingnamedcellstyles.png" alt="Applying named cell styles" /></p>
<p>Note that some of the named cell styles use accent colours. The accent colours are part of the spreadsheet&#8217;s theme. So in offering named cell styles as a feature, I also had to allow you to create your own theme. And here&#8217;s the code using SpreadsheetLight:</p>
<div class="codediv">
<pre>
System.Drawing.Color[] clrs = new System.Drawing.Color[12];
clrs[0] = System.Drawing.Color.White;
clrs[1] = System.Drawing.Color.Black;
clrs[2] = System.Drawing.Color.WhiteSmoke;
clrs[3] = System.Drawing.Color.DarkSlateGray;
clrs[4] = System.Drawing.Color.DarkRed;
clrs[5] = System.Drawing.Color.OrangeRed;
clrs[6] = System.Drawing.Color.DarkGoldenrod;
clrs[7] = System.Drawing.Color.DarkOliveGreen;
clrs[8] = System.Drawing.Color.Navy;
clrs[9] = System.Drawing.Color.Indigo;
clrs[10] = System.Drawing.Color.SkyBlue;
clrs[11] = System.Drawing.Color.MediumPurple;

SLDocument sl = new SLDocument("ColourWheel", "Castellar", "Harrington", clrs);

sl.SetRowHeight(6, 24);
sl.SetColumnWidth(1, 1);
sl.SetColumnWidth(2, 13);
sl.SetColumnWidth(3, 13);
sl.SetColumnWidth(4, 13);
sl.SetColumnWidth(5, 13);
sl.SetColumnWidth(6, 13);
sl.SetColumnWidth(7, 13);

sl.SetCellValue(2, 2, "Normal");
sl.ApplyNamedCellStyle(2, 2, SLNamedCellStyleValues.Normal);
sl.SetCellValue(2, 3, "Bad");
sl.ApplyNamedCellStyle(2, 3, SLNamedCellStyleValues.Bad);
sl.SetCellValue(2, 4, "Good");
sl.ApplyNamedCellStyle(2, 4, SLNamedCellStyleValues.Good);
sl.SetCellValue(2, 5, "Neutral");
sl.ApplyNamedCellStyle(2, 5, SLNamedCellStyleValues.Neutral);

sl.SetCellValue(3, 2, "Calculation");
sl.ApplyNamedCellStyle(3, 2, SLNamedCellStyleValues.Calculation);
sl.SetCellValue(3, 3, "Check Cell");
sl.ApplyNamedCellStyle(3, 3, SLNamedCellStyleValues.CheckCell);
sl.SetCellValue(3, 4, "Explanatory Text");
sl.ApplyNamedCellStyle(3, 4, SLNamedCellStyleValues.ExplanatoryText);
sl.SetCellValue(3, 5, "Input");
sl.ApplyNamedCellStyle(3, 5, SLNamedCellStyleValues.Input);

sl.SetCellValue(4, 2, "Linked Cell");
sl.ApplyNamedCellStyle(4, 2, SLNamedCellStyleValues.LinkedCell);
sl.SetCellValue(4, 3, "Note");
sl.ApplyNamedCellStyle(4, 3, SLNamedCellStyleValues.Note);
sl.SetCellValue(4, 4, "Output");
sl.ApplyNamedCellStyle(4, 4, SLNamedCellStyleValues.Output);
sl.SetCellValue(4, 5, "Warning Text");
sl.ApplyNamedCellStyle(4, 5, SLNamedCellStyleValues.WarningText);

sl.SetCellValue(6, 2, "Heading 1");
sl.ApplyNamedCellStyle(6, 2, SLNamedCellStyleValues.Heading1);
sl.SetCellValue(6, 3, "Heading 2");
sl.ApplyNamedCellStyle(6, 3, SLNamedCellStyleValues.Heading2);
sl.SetCellValue(6, 4, "Heading 3");
sl.ApplyNamedCellStyle(6, 4, SLNamedCellStyleValues.Heading3);
sl.SetCellValue(6, 5, "Heading 4");
sl.ApplyNamedCellStyle(6, 5, SLNamedCellStyleValues.Heading4);
sl.SetCellValue(6, 6, "Title");
sl.ApplyNamedCellStyle(6, 6, SLNamedCellStyleValues.Title);
sl.SetCellValue(6, 7, "Total");
sl.ApplyNamedCellStyle(6, 7, SLNamedCellStyleValues.Total);

sl.SetCellValue(8, 2, "Accent1");
sl.ApplyNamedCellStyle(8, 2, SLNamedCellStyleValues.Accent1);
sl.SetCellValue(8, 3, "Accent2");
sl.ApplyNamedCellStyle(8, 3, SLNamedCellStyleValues.Accent2);
sl.SetCellValue(8, 4, "Accent3");
sl.ApplyNamedCellStyle(8, 4, SLNamedCellStyleValues.Accent3);
sl.SetCellValue(8, 5, "Accent4");
sl.ApplyNamedCellStyle(8, 5, SLNamedCellStyleValues.Accent4);
sl.SetCellValue(8, 6, "Accent5");
sl.ApplyNamedCellStyle(8, 6, SLNamedCellStyleValues.Accent5);
sl.SetCellValue(8, 7, "Accent6");
sl.ApplyNamedCellStyle(8, 7, SLNamedCellStyleValues.Accent6);

sl.SetCellValue(9, 2, "Accent1Perc60");
sl.ApplyNamedCellStyle(9, 2, SLNamedCellStyleValues.Accent1Percentage60);
sl.SetCellValue(9, 3, "Accent2Perc60");
sl.ApplyNamedCellStyle(9, 3, SLNamedCellStyleValues.Accent2Percentage60);
sl.SetCellValue(9, 4, "Accent3Perc60");
sl.ApplyNamedCellStyle(9, 4, SLNamedCellStyleValues.Accent3Percentage60);
sl.SetCellValue(9, 5, "Accent4Perc60");
sl.ApplyNamedCellStyle(9, 5, SLNamedCellStyleValues.Accent4Percentage60);
sl.SetCellValue(9, 6, "Accent5Perc60");
sl.ApplyNamedCellStyle(9, 6, SLNamedCellStyleValues.Accent5Percentage60);
sl.SetCellValue(9, 7, "Accent6Perc60");
sl.ApplyNamedCellStyle(9, 7, SLNamedCellStyleValues.Accent6Percentage60);

sl.SetCellValue(10, 2, "Accent1Perc40");
sl.ApplyNamedCellStyle(10, 2, SLNamedCellStyleValues.Accent1Percentage40);
sl.SetCellValue(10, 3, "Accent2Perc40");
sl.ApplyNamedCellStyle(10, 3, SLNamedCellStyleValues.Accent2Percentage40);
sl.SetCellValue(10, 4, "Accent3Perc40");
sl.ApplyNamedCellStyle(10, 4, SLNamedCellStyleValues.Accent3Percentage40);
sl.SetCellValue(10, 5, "Accent4Perc40");
sl.ApplyNamedCellStyle(10, 5, SLNamedCellStyleValues.Accent4Percentage40);
sl.SetCellValue(10, 6, "Accent5Perc40");
sl.ApplyNamedCellStyle(10, 6, SLNamedCellStyleValues.Accent5Percentage40);
sl.SetCellValue(10, 7, "Accent6Perc40");
sl.ApplyNamedCellStyle(10, 7, SLNamedCellStyleValues.Accent6Percentage40);

sl.SetCellValue(11, 2, "Accent1Perc20");
sl.ApplyNamedCellStyle(11, 2, SLNamedCellStyleValues.Accent1Percentage20);
sl.SetCellValue(11, 3, "Accent2Perc20");
sl.ApplyNamedCellStyle(11, 3, SLNamedCellStyleValues.Accent2Percentage20);
sl.SetCellValue(11, 4, "Accent3Perc20");
sl.ApplyNamedCellStyle(11, 4, SLNamedCellStyleValues.Accent3Percentage20);
sl.SetCellValue(11, 5, "Accent4Perc20");
sl.ApplyNamedCellStyle(11, 5, SLNamedCellStyleValues.Accent4Percentage20);
sl.SetCellValue(11, 6, "Accent5Perc20");
sl.ApplyNamedCellStyle(11, 6, SLNamedCellStyleValues.Accent5Percentage20);
sl.SetCellValue(11, 7, "Accent6Perc20");
sl.ApplyNamedCellStyle(11, 7, SLNamedCellStyleValues.Accent6Percentage20);

sl.SetCellValue(13, 2, 12345678);
sl.ApplyNamedCellStyle(13, 2, SLNamedCellStyleValues.Comma);
sl.SetCellValue(13, 4, 12345678);
sl.ApplyNamedCellStyle(13, 4, SLNamedCellStyleValues.Comma0);
sl.SetCellValue(14, 2, 12345678);
sl.ApplyNamedCellStyle(14, 2, SLNamedCellStyleValues.Currency);
sl.SetCellValue(14, 4, 12345678);
sl.ApplyNamedCellStyle(14, 4, SLNamedCellStyleValues.Currency0);
sl.SetCellValue(15, 2, 123);
sl.ApplyNamedCellStyle(156, 2, SLNamedCellStyleValues.Percentage);

sl.SaveAs("NamedCellStyles.xlsx");
</pre>
</div>
<p>I set the column widths of the 2nd to 7th column, and the row height of the 6th row so it&#8217;s easier to see.</p>
<p>The main body text (the minor font) is in Harrington, and the title font (major font) is Castellar. You will note that even though the major font is supposedly used for heading and title texts, only the named cell style Title uses the major font. The headings 1 through 4 use the minor font.</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/PolymathProgrammer?a=soOMIlfEVbA:ARKjgpaKOJU:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/PolymathProgrammer?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/PolymathProgrammer?a=soOMIlfEVbA:ARKjgpaKOJU:I9og5sOYxJI"><img src="http://feeds.feedburner.com/~ff/PolymathProgrammer?d=I9og5sOYxJI" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/PolymathProgrammer?a=soOMIlfEVbA:ARKjgpaKOJU:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/PolymathProgrammer?d=qj6IDK7rITs" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/PolymathProgrammer/~4/soOMIlfEVbA" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://polymathprogrammer.com/2012/01/05/named-cell-styles-explicitly-declared/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://polymathprogrammer.com/2012/01/05/named-cell-styles-explicitly-declared/</feedburner:origLink></item>
		<item>
		<title>Singularity Magazine January 2012</title>
		<link>http://feedproxy.google.com/~r/PolymathProgrammer/~3/wzGFTFZXx2E/</link>
		<comments>http://polymathprogrammer.com/2012/01/03/singularity-magazine-january-2012/#comments</comments>
		<pubDate>Tue, 03 Jan 2012 12:40:43 +0000</pubDate>
		<dc:creator>Vincent</dc:creator>
				<category><![CDATA[Singularity]]></category>
		<category><![CDATA[goal]]></category>
		<category><![CDATA[january]]></category>
		<category><![CDATA[journey]]></category>
		<category><![CDATA[magazine]]></category>
		<category><![CDATA[resolution]]></category>
		<category><![CDATA[singularity]]></category>

		<guid isPermaLink="false">http://polymathprogrammer.com/?p=3255</guid>
		<description><![CDATA[A new issue of Singularity is available! Download it (2.5 MB). Read about the journey I took, spanning 22 kilometres and 5 hours. Subscribe for free here.]]></description>
			<content:encoded><![CDATA[<p><a href="http://polymathprogrammer.com/issues/singularity201201.pdf" onClick="_gaq.push(['_trackEvent', 'Singularity', 'Download', '201201']);"><img src="http://polymathprogrammer.com/images/blog/201201/singularity201201.jpg" alt="Singularity Magazine January 2012" /></a></p>
<p>A new issue of Singularity is available! <a href="http://polymathprogrammer.com/issues/singularity201201.pdf" onClick="_gaq.push(['_trackEvent', 'Singularity', 'Download', '201201']);">Download it</a> (2.5 MB).</p>
<p>Read about the journey I took, spanning 22 kilometres and 5 hours.</p>
<p><a href="http://polymathprogrammer.com/singularity/">Subscribe for free here</a>.</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/PolymathProgrammer?a=wzGFTFZXx2E:CNvtS0gjTXc:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/PolymathProgrammer?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/PolymathProgrammer?a=wzGFTFZXx2E:CNvtS0gjTXc:I9og5sOYxJI"><img src="http://feeds.feedburner.com/~ff/PolymathProgrammer?d=I9og5sOYxJI" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/PolymathProgrammer?a=wzGFTFZXx2E:CNvtS0gjTXc:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/PolymathProgrammer?d=qj6IDK7rITs" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/PolymathProgrammer/~4/wzGFTFZXx2E" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://polymathprogrammer.com/2012/01/03/singularity-magazine-january-2012/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://polymathprogrammer.com/2012/01/03/singularity-magazine-january-2012/</feedburner:origLink></item>
	</channel>
</rss>

