plaintext

Fall in New York

leave a comment »

Generally beautiful, New York City is even beautiful-er when autumn foliage comes around. So it was cool to discover this Flickr set of scanned leaves from Morningside Park – literally 3 blocks from where we live.

(Via what about the plastic animals, via Outside.in)

Written by Nir

December 1, 2009 at 4:52 pm

Posted in design, other, systems

Tagged with , , ,

Google App Engine Quotas on > 430k Requests/Day

with 4 comments

[UPDATE: Posted this yesterday for >140k requests/day, updating now with >430k requests..]

TheRealURL had a particularly busy Thanksgiving Day Black Friday for some reason. Just for curiosity’s sake, here’s the quota usage for a GAE application under a relatively high load. The quotas that aren’t pictured are all on %0. Billing is now turned on (for the Incoming Bandwidth) but limited to up to $1/day – and was never used yet.

Bear in mind this is a pretty minimal app, of course, but still – not too shabby.

Written by Nir

November 27, 2009 at 12:47 pm

UnShorten WordPress Plugin Uses TheRealURL

with 2 comments

I recently found that Jon Rogers, a developer from the UK, released the UnShorten WordPress plugin, which uses TheRealURL to unshorten links displayed by the Twitter Tools plugin.

That’s pretty cool, TheRealURL was designed as a web service with exactly this type of use in mind.

Between this and other users TheRealURL now serves over 40,000 requests a day. It’s nice to see Google App Engine handling that with barely using any of the various daily quotas (except for incoming bandwidth… Need to check on that one):

TheRealURL GAE Quota Usage

Written by Nir

November 10, 2009 at 3:09 pm

Posted in The Real URL, code

So Beautiful.

leave a comment »

Jenny Pollak’s foggy window shots.

jenny_pollak_07

(Found via FFFFOUND)

Written by Nir

October 10, 2009 at 11:53 am

Posted in web

Obscure

leave a comment »

i love working on an obscure book. people cling to ideas, because they’re supposed to be vouchers for a million dollars. no, write an obscure book. build something outside all that pressure. i guess treehouses for kids qualify.

_why, Sep 2004

Where’s _why? I do hope all is OK.

Written by Nir

August 19, 2009 at 6:17 pm

Posted in web

TheRealURL Adds Page Titles

leave a comment »

I needed this for a project I’m working on, so I added a new feature to TheRealURL unshortening service: JSON/P requests now return the page title (scraped from the HTML <title> tag) as well as its original URL.

For example, http://therealurl.appspot.com/?format=json&url=bit.ly/a returns:

{ "url" : "http://www.apple.com/", "title" : "Apple" }

The plain text format remains as is – nothing but the unshortened URL – so I don’t think there should be any issues for existing API users. Response times don’t appear to be affected much either. If you do get any issues, please let me know in the comments or at niryariv@gmail.com.

Written by Nir

July 17, 2009 at 1:29 pm

Posted in The Real URL, code, projects

The Long Poll: AJAX Push(like) Chat with Comet

with 4 comments

Recently I’ve been working on an AJAX based chat application (in development..). The obvious way to do it is send an XMLHttpRequest every few seconds to check for new messages. Unless it’s a particularly animated conversation most requests won’t return any new content, so I added a simple Conditional-GET like system based on the chat’s text size. Here’s the client side implementation:

function refresh_chat() {
	$.ajax({
	  	url: "/chat",
	   	data: "format=xhr&chat_id={{chat_id}}&cur_len=" + chat_content.length,
		  complete: function(xhr){
				if (xhr.status == 200) render_chat(xhr.responseText);
				setTimeout("refresh_chat()", 5000)
		  }
	 });
}

And the server code that handles it:

cur_len = self.request.get("cur_len", 0)
if len(chat.content) == int(cur_len):
	self.error(304) # return 304 Not Modified
else:
	self.response.out.write(chat.content) # return new content

That’s basically the standard approach. Pretty simple, works ok (could be optimized a bit, for example return only the actual new content etc). It’s not exactly an elegant design, though. Trying to use HTTP, designed as a Pull protocol, for an application that requires Push results creates this system of frequent server requests with empty responses, kind of like the “Are we there yet?” conversations with kids on long road trips.

Jack Moffitt’s JSConf talk introduced me to the concept of Long Polling, aka Comet or (with a lot added) BOSH, as a way to simulate HTTP Push. Rather than have the client sending a lot of short, frequent requests and the server responding to each as fast as possible, long polling turns it around: the server holds the requests as long as it can, returning a response only when it has new data or a timeout limit was hit. So, instead of sending request every 3 seconds, for example, you can send one every 30 seconds.

