My name is Emanuel Carnevale, I write about software and technology, I also keep another tumblelog An onigiri a day and take pictures.
Emanuel Carnevale's Blog
January 9, 2010
Because CouchDB is aimed squarely at the line between the desktop and the cloud, Couch disrupts a lot of the web-physics we’re accustomed too. […] In a CouchDB-enabled web, data-flows don’t have to be centralized, which means friends can communicate without going through a fixed domain. This makes the web more efficient. It also means I can make data available to my social network without relying on 3rd-party services.
August 24, 2009
I hear people saying “JSON is great, XML is over”, but I don’t hear XML partisans saying anything bad about JSON. There are two arguments that are over, though. It seems to me that the great thing about JSON is that it exists for one purpose: to put structs on the wire. With XML, on the other hand, it’s assumed that you might want to stream it in by the gigabyte, or load it into one of a many different in-memory data structures, or run a full-text indexer over the contents, or render it for human consumption, or, well, anything.
May 21, 2009

NSZombieEnabled is an environment variable which controls whether the Foundation runtime will use zombies. When zombies are enabled, a deallocated object’s class is dynamically changed to be _NSZombie, and by default, the memory region is never marked as free, although this can be controlled separately. The end result is that, with zombies enabled, messages to deallocated objects will no longer behave strangely or crash in difficult-to-understand ways, but will instead log a message and die in a predictable and debugger-breakpointable way. This is the tool to use when trying to track down over-releases and premature releases.

March 27, 2009
A pass through the MRI source code reveals that the the Array.sort! is implemented via quicksort. And while the benchmarks do show a four times performance hit when compared to the raw C++ version sorting an array of integers, you have to remember that an equivalent implementation in Ruby is operating on array of integer objects! In other words, native Array.sort! is a highly optimized piece of code: use it, embrace it, and don’t worry about it!
March 12, 2009
Simple rate-limiting algorithm?

marco:

But I can’t figure out a way to do a rolling 60-second period without storing every hit and its timestamp within the rolling window. Is there a good algorithm for doing that in constant space and time (maybe a trick using averages?), or am I pretty much stuck with the fixed calendar-window method?

My proposed solution:

public function allow_hit($id, $limit_per_minute)
{
    $min = idate('i');
    $sec  = idate('s');
    $key = md5($id) . ($min-1) . $sec;
    $count = intval(Cache::get('rate-limiter', $key));
    if($count == 0) { $key = md5($id) . $min . $sec; }
    elseif ($count > $limit_per_minute) return false;
    Cache::set('rate-limiter', $key, $count + 1, /* ttl */ 60);
    return true;
}

($min-1) it doesn’t always work since it’s not modulo 60. I know it, but solving that is trivial, so I didn’t bother implementing it. Hope this helps.

March 10, 2009
GreaseMonkey? I Hardly Know Her

I really like all the works by Justin, from Muxtape to his amazing shots at chromogenic.net, including his own window on the flickrverse: I hardly Know Her and I share a passion for minimalist design.

Here there is a quick GreaseMonkey script that subtly redirects you to the IHKH equivalent of the flickr page you are looking at, provided the owner authorised its publishing.

Anyway, it’s easier to try than to explain, especially while I’m squeezing the writing of the script and this post in my lunch break ;)

UPDATE: To install it easily, just click here within Firefox.


March 2, 2009
instapaper:

I’ve also consolidated some terminology to be more consistent everywhere: “Archive” is gone and has been replaced by “Deleted”. You can still permanently delete articles so that they don’t even show up in the “Deleted” section — just find them in the Deleted section and hit the red “×” button again.

No no no… call it archive, please! Not delete.
Except this, great to see the birth of the starred category!

instapaper:

I’ve also consolidated some terminology to be more consistent everywhere: “Archive” is gone and has been replaced by “Deleted”. You can still permanently delete articles so that they don’t even show up in the “Deleted” section — just find them in the Deleted section and hit the red “×” button again.

No no no… call it archive, please! Not delete. Except this, great to see the birth of the starred category!

February 25, 2009

I bet I’ll be the only one absolutely not thrilled about this news, but really sad instead. Tumblerette’s and Tumblr API main drawback was the lack of API for accessing to a Dashboard, so I made a parser and was writing my own iPhone Dashboard app.

This idea grew from a major itch I had: not being able to read and properly follow my dashboard on the road: MobileSafari memory management flakiness was too much to bear while reading new posts.

But now with a free and officially backed by Tumblr app, my app is nowhere to go, or at least for the meanwhile. I’d better start considering new apps to develop.

Last month hacking nights are not completely wasted since I learned a lot, but still… Anyway, congratulations to everyone and at least I’ll have a great app to use.

February 20, 2009
Get Pinyin readings from Chinese Ideograms with Ubiquity

Mozilla’s Ubiquity is a wonderful thing, especially for an avid Quicksilver user as I am. Nowadays I live in the browser and having this tool across all the platforms I use it’s priceless.

Since the first version I wanted to contribute with some code for the engine or with some commands, but I got overwhelmed and only recently I caved in.

I actually wrote my first Ubiquity command almost a month ago, but I never got around to post a blog post to publish it. It queries my json-zh service for the pinyin character of the selected chinese text and gives you 3 way to deal with the result putting it in the

  1. clipboard,
  2. replacing the selected text
  3. or in a displayed message using Ubiquity’s notification method.

The code is really simple and using the embedded editor is amazing, except that I’d love some debugging facilities.

Working with optional arguments led me thinking about concatenated commands and a way to solve the problem of chaining them. Material for another post or (finally) a message in the ML: guys, you write too much and I barely keep the pace just reading the subjects ;)

Here’s the code, I hope someone will benefit from it.

February 17, 2009

Thanks! (and a way too cool URL ;) )