Moved!

I have fallen head over heels for Tumblr, and will continue this blog over there. The DNS should update in a few days, if not before. I’ll see about importing the old posts in there too, but no promises!

Leave a Comment

1,000,000,000 seconds old

Re-reading Accelerando recently. Throughout the book they dispense with years, months, days, hours and minutes and instead measure longer timespans in Mega and Giga seconds. Personally I find such big numbers hard to deal with, so I converted them to familiar units. What blew me away is the scale of the difference between the two numbers. A Megasecond is only around 11.5 days, but a Gigasecond is more than 31 years, 9 months and 9 days!

When I realised this I was 31 years and about 7.5 months, and since then I thought the day for me was yesterday. (I even noted so on twitter. And Facebook. The shame.) However today I was challenged on it. Since I could not find the program I wrote previously I whipped up a new one. Here it is:

#!/usr/bin/perl
use strict;
use warnings;
use DateTime;
my $date = DateTime->new( time_zone => 'floating', @ARGV )
	or die "Could not get date from input!";
printf "If your birth date is: %s\n", $date;
for (qw/ 1e6 1e9 /) {
	my $date2 = $date->clone->add( seconds => $_ );
	printf " .. your birth date plus $_ seconds is: %s\n", $date2;
}
printf " .. and you are now %d seconds old\n", (DateTime->now->epoch - $date->epoch);

I then texted mom to find out exactly when on the day I was born and after a quick response could call the script with the following arguments:

./1e9.pl year 1978 month 4 day 24 hour 12 minute 35

The output produced is:

If your birth date is: 1978-04-24T12:35:00
 .. your birth date plus 1e6 seconds is: 1978-05-06T02:21:40
 .. your birth date plus 1e9 seconds is: 2009-12-31T14:21:40
 .. and you are now 1000012821 seconds old

So, it turned out that I either misremembered or miscalculated before: today is actually the day when I turned 1,000,000,000 seconds old. Happy 1e9 seconds day to me!

Leave a Comment

JSON.framework v2.2 released!

I am proud to present version 2.2 of JSON.framework, the strict JSON parser/generator for Cocoa and the iPhone. You can get the latest version from the download page.

Here are the more significant changes from the 2.1 series:

  • New, fresh API—particularly for errors

    Extracted the SBJsonWriter and SBJsonParser classes from the SBJSON class. These present a fresh, simple API. If a method returns nil, you can now simply call a method to get an array of NSError objects containing the error trace.

    The SBJSON class is now a facade, implementing its old interface by forwarding messages to instances of the new classes. Additionally, the facade also implements the new simplified interface of the SBJsonWriter and SBJsonParser classes.

    The category methods on Foundation objects have also been re-implemented more efficiently in terms of the new objects. In case of error in these methods now print the full trace to the log, rather than just the top-level error.

  • Support for JSON representation of custom objects

    If you implement the -proxyForJson method in a custom class (either directly or as category) this now enables JSON.framework to create a JSON representation for objects of that type. See the ProxyTest.m file for more information on how this works.

  • Deprecated fragment-based methods

    The fragment-based methods are an extension to the JSON spec that does not belong in a strict JSON parser/generator. They were originally implemented to ease testing, but the tests should rather be rewritten not to need them. For the time being they are still included, but will be removed in the 2.3.x line.

  • Updated the iPhone SDK

    The iPhone SDK has had some updates to address problems some people were seeing. It has been updated to be based on iPhoneOS v2.2.1.

  • Fix crash on recursive structures

    Implemented the maxDepth setting for writing JSON. This defaults to 512 and means the framework won’t crash if its is fed a recursive (or extremely deeply nested) structure.

  • Documentation updates

    Simplified the installation instructions, particularly for the iPhone.

    In the API documentation classes now inherit documentation from their superclasses and the protocols they implement.

  • Miscellaneous

    Fixed some warnings reported by the Clang static analyser.

    Added a Changes file and updated the Credits.

Comments (9)

Older Posts »
Follow

Get every new post delivered to your Inbox.