<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
	<channel>

		<title><![CDATA[jtolds.com - Programming]]></title>
		<link><![CDATA[http://www.jtolds.com/newsletter/category/programming]]></link>
		<description><![CDATA[JT Olds' RSS Feed for Programming]]></description>

		<language>en-us</language>
		<copyright>Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License</copyright>

<item>
	<title><![CDATA[Pubsubhubbub and Superfeedr]]></title>
	<author>JT Olds</author>

	<link><![CDATA[http://www.jtolds.com/newsletter/2009/7/9/pubsubhubbub-and-superfeedr]]></link>

	<guid>1247172810</guid>
	<pubDate>Thu, 9 Jul 2009 20:53:30 +0000</pubDate>
	<description><![CDATA[<p>Occasionally there is a huge hole on the internet that needs to be filled. One such hole is a core part of how <a href="/feeds/">feeds</a> on the internet work. Feeds are currently <a href="http://en.wikipedia.org/wiki/Pull_technology">Polling-based</a> (though I suppose Pull-based is a similar enough name). It's the <a href="/newsletter/2009/3/28/i-finally-figured-out-twitter">same problem that Twitter currently has</a>. Basically all clients have to continually sit and ask if there's any new information, instead of being notified. Notification delivery is how it should work.</p>

<p>Two developments today will help fill this hole, and instead of just sharing them on my <a href="http://www.google.com/reader/shared/03448473034476276773">Google Reader Shared Items</a> feed, I thought I would make an explicit newsletter entry.</p>

<p>First, <a href="http://code.google.com/p/pubsubhubbub/">PubSubHubbub</a>. This holds the promise to fix, for the long term, how feeds work. I'm about as excited about this as I am for <a href="http://wave.google.com/">Google Wave</a>.</p>

<p>More immediately, though, is <a href="http://superfeedr.com/">Superfeedr</a>. I was just <a href="http://ff.im/51c1d">notified via Friendfeed</a> of this new startup that does exactly <a href="http://groups.google.com/group/feedburner-for-developers/browse_thread/thread/443a77ba936e6f56/a6252c12e9d0a905?lnk=gst&q=jtolds#a6252c12e9d0a905">what I've been hoping someone would do for a while now</a>. So, yes! Now my stealth <a href="http://www.snewsflash.com/">SnewsFlash</a> project will be way easier. Thanks, Superfeedr!</p>

<p><b>Update:</b> Well, I'll be. <a href="http://www.techcrunch.com/2009/07/09/gnip-launches-push-api-to-create-real-time-stream-of-business-data/">Gnip, too.</a> Yay!</p>]]></description>
</item>

<item>
	<title><![CDATA[TextMarks]]></title>
	<author>JT Olds</author>

	<link><![CDATA[http://www.jtolds.com/newsletter/2008/8/25/textmarks]]></link>

	<guid>1219642966</guid>
	<pubDate>Mon, 25 Aug 2008 05:42:46 +0000</pubDate>
	<description><![CDATA[Thank heavens. <a href="http://www.textmarks.com/">TextMarks</a> is the developer service I have been looking for. I am so glad someone made this. I figured it was only a matter of time.<br/>
<br/>
I've recently decided that it's too bad <a href="http://en.wikipedia.org/wiki/Short_code">SMS short codes</a> are so prohibitively expensive for small-time developers to SMS-enable their (potentially infrequently used) applications. TextMarks solves this by essentially multiplexing SMS services over one short code, requiring users of each service to prefix their messages with a "textmark" service identifier, thereby cutting costs for everyone. TextMarks pays for the one short code and covers the service fees, allowing small-time developers to use SMS as an application interface. Hooray!]]></description>
</item>

<item>
	<title><![CDATA[Can you make (10, 10, 9, 9, 1, +, /, -, *) = 4?]]></title>
	<author>JT Olds</author>

	<link><![CDATA[http://www.jtolds.com/newsletter/2008/8/24/can-you-make-10-10-9-9-1-4]]></link>

	<guid>1219617348</guid>
	<pubDate>Sun, 24 Aug 2008 22:35:48 +0000</pubDate>
	<description><![CDATA[Last night at around 10pm I got a text from my friend asking how you could combine the numbers 10, 10, 9, 9, and 1, to make 4, using only addition, subtraction, multiplication, and/or division, provided you use the numbers once each.<br/>
<br/>
I didn't start thinking about it until later (sorry Mike), but at 2 am I got frustrated and, as I seem wont to do, ignored reasonable priorities (such as sleeping, or the rest of my todo list) and sat down to write a program to enumerate all of the possible solutions, instead of just figuring it out myself.<br/>
<br/>
Below is a general solution to the problem. The basic idea is it is simple enough to consider all the valid possible combinations of the numbers in Reverse Polish Notation (<a href="http://en.wikipedia.org/wiki/Reverse_Polish_notation">postfix</a>), and evaluate them.<br/>
<br/>
<code>#!/usr/bin/python2.5<br/>
<br/>
def add(x, y): return x + y<br/>
def sub(x, y): return x - y<br/>
def mult(x, y): return x * y<br/>
def div(x, y): return float(x) / y<br/>
OPERATIONS = [add, sub, mult, div]<br/>
REPRESENTATIONS = {add: '+', sub: '-', mult: '*', div: '/'}<br/>
<br/>
def new_counter(counter, item):<br/>
&nbsp; if counter is None: counter = 0<br/>
&nbsp; if type(item) == type(add): return counter - 1<br/>
&nbsp; else: return counter + 1<br/>
<br/>
def valid_perms(lst, counter=None):<br/>
&nbsp; if counter is not None and counter <= 0: return<br/>
&nbsp; if len(lst) == 1:<br/>
&nbsp; &nbsp; if new_counter(counter, lst[0]) != 1: return<br/>
&nbsp; &nbsp; yield lst<br/>
&nbsp; else:<br/>
&nbsp; &nbsp; for i in xrange(len(lst)):<br/>
&nbsp; &nbsp; &nbsp; for perm in valid_perms(lst[:i]+lst[i+1:], new_counter(counter, lst[i])):<br/>
&nbsp; &nbsp; &nbsp; &nbsp; yield [lst[i]] + perm<br/>
<br/>
def all_combos(lst, n):<br/>
&nbsp; if n == 0: yield []<br/>
&nbsp; else:<br/>
&nbsp; &nbsp; for i in xrange(len(lst)):<br/>
&nbsp; &nbsp; &nbsp; for combo in all_combos(lst, n - 1):<br/>
&nbsp; &nbsp; &nbsp; &nbsp; yield [lst[i]] + combo<br/>
<br/>
def uniq(generator):<br/>
&nbsp; seen_things=set([])<br/>
&nbsp; for thing in generator:<br/>
&nbsp; &nbsp; if tuple(thing) not in seen_things:<br/>
&nbsp; &nbsp; &nbsp; seen_things.add(tuple(thing))<br/>
&nbsp; &nbsp; &nbsp; yield thing<br/>
<br/>
def valid_postfix_stacks(nums):<br/>
&nbsp; for op_combo in uniq(all_combos(OPERATIONS, len(nums) - 1)):<br/>
&nbsp; &nbsp; for perm in uniq(valid_perms(nums + op_combo)):<br/>
&nbsp; &nbsp; &nbsp; yield perm<br/>
<br/>
def compute(stack):<br/>
&nbsp; s = []<br/>
&nbsp; for item in stack:<br/>
&nbsp; &nbsp; if type(item) != type(add):<br/>
&nbsp; &nbsp; &nbsp; s.append(item)<br/>
&nbsp; &nbsp; else:<br/>
&nbsp; &nbsp; &nbsp; s.append(item(*reversed([s.pop(), s.pop()])))<br/>
&nbsp; assert len(s) == 1<br/>
&nbsp; return s[0]<br/>
<br/>
def infix(stack):<br/>
&nbsp; s = []<br/>
&nbsp; for item in stack:<br/>
&nbsp; &nbsp; if type(item) != type(add):<br/>
&nbsp; &nbsp; &nbsp; s.append(str(item))<br/>
&nbsp; &nbsp; else:<br/>
&nbsp; &nbsp; &nbsp; s.append('(' + ' '.join(reversed([s.pop(), REPRESENTATIONS[item], s.pop()])) + ')')<br/>
&nbsp; assert len(s) == 1<br/>
&nbsp; return s[0]<br/>
<br/>
def main(nums, answer, tol=.0001, find_all=False):<br/>
&nbsp; print "searching..."<br/>
&nbsp; found = False<br/>
&nbsp; for postfix_stack in uniq(valid_postfix_stacks(nums)):<br/>
&nbsp; &nbsp; try: val = compute(postfix_stack)<br/>
&nbsp; &nbsp; except ZeroDivisionError, e: continue<br/>
&nbsp; &nbsp; if (float(val) + float(tol)/2 >= float(answer) and float(val) - float(tol)/2 <= float(answer)):<br/>
&nbsp; &nbsp; &nbsp; print infix(postfix_stack), '=', val<br/>
&nbsp; &nbsp; &nbsp; found = True<br/>
&nbsp; &nbsp; &nbsp; if not find_all: break<br/>
&nbsp; if not found: print "no solutions found"<br/>
 <br/>
if __name__ == "__main__":<br/>
&nbsp; main([10,10,9,9,1], 4)</code>]]></description>
</item>

<item>
	<title><![CDATA[How to get V4L2 devices to work with Flash]]></title>
	<author>JT Olds</author>

	<link><![CDATA[http://www.jtolds.com/newsletter/2008/7/27/how-to-get-v4l2-devices-to-work-with-flash]]></link>

	<guid>1217200446</guid>
	<pubDate>Sun, 27 Jul 2008 23:14:06 +0000</pubDate>
	<description><![CDATA[<h3>Background</h3>Recently, I wanted to get a webcam I have working with <a href="http://www.tokbox.com/">TokBox</a>. The allure of TokBox is great, since it's videochatting with no downloadable software, as long as you have Flash set up correctly. Unfortunately, however, Flash currently supports Video4Linux version 1 devices, and most new webcam drivers for Linux are Video4Linux version 2. 
<br/>

<br/>
As of this writing, <a href="http://labs.adobe.com/technologies/flashplayer10/">Flash 10</a> Beta 2 is the most recent release of Adobe Flash, and it now <a href="http://blogs.adobe.com/penguin.swf/2008/07/turkish_localization_also_wmod.html">has support for V4L2 devices</a>! However, not many devices (<a href="http://blogs.adobe.com/penguin.swf/2008/07/paparazzi_v2_1.html">help out here</a>), and if you're not the sort of person that wants to uninstall your comforting Flash Player deb package for some beta tarball, Flash 10 Beta 2 isn't actually the solution yet.
<br/>

<br/>
So, I started looking for another way. Well, <a href="http://www.gstreamer.net/">Gstreamer</a> supports my webcam, and most other V4L2 devices, so if there was a way of converting a Gstreamer pipeline to a V4L (v1) device, then I'd be set. Turns out, there is! <a href="http://code.google.com/p/gstfakevideo/">gstfakevideo</a> was written so that Skype users could get better webcam support in Linux.
<br/>

<br/>
So now, if you want to get your Gstreamer-supported V4L2 video device to work with Flash (even pre-V4L2 supporting builds of Flash), follow these instructions. I admit they're a bit high-level.
<br/>

<br/>
<h3>Implementation</h3>First, grab <a href="http://code.google.com/p/gstfakevideo/">gstfakevideo</a>. I did everything with the repository's revision 3 (the latest at the time of this writing), so if the gstfakevideo people change something, these instructions will work with codetree version 3.
<br/>

<br/>
Stupidly, gstfakevideo is hardcoded to intercept any attempts to grab /dev/video0. You'll probably want to change that so applications can see all of your video devices, including the fake one we're about to make. I plan on submitting a patch to the gstfakevideo people soon so this is configurable, but haven't yet.
<br/>

<br/>
To fix this for now, you'll need to edit both the gstfakevideo shell script and gstfakevideo.c source before compilation. Just pick an unused video device name and change all instances in both files of /dev/video0 to your new video device. I just used /dev/video1. Then compile.
<br/>

<br/>
Next, find in the gstfakevideo script where it says "exec skype". Change that to exec firefox, or whatever webbrowser you use. Make sure you close your running webbrowser instances. Then, on your command line, try "./gstfakevideo v4l2src ! ffmpegcolorspace ! videoscale". All we're doing here is setting up a Gstreamer pipeline that the gstfakevideo library will convert to a V4L device. This should launch your webbrowser. Navigate to a website that has Flash and right click the Flash applet. Go to settings, and select the webcam tab. Change the input device to the gstfakevideo device and click the webcam icon box to see if it works. If it does, you're set.
<br/>

<br/>
If it doesn't work, there's a chance that figuring out a different Gstreamer pipeline would work better (the pipeline is the "v4l2src ! ffmpegcolorspace ! videoscale" part). If you can get the pipeline "videotestsrc is-live=true ! ffmpegcolorspace ! videoscale" to work, then Gstreamer is probably not the problem. Play around with pipelines (help elsewhere). You can test pipelines by using gst-launch (gst-launch-0.10 on Ubuntu Hardy). You'll need to add ! xvimagesink at the end of any pipeline given to gst-launch.
<br/>

<br/>
Once you have a working system, you can make the whole process a little easier to start up the next time around by replacing the line that says 'GST_PIPE="$*"' in the gstfakevideo script with 'GST_PIPE="v4l2src ! ffmpegcolorspace ! videoscale"' (or whatever pipeline you figured out), moving the libgstfakevideo.so file to /usr/local/lib, and renaming gstfakevideo to a name that makes more sense, like firefox-video. Then, move the script to somewhere more useful like ~/bin.  
<br/>
Every time you run that script, you'll start your browser with Flash support for your V4L2 Gstreamer default input device (configurable with gstreamer-properties). Since all you need is your compiled libgstfakevideo.so library and the script you just moved, you can delete the source directory.
<br/>

<br/>
Hooray!
<br/><br/>]]></description>
</item>

<item>
	<title><![CDATA[Mox]]></title>
	<author>JT Olds</author>

	<link><![CDATA[http://www.jtolds.com/newsletter/2008/7/17/mox]]></link>

	<guid>1216253205</guid>
	<pubDate>Thu, 17 Jul 2008 00:06:45 +0000</pubDate>
	<description><![CDATA[In working on <a href="/projects/1/">Viricide</a>, I spent a good deal of time writing unit tests for the server portion. The majority of my previous Python unit testing experience being at Google, I looked around on the internet for potentially similar solutions to write my unit tests in.<br/>
<br/>
I was surprised to discover that mock-object unit test frameworks for Python essentially boiled down to the following three solutions:<ul><li>The Python Mock Module (<a href="http://python-mock.sourceforge.net/">http://python-mock.sourceforge.net/</a>)</li><li>pMock (<a href="http://pmock.sourceforge.net/">http://pmock.sourceforge.net/</a>)</li><li>Python Mocker (<a href="http://labix.org/mocker">http://labix.org/mocker</a>)</li></ul>I didn't like any of the solutions, really, as they all seemed to have various glaring problems or inconveniences (the specifics of which I have forgotten), but I settled on Mocker as it was closest to the Google mock-object system, right after sending an email to a friend at Google requesting that they open source what I was used to.<br/>
<br/>
It appears that my friend totally pulled through, sent an email to the right people, and <a href="http://code.google.com/p/pymox/">Mox</a> was released on Google Code in mid-June.<br/>
<br/>
Though I first noticed that Mox was available for download the day <a href="http://code.google.com/p/protobuf/">Protocol Buffers</a> were released on Google Code (Mox is included in the Protocol Buffer source distribution as it is required for unit tests), the <a href="http://google-opensource.blogspot.com/2008/07/check-out-mox-our-mock-object-framework.html">Google blog is now announcing Mox for general availability</a>.<br/>
<br/>
I guess I'm not surprised the announcement references other former Googlers requesting it, as it's a pretty sweet mock-object system. But hooray!<br/>
<br/>
Also, do check out <a href="http://code.google.com/p/protobuf/">Protocol Buffers</a>. I'm pretty excited about them, too.]]></description>
</item>

<item>
	<title><![CDATA[My OLPC software is actually useful!]]></title>
	<author>JT Olds</author>

	<link><![CDATA[http://www.jtolds.com/newsletter/2008/5/9/my-olpc-software-is-actually-useful]]></link>

	<guid>1210367795</guid>
	<pubDate>Fri, 9 May 2008 21:16:35 +0000</pubDate>
	<description><![CDATA[In February, I received an <a href="http://www.laptop.org/">OLPC laptop</a> as part of their Give1Get1 program. One of the things it was missing was a way of launching native Linux applications and commands without opening a terminal, so I wrote a simple OLPC Activity that provided this ability to some extent. The project page is <a href="http://web.jtolds.com/projects/8/">here</a>.<br/>
<br/>
Early this week I found out that my little project is of some use to the <a href="http://www.teachingmatters.org/">Teaching Matters</a> non-profit, and they are now rolling out my app on XO laptops in NYC.<br/>
<br/>
<a href="http://olpcnyc.wordpress.com/2008/05/09/connecting-to-hidden-wifi-networks/">Here's the blog post where I'm mentioned.</a>]]></description>
</item>

<item>
	<title><![CDATA[Holy crap: Google App Engine!]]></title>
	<author>JT Olds</author>

	<link><![CDATA[http://www.jtolds.com/newsletter/2008/4/8/holy-crap-google-app-engine]]></link>

	<guid>1207644230</guid>
	<pubDate>Tue, 8 Apr 2008 08:43:50 +0000</pubDate>
	<description><![CDATA[<span class="highlight"><b>Update:</b> whoa, check out one of the first demo apps: <a href="http://huddlechat.appspot.com/">HuddleChat</a><br/>
<b>Update 2:</b> as usual, <a href="http://googleappengine.blogspot.com/2008/04/introducing-google-app-engine-our-new.html">Google does a better job of explaining their own products</a> than I do.</span><br/>
<br/>
Probably unsurprisingly, there are a number of unlaunched Google projects I learned about while I worked there last summer. Unfortunately, I've had to keep my lips completely sealed due to the NDA I signed. So, I've had some amount of quiet and unshared (at least, outside of Google) anticipation for a number of different things I happen to know Google has been working on.<br/>
<br/>
Few of these things, however, even come close to matching my anticipation for the service that was finally released today.<br/>
<br/>
Even though I knew Google planned to release a web-services platform, I didn't fully understand the details. I was sort of expecting a me-too competitor to <a href="http://aws.amazon.com/">Amazon Web Services</a>, and figured Amazon had simply beaten Google to the punch here. Hey, it could happen.<br/>
<br/>
However, with the public release of <a href="http://code.google.com/appengine/">Google App Engine</a>, I am again blown away by the details with which Google nailed this product.<br/>
<br/>
TechCrunch <a href="http://www.techcrunch.com/2008/04/07/google-jumps-head-first-into-web-services-with-google-app-engine/">just covered</a> the launch, and although their initial article simply reported the news, I expected more thought and speculation on how much this is a game-changer. Every crappy part of AWS is fixed. There are some limitations that Google App Engine has that AWS doesn't (only Python is supported, say), but these are silly when compared to the limitations of AWS*:<ul><li>cost - App Engine is free under certain very reasonable limits, AWS is not.</li><li>elasticity - load balancing and replication are <span class="highlight">automatic</span> with App Engine, not AWS</li><li>simplicity - the only work involved with App Engine is writing some Python code; you don't have to manage your own virtual machine images</li></ul>* I haven't actually used AWS, and I've only used internal Google technologies (basically App Engine, but not exactly), so this feature comparison is based on my loose reading of news clippings.<br/>
<br/>
Here's what I see happening:<ol><li>The barrier to entry for scalable website design is totally lowered. Tons of developers see this and go "ooh, neat, I can write that personal project pretty easily now" and do so.</li><li>Some of these projects become financially viable from Google Advertising, but where the costs would usually go straight into maintenance for the growing user demand, Google manages it all very cheaply and efficiently. Instead of developers having to choose between killing their project due to too much demand or quitting their day job just to support it, Google eases the maintenance of the site considerably. Futhermore, the cost-effectiveness of running your own service is now much better due to the low over-head costs. Developers actually could quit their day jobs.</li><li>Many new, innovative services start springing up like wildfire, and don't be surprised to find that they're all only one or two man shops.</li></ol><br/>
I've already been convinced that <a href="http://code.google.com/android/">Android</a> is going to completely revolutionize the cellphone market, and I feel the same way about Google App Engine. Even though AWS really started this product space, App Engine seems like enough done right that this will open the floodgates on cloud application hosting. I do not expect Google App Engine to simply be a footnote in the history of the internet.<br/>
<br/>
If you're interested in developing for App Engine, make sure you <a href="http://appengine.google.com/">sign up soon</a>, as there's only a limited number of trial accounts during the preview release.<br/>
<br/>
We could totally rewrite <a href="http://www.chipmark.com/">Chipmark</a> on Google App Engine. That would be sweet.]]></description>
</item>

	</channel>
</rss>
