<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>thesweeheng's weblog</title>
	<atom:link href="http://thesweeheng.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://thesweeheng.wordpress.com</link>
	<description>a technical weblog</description>
	<lastBuildDate>Thu, 26 Jan 2012 10:03:56 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='thesweeheng.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>thesweeheng's weblog</title>
		<link>http://thesweeheng.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://thesweeheng.wordpress.com/osd.xml" title="thesweeheng&#039;s weblog" />
	<atom:link rel='hub' href='http://thesweeheng.wordpress.com/?pushpress=hub'/>
		<item>
		<title>American Binomial Model in Python</title>
		<link>http://thesweeheng.wordpress.com/2009/12/11/american-binomial-model-in-python/</link>
		<comments>http://thesweeheng.wordpress.com/2009/12/11/american-binomial-model-in-python/#comments</comments>
		<pubDate>Fri, 11 Dec 2009 15:04:54 +0000</pubDate>
		<dc:creator>thesweeheng</dc:creator>
				<category><![CDATA[coding]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[binomial]]></category>
		<category><![CDATA[numpy]]></category>
		<category><![CDATA[options]]></category>
		<category><![CDATA[pricing]]></category>

		<guid isPermaLink="false">http://thesweeheng.wordpress.com/?p=460</guid>
		<description><![CDATA[Having written about pricing American-style options on a binomial tree in q, I thought it would be instructive to do the same in Python and NumPy. Here is the code: import functools as ft import numpy as np def BPTree(n, S, u, d): r = [np.array([S])] for i in range(n): r.append(np.concatenate((r[-1][:1]*u, r[-1]*d))) return r def [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thesweeheng.wordpress.com&amp;blog=806407&amp;post=460&amp;subd=thesweeheng&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Having written about <a href="http://thesweeheng.wordpress.com/2009/12/09/american-binomial-model-in-q/">pricing American-style options on a binomial tree in q</a>, I thought it would be instructive to do the same in Python and NumPy. Here is the code:</p>
<blockquote><pre>
import functools as ft
import numpy as np

def BPTree(n, S, u, d):
  r = [np.array([S])]
  for i in range(n):
    r.append(np.concatenate((r[-1][:1]*u, r[-1]*d)))
  return r

def GBM(R, P, S, T, r, b, v, n):
  t = float(T)/n
  u = np.exp(v * np.sqrt(t))
  d = 1./u
  p = (np.exp(b * t) - d)/(u - d)
  ptree = BPTree(n, S, u, d)[::-1]
  R_ = ft.partial(R, np.exp(-r*t), p)
  return reduce(R_, map(P, ptree))[0]

def American(D, p, a, b): return np.maximum(b, D*(a[:-1]*p + a[1:]*(1-p)))
def VP(S, K): return np.maximum(K - S, 0)
ABM = ft.partial(GBM, American)
</pre>
</blockquote>
<p>There is a minor deviation from the q code: we are allowing d to be specified in BPTree. But otherwise, they are doing the same thing. Performance (as measured in ipython) isn&#8217;t too far-off either:</p>
<blockquote><pre>
In [1]: from binomial import *
In [2]: %timeit ABM(ft.partial(VP,K=102.0), 100.0, 1.0, 0.08, 0.08, 0.2, 1000)
10 loops, best of 3: 38.4 ms per loop
In [3]: ABM(ft.partial(VP,K=102.0), 100.0, 1.0, 0.08, 0.08, 0.2, 1000)
Out[3]: 6.2215001602514555
</pre>
</blockquote>
<p>Note the similarity between the q and Python code. The similarity is a result of using NumPy and functools which enabled Python to perform array-oriented computation and partial function application. We did use a loop in BPTree as Python/NumPy does not seem to have the same &#8220;scan&#8221; operation as q. I suppose we could have created a numpy.ufunc to use accumulate()&#8230; but the loop felt cleaner and more Pythonic.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/thesweeheng.wordpress.com/460/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/thesweeheng.wordpress.com/460/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/thesweeheng.wordpress.com/460/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/thesweeheng.wordpress.com/460/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/thesweeheng.wordpress.com/460/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/thesweeheng.wordpress.com/460/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/thesweeheng.wordpress.com/460/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/thesweeheng.wordpress.com/460/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/thesweeheng.wordpress.com/460/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/thesweeheng.wordpress.com/460/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/thesweeheng.wordpress.com/460/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/thesweeheng.wordpress.com/460/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/thesweeheng.wordpress.com/460/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/thesweeheng.wordpress.com/460/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thesweeheng.wordpress.com&amp;blog=806407&amp;post=460&amp;subd=thesweeheng&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://thesweeheng.wordpress.com/2009/12/11/american-binomial-model-in-python/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/4610086cdfe5540d02f3e19cd1f88627?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">thesweeheng</media:title>
		</media:content>
	</item>
		<item>
		<title>American Binomial Model in q</title>
		<link>http://thesweeheng.wordpress.com/2009/12/09/american-binomial-model-in-q/</link>
		<comments>http://thesweeheng.wordpress.com/2009/12/09/american-binomial-model-in-q/#comments</comments>
		<pubDate>Wed, 09 Dec 2009 15:22:04 +0000</pubDate>
		<dc:creator>thesweeheng</dc:creator>
				<category><![CDATA[coding]]></category>
		<category><![CDATA[k&q]]></category>
		<category><![CDATA[binomial]]></category>
		<category><![CDATA[options]]></category>
		<category><![CDATA[pricing]]></category>
		<category><![CDATA[q]]></category>

		<guid isPermaLink="false">http://thesweeheng.wordpress.com/?p=450</guid>
		<description><![CDATA[American-style options may be exercised prior to expiry. To price them on a binomial tree, the full tree has to be constructed. The prices are then computed at each node through a backward reduction process starting from the prices at maturity. At each node, we take the maximum of the payoff at that node versus [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thesweeheng.wordpress.com&amp;blog=806407&amp;post=450&amp;subd=thesweeheng&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>American-style options may be exercised prior to expiry. To price them on a binomial tree, the full tree has to be constructed. The prices are then computed at each node through a backward reduction process starting from the prices at maturity. At each node, we take the maximum of the payoff at that node versus the price implied by the binomial model.</p>
<p>Constructing a binomial price tree is relatively easy in q:</p>
<blockquote>
<pre>BPTree:{[n;S;u] n{(x*y 0),y%x}[u]\1#S}  / binomial price tree
</pre>
</blockquote>
<p>where n is the depth of the tree, S is the current price and u is the scale of the up-move. We simply let the scale of the down-move be 1/u and hence the y%x in the expression.</p>
<p>The general binomial model can then be implemented as follow:</p>
<blockquote>
<pre>GBM:{[R;P;S;T;r;b;v;n]                  / General Binomial Model (CRR)
 t:T%n;                                 / time interval
 u:exp v*sqrt t;                        / up; down is 1/u
 p:(exp[b*t]-1%u)%(u-1%u);              / probability of up
 ptree:reverse BPTree[n;S;u];           / reverse binomial price tree
 first R[exp[neg r*t];p] over P ptree }
</pre>
</blockquote>
<p>where R is a reduction function, P is the payoff function, S is the current price, T is the time to maturity, r is the risk-free rate, b is the cost of carry, v is the volatility and n is the depth of the tree. For American and European options, the reduction functions may be expressed as:</p>
<blockquote>
<pre>American:{[D;p;a;b] max(b;D*(-1_a*p)+1_a*1-p)}
European:{[D;p;a;b] D*(-1_a*p)+1_a*1-p}
</pre>
</blockquote>
<p>where D is the discount factor and p is the probability of an up-move. Consequently, we can express the American and European binomial models simply as:</p>
<blockquote>
<pre>ABM:GBM[American]
EBM:GBM[European]
</pre>
</blockquote>
<p>Testing the code on an American vanilla put option (strike = 102; price = 100; time to maturity = 1 year; risk-free rate = cost of carry = 8%; volatility = 20%; depth of tree = 1000):</p>
<blockquote>
<pre>q) VP:{[S;K]max(K-S;0)}    / vanilla put: max(K-S,0)
q) \t show ABM[VP[;102];100;1;0.08;0.08;0.2;1000]
6.2215
31
</pre>
</blockquote>
<p>It took 31 ms to compute. Pretty nice for so little code.</p>
<p>Note: It turns out that this implementation of EBM is faster than the one in the previous post. The reason is that I avoided using the expensive xexp function this time round. Otherwise, the previous implementation should be faster since it only computes the payoffs at maturity and not the intermediate nodes.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/thesweeheng.wordpress.com/450/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/thesweeheng.wordpress.com/450/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/thesweeheng.wordpress.com/450/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/thesweeheng.wordpress.com/450/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/thesweeheng.wordpress.com/450/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/thesweeheng.wordpress.com/450/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/thesweeheng.wordpress.com/450/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/thesweeheng.wordpress.com/450/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/thesweeheng.wordpress.com/450/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/thesweeheng.wordpress.com/450/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/thesweeheng.wordpress.com/450/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/thesweeheng.wordpress.com/450/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/thesweeheng.wordpress.com/450/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/thesweeheng.wordpress.com/450/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thesweeheng.wordpress.com&amp;blog=806407&amp;post=450&amp;subd=thesweeheng&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://thesweeheng.wordpress.com/2009/12/09/american-binomial-model-in-q/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/4610086cdfe5540d02f3e19cd1f88627?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">thesweeheng</media:title>
		</media:content>
	</item>
		<item>
		<title>European Binomial Model in q and Python</title>
		<link>http://thesweeheng.wordpress.com/2009/12/04/european-binomial-model-in-q-and-python/</link>
		<comments>http://thesweeheng.wordpress.com/2009/12/04/european-binomial-model-in-q-and-python/#comments</comments>
		<pubDate>Thu, 03 Dec 2009 16:48:41 +0000</pubDate>
		<dc:creator>thesweeheng</dc:creator>
				<category><![CDATA[coding]]></category>
		<category><![CDATA[k&q]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[binomial]]></category>
		<category><![CDATA[numpy]]></category>
		<category><![CDATA[options]]></category>
		<category><![CDATA[pricing]]></category>
		<category><![CDATA[q]]></category>
		<category><![CDATA[scipy]]></category>

		<guid isPermaLink="false">http://thesweeheng.wordpress.com/?p=439</guid>
		<description><![CDATA[In the previous post, we created a binomial probability mass function (pmf). We can use that to easily evaluate European-style options: EBM:{[P;S;K;T;r;b;v;n] / European Binomial Model (CRR) t:T%n; / time interval u:exp v*sqrt t; / up d:1%u; / down p:(exp[b*t]-d)%(u-d); / probability of up ns:til n+1; / 0, 1, 2, ..., n us:u xexp ns; [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thesweeheng.wordpress.com&amp;blog=806407&amp;post=439&amp;subd=thesweeheng&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>In the previous post, we created a binomial probability mass function (pmf). We can use that to easily evaluate European-style options:</p>
<blockquote>
<pre>EBM:{[P;S;K;T;r;b;v;n]                 / European Binomial Model (CRR)
 t:T%n;                                / time interval
 u:exp v*sqrt t;                       / up
 d:1%u;                                / down
 p:(exp[b*t]-d)%(u-d);                 / probability of up
 ns:til n+1;                           / 0, 1, 2, ..., n
 us:u xexp ns;                         / u**0, u**1, ...
 ds:d xexp ns;                         / d**0, d**1, ...
 Ss:S*ds*reverse us;                   / prices at tree leaves
 ps:pmf[n;p];                          / probabilities at tree leaves
 exp[neg r*T]*sum P[Ss;K]*ps }
</pre>
</blockquote>
<p>Note that P is the payoff, S is the current price, K is the strike price, T is the time to maturity, r is the risk-free rate, v is the volatility, b is the cost of carry and n is the depth of the binomial tree. The Python version using NumPy and SciPy actually looks quite similar:</p>
<blockquote>
<pre>def EuropeanBinomialModel(P, S, K, T, r, b, v, n):
  n = int(n)
  t = float(T)/n                              # time interval
  u = np.exp(v * np.sqrt(t))                  # up
  d = 1/u                                     # down
  p = (np.exp(b*t)-d)/(u-d)                   # probability of up
  ns = np.arange(0, n+1, 1)                   # 0, 1, 2, ..., n
  us = u**ns                                  # u**0, u**1, ...
  ds = d**ns                                  # d**0, d**1, ...
  Ss = S*us*ds[::-1]                          # prices at leaves
  ps = binom_pmf(ns, n, p)                    # probabilities at leaves
  return np.exp(-r*T) * np.sum(P(Ss,K) * ps)
</pre>
</blockquote>
<p>As we can see, both code has no explicit loops. This is possible in Python as NumPy and SciPy are array-oriented. NumPy and SciPy&#8217;s idea of &#8220;broadcasting&#8221; has some similarity with k/q&#8217;s concept of &#8220;atomic functions&#8221; (<a href="https://code.kx.com/trac/wiki/DotQ/DotQDotfu">definition</a>: <em>a function f of any number of arguments is atomic if f is identical to f&#8217;</em>).</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/thesweeheng.wordpress.com/439/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/thesweeheng.wordpress.com/439/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/thesweeheng.wordpress.com/439/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/thesweeheng.wordpress.com/439/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/thesweeheng.wordpress.com/439/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/thesweeheng.wordpress.com/439/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/thesweeheng.wordpress.com/439/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/thesweeheng.wordpress.com/439/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/thesweeheng.wordpress.com/439/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/thesweeheng.wordpress.com/439/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/thesweeheng.wordpress.com/439/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/thesweeheng.wordpress.com/439/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/thesweeheng.wordpress.com/439/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/thesweeheng.wordpress.com/439/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thesweeheng.wordpress.com&amp;blog=806407&amp;post=439&amp;subd=thesweeheng&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://thesweeheng.wordpress.com/2009/12/04/european-binomial-model-in-q-and-python/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/4610086cdfe5540d02f3e19cd1f88627?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">thesweeheng</media:title>
		</media:content>
	</item>
		<item>
		<title>Binomial distribution in q</title>
		<link>http://thesweeheng.wordpress.com/2009/12/04/binomial-distribution-in-q/</link>
		<comments>http://thesweeheng.wordpress.com/2009/12/04/binomial-distribution-in-q/#comments</comments>
		<pubDate>Thu, 03 Dec 2009 16:33:18 +0000</pubDate>
		<dc:creator>thesweeheng</dc:creator>
				<category><![CDATA[coding]]></category>
		<category><![CDATA[k&q]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[binomial]]></category>
		<category><![CDATA[q]]></category>
		<category><![CDATA[scipy]]></category>

		<guid isPermaLink="false">http://thesweeheng.wordpress.com/?p=433</guid>
		<description><![CDATA[Recently I was using SciPy&#8217;s scipy.stats.binom.pmf(x,n,p). I though it would be great if I could have such a function in q. So a simple idea is to construct a binomial tree with probabilities attached. Recalling that a Pascal triangle is generated using n{0+':x,0}\1, I modified it to get: q)pmf:{[n;p]n{(0,y*1-x)+x*y,0}[p]/1#1f} q)pmf[6;0.3] 0.000729 0.010206 0.059535 0.18522 0.324135 [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thesweeheng.wordpress.com&amp;blog=806407&amp;post=433&amp;subd=thesweeheng&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Recently I was using SciPy&#8217;s <code>scipy.stats.binom.pmf(x,n,p)</code>. I though it would be great if I could have such a function in q. So a simple idea is to construct a binomial tree with probabilities attached. Recalling that a Pascal triangle is generated using <code>n{0+':x,0}\1</code>, I modified it to get:</p>
<blockquote>
<pre>q)pmf:{[n;p]n{(0,y*1-x)+x*y,0}[p]/1#1f}
q)pmf[6;0.3]
0.000729 0.010206 0.059535 0.18522 0.324135 0.302526 0.117649
q)sum pmf[1000;0.3]
1f
</pre>
</blockquote>
<p>What is great about this method is that it is stable. Compared to SciPy 0.7.0, it was more accurate too (it is a known <a href="http://projects.scipy.org/scipy/ticket/620">issue</a> that older SciPy has buggy binom.pmf):</p>
<blockquote>
<pre>&gt;&gt;&gt; scipy.stats.binom.pmf(range(0,41),40,0.3)[-5:]
&gt;&gt;&gt; array([3.33066907e-15, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 1.11022302e-16])
q)-5#pmf[40;0.7]
3.293487e-15 1.52594e-16 5.162955e-18 1.134715e-19 1.215767e-21
</pre>
</blockquote>
<p>Unfortunately this method is too slow for large n. For large n, we need more sophisticated methods. For the interested reader, take a look at Catherine Loader&#8217;s <a href="http://projects.scipy.org/scipy/attachment/ticket/620/loader2000Fast.pdf" target="_blank">Fast and Accurate Computation of Binomial Probabilities</a> paper and an <a href="http://www.boost.org/doc/libs/1_35_0/libs/math/doc/sf_an&lt;/ul&gt; &lt;/ol&gt; &lt;p&gt;d_dist/html/math_toolkit/dist/dist_ref/dists/binomial_dist.html" target="_blank">implementation</a> of a binomial distribution in Boost</p>
<ul></ul>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/thesweeheng.wordpress.com/433/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/thesweeheng.wordpress.com/433/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/thesweeheng.wordpress.com/433/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/thesweeheng.wordpress.com/433/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/thesweeheng.wordpress.com/433/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/thesweeheng.wordpress.com/433/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/thesweeheng.wordpress.com/433/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/thesweeheng.wordpress.com/433/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/thesweeheng.wordpress.com/433/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/thesweeheng.wordpress.com/433/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/thesweeheng.wordpress.com/433/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/thesweeheng.wordpress.com/433/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/thesweeheng.wordpress.com/433/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/thesweeheng.wordpress.com/433/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thesweeheng.wordpress.com&amp;blog=806407&amp;post=433&amp;subd=thesweeheng&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://thesweeheng.wordpress.com/2009/12/04/binomial-distribution-in-q/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/4610086cdfe5540d02f3e19cd1f88627?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">thesweeheng</media:title>
		</media:content>
	</item>
		<item>
		<title>GAE: Storing serializable objects in datastore</title>
		<link>http://thesweeheng.wordpress.com/2009/11/16/gae-storing-serializable-objects-in-datastore/</link>
		<comments>http://thesweeheng.wordpress.com/2009/11/16/gae-storing-serializable-objects-in-datastore/#comments</comments>
		<pubDate>Mon, 16 Nov 2009 14:00:52 +0000</pubDate>
		<dc:creator>thesweeheng</dc:creator>
				<category><![CDATA[coding]]></category>
		<category><![CDATA[gae]]></category>
		<category><![CDATA[hacks]]></category>
		<category><![CDATA[appengine]]></category>
		<category><![CDATA[serializable]]></category>

		<guid isPermaLink="false">http://thesweeheng.wordpress.com/?p=421</guid>
		<description><![CDATA[Google AppEngine&#8217;s datastore supports a variety of simple Types and Property Classes by default. However if we want to store something like a dictionary, we typically have to serialize it and store it as a Blob. On fetching we will de-serialize it. While this approach works, it is repetitive and somewhat error-prone. Wouldn&#8217;t it be [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thesweeheng.wordpress.com&amp;blog=806407&amp;post=421&amp;subd=thesweeheng&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Google AppEngine&#8217;s datastore supports a variety of simple <a href="http://code.google.com/appengine/docs/python/datastore/typesandpropertyclasses.html" target="_blank">Types and Property Classes</a> by default. However if we want to store something like a dictionary, we typically have to serialize it and store it as a Blob. On fetching we will de-serialize it. While this approach works, it is repetitive and somewhat error-prone.</p>
<p>Wouldn&#8217;t it be great if there is a SerializableProperty class that can handle this automatically for us? It doesn&#8217;t exist but according to this <a href="http://code.google.com/appengine/articles/extending_models.html">article</a>, it is easy to create our own customized Property classes. So here is a simple implementation of SerializableProperty that worked for me:</p>
<blockquote>
<pre>import cPickle as pickle
import zlib
from google.appengine.ext import db

class SerializableProperty(db.Property):
  """
  A SerializableProperty will be pickled and compressed before it is
  saved as a Blob in the datastore. On fetch, it would be decompressed
  and unpickled. It allows us to save serializable objects (e.g. dicts)
  in the datastore.

  The sequence of transformations applied can be customized by calling
  the set_transforms() method.
  """

  data_type = db.Blob
  _tfm = [lambda x: pickle.dumps(x,2), zlib.compress]
  _itfm = [zlib.decompress, pickle.loads]

  def set_transforms(self, tfm, itfm):
    self._tfm = tfm
    self._itfm = itfm

  def get_value_for_datastore(self, model_instance):
    value = super(SerializableProperty,
        self).get_value_for_datastore(model_instance)
    if value is not None:
      value = self.data_type(reduce(lambda x,f: f(x), self._tfm, value))
    return value

  def make_value_from_datastore(self, value):
    if value is not None:
      value = reduce(lambda x,f: f(x), self._itfm, value)
    return value
</pre>
</blockquote>
<p>Usage is as simple as this:</p>
<blockquote>
<pre>class MyModel(db.Model):
  data = SerializableProperty()

entity = MyModel(data = {"key": "value"}, key_name="somekey")
entity.put()
entity = MyModel.get_by_key_name("somekey")
print entity.data
</pre>
</blockquote>
<p>Hope that helps!</p>
<p><strong>Update</strong> (20091126): I&#8217;ve changed db.Blob to self.data_type as suggested by Peritus in <a href="http://thesweeheng.wordpress.com/2009/11/16/gae-storing-serializable-objects-in-datastore/#comment-68" target="_blank">Comment</a>. The same comment also suggested a JSONSerializableProperty subclass:</p>
<blockquote>
<pre>import simplejson as json
class JSONSerializableProperty(SerializableProperty):
  data_type = db.Text
  _tfm = [json.dumps]
  _itfm = [json.loads]</pre>
</blockquote>
<p>Thanks Peritus!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/thesweeheng.wordpress.com/421/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/thesweeheng.wordpress.com/421/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/thesweeheng.wordpress.com/421/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/thesweeheng.wordpress.com/421/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/thesweeheng.wordpress.com/421/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/thesweeheng.wordpress.com/421/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/thesweeheng.wordpress.com/421/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/thesweeheng.wordpress.com/421/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/thesweeheng.wordpress.com/421/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/thesweeheng.wordpress.com/421/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/thesweeheng.wordpress.com/421/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/thesweeheng.wordpress.com/421/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/thesweeheng.wordpress.com/421/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/thesweeheng.wordpress.com/421/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thesweeheng.wordpress.com&amp;blog=806407&amp;post=421&amp;subd=thesweeheng&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://thesweeheng.wordpress.com/2009/11/16/gae-storing-serializable-objects-in-datastore/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/4610086cdfe5540d02f3e19cd1f88627?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">thesweeheng</media:title>
		</media:content>
	</item>
		<item>
		<title>Gray code in q</title>
		<link>http://thesweeheng.wordpress.com/2009/09/13/gray-code-in-q/</link>
		<comments>http://thesweeheng.wordpress.com/2009/09/13/gray-code-in-q/#comments</comments>
		<pubDate>Sat, 12 Sep 2009 18:00:59 +0000</pubDate>
		<dc:creator>thesweeheng</dc:creator>
				<category><![CDATA[k&q]]></category>
		<category><![CDATA[gray code]]></category>
		<category><![CDATA[q]]></category>

		<guid isPermaLink="false">http://thesweeheng.wordpress.com/?p=379</guid>
		<description><![CDATA[It is easy to construct binary n-bit Gray code in q using the recursive reflection-prefixing technique: q)gc:{$[x;(0b,/:a),1b,/:reverse a:.z.s x-1;1#()]} q)show gc 4 0000b 0001b 0011b 0010b 0110b 0111b 0101b 0100b 1100b 1101b 1111b 1110b 1010b 1011b 1001b 1000b It is also possible to construct the above iteratively using the formula : q).q.xor:{not x=y} q)gc_iter:{(0b vs [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thesweeheng.wordpress.com&amp;blog=806407&amp;post=379&amp;subd=thesweeheng&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>It is easy to construct binary <em>n</em>-bit <a href="http://en.wikipedia.org/wiki/Gray_code" target="_blank">Gray code</a> in q using the recursive reflection-prefixing technique:</p>
<blockquote>
<pre>q)gc:{$[x;(0b,/:a),1b,/:reverse a:.z.s x-1;1#()]}
q)show gc 4
0000b 0001b 0011b 0010b 0110b 0111b 0101b 0100b
1100b 1101b 1111b 1110b 1010b 1011b 1001b 1000b</pre>
</blockquote>
<p>It is also possible to construct the above iteratively using the formula <img src='http://s0.wp.com/latex.php?latex=n+%5Coplus+%5Clfloor+n%2F2+%5Crfloor&amp;bg=ffffff&amp;fg=183267&amp;s=0' alt='n &#92;oplus &#92;lfloor n/2 &#92;rfloor' title='n &#92;oplus &#92;lfloor n/2 &#92;rfloor' class='latex' />:</p>
<blockquote>
<pre>q).q.xor:{not x=y}
q)gc_iter:{(0b vs x) xor (0b vs x div 2)}
q)show (-4#gc_iter@) each til 16
0000b 0001b 0011b 0010b 0110b 0111b 0101b 0100b
1100b 1101b 1111b 1110b 1010b 1011b 1001b 1000b</pre>
</blockquote>
<p>To check that indeed exactly one bit is flipped each time:</p>
<blockquote>
<pre>q)check:{x[0] (sum@xor)': 1_x}
q)check gc 5
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1</pre>
</blockquote>
<p>To identify the position of the bit that was flipped:</p>
<blockquote>
<pre>q)pos:{raze x[0] (where@xor)': 1_x}
q)pos gc 5
4 3 4 2 4 3 4 1 4 3 4 2 4 3 4 0 4 3 4 2 4 3 4 1 4 3 4 2 4 3 4</pre>
</blockquote>
<p>If we think about it, there is no reason why we have to prefix. We could do suffix as well:</p>
<blockquote>
<pre>q)gc:{$[x;(a,\:0b),(reverse a:.z.s x-1),\:1b;1#()]}
q)show gc 4
0000b 1000b 1100b 0100b 0110b 1110b 1010b 0010b
0011b 1011b 1111b 0111b 0101b 1101b 1001b 0001b
q)check gc 5
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
q)pos gc 5
0 1 0 2 0 1 0 3 0 1 0 2 0 1 0 4 0 1 0 2 0 1 0 3 0 1 0 2 0 1 0</pre>
</blockquote>
<p>In fact, if we are only interested in the positions that need to be flipped, we can use this instead:</p>
<blockquote>
<pre>q)gcpos:{$[x;a,n,a:.z.s n:x-1;()]}
q)gcpos 5
<a href="http://www.research.att.com/~njas/sequences/index.html?q=0+1+0+2+0+1+0+3+0+1+0+2+0+1+0+4+0+1+0+2+0+1+0+3+0+1+0+2+0+1+0&amp;language=english&amp;go=Search" target="_blank">0 1 0 2 0 1 0 3 0 1 0 2 0 1 0 4 0 1 0 2 0 1 0 3 0 1 0 2 0 1 0</a></pre>
</blockquote>
<p>Such a sequence of positions is useful if we are using Gray code to efficiently enumerate the non-zero points spanned by a set of basis vectors:</p>
<blockquote>
<pre>q)basis:(1100000b;0111001b;0000011b)
q){x xor y} scan basis gcpos count basis
1100000b
1011001b
0111001b
0111010b
1011010b
1100011b
0000011b</pre>
</blockquote>
<p><strong>Update</strong> (20090927): Once again, Attila has beaten me at q-golf :-) Here is his formulation:</p>
<blockquote><pre>gc:{x{(0b,/:x),1b,/:reverse x}/1#()}</pre>
</blockquote>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/thesweeheng.wordpress.com/379/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/thesweeheng.wordpress.com/379/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/thesweeheng.wordpress.com/379/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/thesweeheng.wordpress.com/379/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/thesweeheng.wordpress.com/379/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/thesweeheng.wordpress.com/379/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/thesweeheng.wordpress.com/379/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/thesweeheng.wordpress.com/379/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/thesweeheng.wordpress.com/379/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/thesweeheng.wordpress.com/379/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/thesweeheng.wordpress.com/379/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/thesweeheng.wordpress.com/379/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/thesweeheng.wordpress.com/379/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/thesweeheng.wordpress.com/379/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thesweeheng.wordpress.com&amp;blog=806407&amp;post=379&amp;subd=thesweeheng&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://thesweeheng.wordpress.com/2009/09/13/gray-code-in-q/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/4610086cdfe5540d02f3e19cd1f88627?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">thesweeheng</media:title>
		</media:content>
	</item>
		<item>
		<title>Building SAGE 4.1.1 on Fedora 11</title>
		<link>http://thesweeheng.wordpress.com/2009/08/28/building-sage-4-1-1-on-fedora-11/</link>
		<comments>http://thesweeheng.wordpress.com/2009/08/28/building-sage-4-1-1-on-fedora-11/#comments</comments>
		<pubDate>Fri, 28 Aug 2009 13:14:46 +0000</pubDate>
		<dc:creator>thesweeheng</dc:creator>
				<category><![CDATA[hacks]]></category>
		<category><![CDATA[gcc]]></category>
		<category><![CDATA[pari]]></category>
		<category><![CDATA[sage]]></category>

		<guid isPermaLink="false">http://thesweeheng.wordpress.com/?p=308</guid>
		<description><![CDATA[While building SAGE 4.1.1 on a AMD Phenom II running Fedora 11, GCC 4.4.1 will hang the machine when compiling &#8220;base3.c&#8221; of PARI. Apparently it was sucking up all the available memory. According to this thread, it happens on Ubuntu 9.10 too and the solution is to compile with -O1 instead of -O3 optimization. Unfortunately [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thesweeheng.wordpress.com&amp;blog=806407&amp;post=308&amp;subd=thesweeheng&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>While building <a href="http://www.sagemath.org" target="_blank">SAGE</a> 4.1.1  on a AMD Phenom II running Fedora 11, GCC 4.4.1 will hang the machine when compiling &#8220;base3.c&#8221; of PARI. Apparently it was sucking up all the available memory.</p>
<p>According to this <a href="http://pari.math.u-bordeaux.fr/archives/pari-dev-0908/msg00012.html" target="_blank">thread</a>, it happens on Ubuntu 9.10 too and the solution is to compile with -O1 instead of -O3 optimization. Unfortunately it wasn&#8217;t obvious (to me, at least) how to make GCC  use -O1 specifically for PARI only.</p>
<p>Digging around in SAGE&#8217;s build system, I figured it could be done by repacking the PARI spkg with a modified &#8220;get_cc&#8221; script:</p>
<blockquote>
<pre>cd sage-4.1.1/spkg/standard
tar jxf pari-2.3.3.p1.spkg
sed 's/OPTFLAGS=-O3/OPTFLAGS=-O1/g' \
  pari-2.3.3.p1/src/config/get_cc &gt; get_cc
mv get_cc pari-2.3.3.p1/src/config/get_cc
mv pari-2.3.3.p1.spkg pari-2.3.3.p1.spkg.orig
tar jcf pari-2.3.3.p1.spkg pari-2.3.3.p1</pre>
</blockquote>
<p>After that, I was able to compile SAGE using its standard build procedure. Admittedly this is a quick hack. A better solution may be to set OPTFLAGS according to the version of GCC used.</p>
<p>Updates: According to this <a href="http://groups.google.com/group/sage-devel/browse_thread/thread/eb1ce062cb8b206d" target="_blank">thread</a>, it is fixed in Ubuntu Karmic.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/thesweeheng.wordpress.com/308/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/thesweeheng.wordpress.com/308/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/thesweeheng.wordpress.com/308/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/thesweeheng.wordpress.com/308/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/thesweeheng.wordpress.com/308/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/thesweeheng.wordpress.com/308/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/thesweeheng.wordpress.com/308/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/thesweeheng.wordpress.com/308/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/thesweeheng.wordpress.com/308/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/thesweeheng.wordpress.com/308/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/thesweeheng.wordpress.com/308/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/thesweeheng.wordpress.com/308/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/thesweeheng.wordpress.com/308/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/thesweeheng.wordpress.com/308/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thesweeheng.wordpress.com&amp;blog=806407&amp;post=308&amp;subd=thesweeheng&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://thesweeheng.wordpress.com/2009/08/28/building-sage-4-1-1-on-fedora-11/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/4610086cdfe5540d02f3e19cd1f88627?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">thesweeheng</media:title>
		</media:content>
	</item>
		<item>
		<title>Grep binary string</title>
		<link>http://thesweeheng.wordpress.com/2009/08/20/grep-binary-string/</link>
		<comments>http://thesweeheng.wordpress.com/2009/08/20/grep-binary-string/#comments</comments>
		<pubDate>Thu, 20 Aug 2009 08:09:33 +0000</pubDate>
		<dc:creator>thesweeheng</dc:creator>
				<category><![CDATA[hacks]]></category>
		<category><![CDATA[binary]]></category>
		<category><![CDATA[grep]]></category>

		<guid isPermaLink="false">http://thesweeheng.wordpress.com/?p=302</guid>
		<description><![CDATA[A co-worker asked me if it is possible to grep arbitrary binary strings, e.g. sequences of non-printable ASCII characters. It turns out that GNU grep does understand binary strings if we use Perl-regex via the -P option. [sh@pc ~]$ grep -slrP '\x05\x00\xc0' /boot /boot/grub/ffs_stage1_5 /boot/grub/ufs2_stage1_5 /boot/grub/stage2 /boot/efi/EFI/redhat/grub.efi /boot/vmlinuz-2.6.29.6-213.fc11.x86_64 I couldn&#8217;t find this when Googling for [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thesweeheng.wordpress.com&amp;blog=806407&amp;post=302&amp;subd=thesweeheng&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>A co-worker asked me if it is possible to grep arbitrary binary strings, e.g. sequences of non-printable ASCII characters. It turns out that GNU grep does understand binary strings if we use Perl-regex via the -P option.</p>
<blockquote>
<pre>[sh@pc ~]$ grep -slrP '\x05\x00\xc0' /boot
/boot/grub/ffs_stage1_5
/boot/grub/ufs2_stage1_5
/boot/grub/stage2
/boot/efi/EFI/redhat/grub.efi
/boot/vmlinuz-2.6.29.6-213.fc11.x86_64</pre>
</blockquote>
<p>I couldn&#8217;t find this when Googling for &#8220;grep binary&#8221; so I thought I should pen it down here.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/thesweeheng.wordpress.com/302/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/thesweeheng.wordpress.com/302/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/thesweeheng.wordpress.com/302/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/thesweeheng.wordpress.com/302/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/thesweeheng.wordpress.com/302/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/thesweeheng.wordpress.com/302/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/thesweeheng.wordpress.com/302/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/thesweeheng.wordpress.com/302/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/thesweeheng.wordpress.com/302/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/thesweeheng.wordpress.com/302/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/thesweeheng.wordpress.com/302/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/thesweeheng.wordpress.com/302/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/thesweeheng.wordpress.com/302/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/thesweeheng.wordpress.com/302/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thesweeheng.wordpress.com&amp;blog=806407&amp;post=302&amp;subd=thesweeheng&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://thesweeheng.wordpress.com/2009/08/20/grep-binary-string/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/4610086cdfe5540d02f3e19cd1f88627?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">thesweeheng</media:title>
		</media:content>
	</item>
		<item>
		<title>gdata.finance</title>
		<link>http://thesweeheng.wordpress.com/2009/06/07/gdata-finance/</link>
		<comments>http://thesweeheng.wordpress.com/2009/06/07/gdata-finance/#comments</comments>
		<pubDate>Sat, 06 Jun 2009 20:45:17 +0000</pubDate>
		<dc:creator>thesweeheng</dc:creator>
				<category><![CDATA[gdata]]></category>
		<category><![CDATA[finance]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://thesweeheng.wordpress.com/?p=299</guid>
		<description><![CDATA[My contributions (gdata.finance module) to the Google Data APIs Python Client Library has been accepted into version 1.3.3 of the library.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thesweeheng.wordpress.com&amp;blog=806407&amp;post=299&amp;subd=thesweeheng&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>My contributions (gdata.finance module) to the <a href="http://code.google.com/p/gdata-python-client/" target="_blank">Google Data APIs Python Client Library</a> has been accepted into version 1.3.3 of the library.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/thesweeheng.wordpress.com/299/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/thesweeheng.wordpress.com/299/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/thesweeheng.wordpress.com/299/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/thesweeheng.wordpress.com/299/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/thesweeheng.wordpress.com/299/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/thesweeheng.wordpress.com/299/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/thesweeheng.wordpress.com/299/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/thesweeheng.wordpress.com/299/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/thesweeheng.wordpress.com/299/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/thesweeheng.wordpress.com/299/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/thesweeheng.wordpress.com/299/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/thesweeheng.wordpress.com/299/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/thesweeheng.wordpress.com/299/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/thesweeheng.wordpress.com/299/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thesweeheng.wordpress.com&amp;blog=806407&amp;post=299&amp;subd=thesweeheng&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://thesweeheng.wordpress.com/2009/06/07/gdata-finance/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/4610086cdfe5540d02f3e19cd1f88627?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">thesweeheng</media:title>
		</media:content>
	</item>
		<item>
		<title>A Conversation with Arthur Whitney</title>
		<link>http://thesweeheng.wordpress.com/2009/04/27/a-conversation-with-arthur-whitney/</link>
		<comments>http://thesweeheng.wordpress.com/2009/04/27/a-conversation-with-arthur-whitney/#comments</comments>
		<pubDate>Sun, 26 Apr 2009 21:25:19 +0000</pubDate>
		<dc:creator>thesweeheng</dc:creator>
				<category><![CDATA[k&q]]></category>

		<guid isPermaLink="false">http://thesweeheng.wordpress.com/?p=294</guid>
		<description><![CDATA[Arthur Whitney was interviewed on ACM&#8217;s Queue magazine. Here&#8217;s a link to the article and a link to a local PDF copy.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thesweeheng.wordpress.com&amp;blog=806407&amp;post=294&amp;subd=thesweeheng&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Arthur Whitney was interviewed on ACM&#8217;s Queue magazine. Here&#8217;s a link to the <a href="http://queue.acm.org/detail.cfm?id=1531242" target="_blank">article</a> and a link to a <a href="http://thesweeheng.files.wordpress.com/2009/04/p12-interview.pdf" target="_blank">local PDF copy</a>.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/thesweeheng.wordpress.com/294/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/thesweeheng.wordpress.com/294/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/thesweeheng.wordpress.com/294/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/thesweeheng.wordpress.com/294/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/thesweeheng.wordpress.com/294/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/thesweeheng.wordpress.com/294/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/thesweeheng.wordpress.com/294/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/thesweeheng.wordpress.com/294/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/thesweeheng.wordpress.com/294/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/thesweeheng.wordpress.com/294/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/thesweeheng.wordpress.com/294/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/thesweeheng.wordpress.com/294/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/thesweeheng.wordpress.com/294/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/thesweeheng.wordpress.com/294/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thesweeheng.wordpress.com&amp;blog=806407&amp;post=294&amp;subd=thesweeheng&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://thesweeheng.wordpress.com/2009/04/27/a-conversation-with-arthur-whitney/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/4610086cdfe5540d02f3e19cd1f88627?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">thesweeheng</media:title>
		</media:content>
	</item>
	</channel>
</rss>