Client side code remains almost the same:

function refresh_chat() {
	$.ajax({
	  	url: "/chat",
	   	data: "format=xhr&chat_id={{chat_id}}&cur_len=" + chat_content.length,
		  complete: function(xhr){
				if (xhr.status == 200) render_chat(xhr.responseText);
				setTimeout("refresh_chat()", 1000);
		  }
	 });
}

But on the server side, there’s a bit of new logic to keep checking for new content while the server holds the response:

cur_len = self.request.get("cur_len", 0)
end_by = int(time.time()) + 30

while int(time.time()) < end_by:
	if len(chat.content) != int(cur_len):
		return self.response.out.write(chat.content) # return new content

	time.sleep(1)

self.error(304) # return 304 Not Modified

If you have any experience building web applications, you’ve spent a lot of effort making sure servers respond quickly to requests. Delaying the response is counter-intuitive, which in itself makes Comet useful to know, if only for its new perspective. However, this also makes production use a bit complicated, since most web server stacks are optimized for maximum requests/second rather than long concurrent requests. Content-rich sites often use separate servers for big media content for this reason, and Comet also has its own server (er “HTTP-based event routing bus”) in Cometd.

Written by Nir

July 13, 2009 at 3:43 pm

Posted in code, design, web

Tagged with , , , , ,

FeedVolley: Messages From Iran

leave a comment »

I just put up a quick hack I made with FeedVolley (more about FV here), that aggregates Twitter (and other media) feeds coming from inside Iran: Messages From Iran

I don’t know about news value, but it’s pretty cool to be able to refresh that page now and then and get a snapshot of the current mood and happenings, in these possibly historic times there.

It was also cool to find another use for FeedVolley, which I neglected a bit recently ;) I added some page caching on top of the existing feed caching, to allow it to handle some traffic (Slicehost’s 256MB slices seem to start sending swap alerts as soon as traffic rises above negligible). The sources are basically the ones listed here, with a few additional ones I’m trying to find. In fact, if you really want to keep a close watch on what’s going on, you may want to watch the FriendFeed stream – the FeedVolley page is really just an HTML skin to make the feed look a little nicer (hopefully).

(Favorite tweet so far: “@jonobacon IRC is blocked. Tell our regards to Ubuntu Global Jam from Iran. I’m twitting the #iranElection story from a Kubuntu machine :)“. Makes me think of starting to use Twitter again..)

Written by Nir

June 18, 2009 at 12:33 pm

Posted in code, feedvolley, rss

The Case for Working With Your Hands

with one comment

I love this NY Times article not just because it reminds me of my old motorcycle which I enjoyed fixing almost as much as riding (and spent almost as much time doing, anyway), but especially for the arguments it makes about the irrelevance of much of conventional “wisdom” about careers, education and happiness in today’s world. It feels great to read your own views and thoughts put in a coherent, clear form. The Case for Working With Your Hands.

Written by Nir

June 7, 2009 at 3:26 pm

Posted in other

41411 Rmmbr: Text Your Inbox

leave a comment »

rmmbr is a service I built for myself and recently opened for general use. I wanted a way to send myself notes about things I need to do, items I want to research etc. If just write this on a scrap of paper I usually seem to forget about it, so using Textmarks‘ web-SMS gateway (which is pretty nice btw – reliable and easy to interface with) I wrote a little web app that lets me text these notes to my inbox.

The examples on rmmbr’s home page are pretty much how I use it – I come across some term I want to research or am reminded of something I need to do and send an text message like rmmbr <whatever> to 41411. When I get back home an email is waiting in my Gmail inbox with the text sent, a Google search link for it, and if it’s an address or a date Gmail might also attach its “map this” or “add to calendar” links as well.

To start using it, you need to let rmmbr connect your phone # with your email address by texting rmmbr signup <your@email> to 41411. You’ll get a confirmation email and can start sending yourself messages. Just remember to always start the message with “rmmbr” – it still gets me sometimes..

I don’t know how useful it would be for anyone with an iPhone or a Blackberry, but if you’re like me and prefer to keep your cellphones small, cheap and low maintenance, you might find this a useful solution for your text-to-inbox needs. Enjoy :)

[Update: formerly rmbr, the app/sms code is now rmmbr, to prevent confusion with rmbr.com - which is a different product, not related to rmmbr in any way]

Written by Nir

May 7, 2009 at 2:47 pm

Posted in projects, rmmbr, web