Rocket code

RSS

Sparrow acquired by Google

Today on http://sprw.me/

We’re excited to announce that Sparrow has been acquired by Google!

We care a lot about how people communicate, and we did our best to provide you with the most > intuitive and pleasurable mailing experience.

Now we’re joining the Gmail team to accomplish a bigger vision — one that we think we can better achieve with Google.

We’d like to extend a special thanks to all of our users who have supported us, advised us, given us priceless feedback and allowed us to build a better mail application. While we’ll be working on new things at Google, we will continue to make Sparrow available and provide support for our users.

We had an amazing ride and can’t thank you enough.

Full speed ahead!

Dom Leca CEO Sparrow

So my preferred mail client on OSX and iOS got aquired by Google which is ok-ish … were it not that they’ll completely stop development and start working on Google products. That just fucked up my day … I’ll have to see where this goes, maybe Google will launch a native mail client soon or improve their iOS Gmail App with the help of the Sparrow devs. I don’t know, but for the moment being I feel fucked. Simple as that.

PS: had to get that off my chest really :)

Jul 9

Testing REST webservices with browser extensions

I’ve been developing a REST webservice for some time now and I’ve found it hard to find the right tools to actually trial and error test the API we are building. For simple GET or even POST requests a browser is good enough, but when you need to do a DELETE or PUT request your browser is no longer an option. And that’s where some excellent browser extensions come in. There is a pretty large amount of Chrome extensions especially created for making HTTP/REST requests.

These are some of the extensions for Chrome i’ve tried in order of my personal preference.

  • Postman, Really nice tool with a clear interface, support for oAuth and basic HTTP auth and possibility to create collections to save your requests for easy access later on.
  • Dev HTTP Client, an excellent HTTP Client with a nice interface and all options you’ll need. You can also save your requests and bundle them as an export to share them with fellow devs.
  • REST Console, Feature complete yet a little lacking on the interface part, not really intuitive.

There are others but these three are the best I’ve found for Chrome, currently I’m using Postman and haven’t had any trouble.

One thing that could give any of these tools an extra advantage would be HATEOAS compatibility. It would be really nice to allow these tools to allow exploring a complete RESTFULL API without having to manually copy/paste the URI’s all over. That’s something for the future perhaps?

I’ve also given soapUI another try but must admit that it’s a horrific tool to use. I’ve used it before to access a third party soap API and it worked pretty fine back then, not really user friendly but what do you expect of a Java based app by and for developers. But the new 4.5 release won’t even start most of the time and when it does it locks up. Thus I’m back to using browser based REST clients.

If you know of any other tools that are worth trying don’t hesitate to comment and I’ll give them a try. Maybe there are even beter tools that I don’t know of.

preppeller:

Alfred 1.3 is coming along great! One new feature which has been a long time requested and desired feature is the ability to work with multiple file selections in Alfred for actions such as copying, deleting, extensions etc.
Above is a new concept being introduced in 1.3 which will allow you to quickly stack up files in a buffer from both the default results and file system navigation which can then subsequently be actioned all in one go!
I hope to have the first 1.3 development / test release with this feature available later on this week for you to have a play with :)
Cheers,Andrew 

preppeller:

Alfred 1.3 is coming along great! One new feature which has been a long time requested and desired feature is the ability to work with multiple file selections in Alfred for actions such as copying, deleting, extensions etc.

Above is a new concept being introduced in 1.3 which will allow you to quickly stack up files in a buffer from both the default results and file system navigation which can then subsequently be actioned all in one go!

I hope to have the first 1.3 development / test release with this feature available later on this week for you to have a play with :)

Cheers,
Andrew 

Redundant HTML tags

Since the dawn of HTML5 a lot has changed in building valid HTML pages. What many people don’t know is that in order to present a valid HTML5 document you don’t even need the <html>, <head> or <body> tags no more … how cool is that?

<!DOCTYPE html>
<meta charset="utf-8">
<title>My Blog</title>
<article>This is only a test.</article>

This is perfectly valid HTML5 and to be honest, from now on I’m using this minimal approach, no need to add all those redundant tags that serve no real purpose.

More useful tips are to be found in the Google HTML/CSS Style Guide, an interesting read.

Apr 2

Why relative date notations suck … most of the time

Relative date notations are nice, when reading blog comments it makes so much more sense to know that someone replied “3 days ago” instead of knowing that someone replied on the “29th of march 2012”. It’s easier to read and intuitive, after all you want to know how long ago someone replied, not exactly when most of the time.

Github’s gist system uses the same relative date notation to indicate when a revision of a gist was created.

At first it seems like a good idea but it quickly becomes unusable when we fast forward a few months. Suddenly where the revisions first said “21 days ago”, “22 days ago” and “23 days ago” … they all say “9 months ago”.

How is a user supposed to know what revision is the most recent when the date gives you the exact same information for all revisions? The hash that is listed next to each revision isn’t helpful either since it isn’t incremental. Experienced users might have grown used to the most recent revision being on top but that’s not true for all users.

My advice? Switch to absolute date notations for commits older than a few months, then the list becomes actually usable. And that goes for all relative date notations, not only on the Github gist system!

Thanks for listening @github :)

The “Self Executing Function” pattern in PHP

Every modern day web developer knows (or at least should know) the self executing function pattern in javascript. It’s an easy way to run your code in a closure and thus avoid variable naming collisions among other things.

// Alerts 5
var a = 1;
(function(){
    var a = 2;
    var b = 3;
    alert(a + b);
})();

Every PHP Developer also knows (or again, at least should know :p) that this is also possible with PHP 5.3 Closures or anonymous functions. This makes that the same pattern now is also usable in PHP.

// Prints 5
$a = 1;
call_user_func(function() {
    $a = 2;
    $b = 3;
    echo $a + $b;
});

This especially comes in handy when working on legacy applications. I’ve recently had to write some patches and updates for a system that holds thousands of lines of unstructured non-oop spaghetti code and a global scope polluted with hundreds of variables with the most exotic names. Instead of fearing I’d overwrite some of those sketchy variable somewhere in the 4000 line long file I just wrapped my fix in a closure and imported the variables I needed with the using statement. And you can always return a variable from the closure to import it into the global scope again if needed.

// 100's of lines of bad, very bad code, above …

// Fix for ticket #PR-558
$foo = call_user_func(function() using ($row, $db, $i) {

    // write your fix with any variables you want
    return $bar
    
});

// more bad code below …

Zen …

Why I’m naming my Primary and Foreign keys the same!

I’ve recently changed the habit from naming my primary keys in an SQL table id to table_id just like I would name the key if it were a foreign key in another table.

To me this has several advantages, the most important one being that you can easily replace the verbose JOIN table ON col1 = col2 into an easier JOIN table USING col syntax.

SELECT 
    u.username, d.email 
FROM users AS u 
LEFT JOIN details AS d 
    USING user_id

Win!

Edit: as @bramus noted, a NATURAL JOIN is even shorter but in most cases introduces extra complexity and harder debugging since you can’t have any matching column names next to the ones used for joining, so no name columns in both tables unless you want to join on them too.

Consuming the twitter streaming API with PHP

For a pet project I needed to get all twitter messages with a certain hashtag, I was looking for ways to consume the twitter streaming API with PHP and there are several libraries like Phirehose out there that can easily do this for me. But … I wanted a lightweight solution that could run as a low memory daemon on my server so I went looking for plain PHP solution.

In the end it’s all pretty simple, just open the stream and read the lines one by one as they come in and process them for whatever purpose you want.

// File: stream.php
define('TWITTER_USERNAME', 'foobar');
define('TWITTER_PASSWORD', 'baz');

$context = stream_context_create(array(
    'http' => array(
        'method'  => 'POST',
        'content' => 'track=#ipad,#iphone,#ipod', // The hashtags you want to follow, comma separated list
        'header' => array(
            'Content-type: application/x-www-form-urlencoded'
        )
    )
));
$stream  = fopen('https://'.TWITTER_USERNAME.':'.TWITTER_PASSWORD.'@stream.twitter.com/1/statuses/filter.json', 'r', false, $context);

while (!feof($stream)) {
    if (!($line = fgets($stream))) {
        continue;
    }
    $tweet = json_decode($line);

    $username = isset($tweet->user) && isset($tweet->user->screen_name) ? $tweet->user->screen_name : "?";
    echo '@' . $username . " - " . $tweet->text . PHP_EOL;
}

Run the script in a shell like this: php stream.php and see the tweets popping up in real-time. Easy as pie. Also make sure that SSL is enabled in PHP-CLI, else you won’t be able to consume the https stream.

Of course this could be improved by using oAuth instead of HTTP auth, especially since twitter is dropping HTTP auth in the future, but that’s something for the day I’ve finished prototyping and am actively developing the project. Later … :)

Hi. I had the same issue with the status bar leaping all over the place. I found it distracting and annoying, so much so that I wrote a CSS userstyle for it. It may/may not be something that interests you. If you want to check it out, visit userstylesDOTorg and do a search for "fixed statuspanel". It might be worth a look (and possibly a laugh).

Yea, thanks! I’ve seen the CSS fix and it’s quite simple, the UserStyle solution is probably the cleanest since it doesn’t mess with the internal chrome stylesheets! Thanks alot!

Fixed statuspanel

The statusbar that couldn’t make it’s mind up

Since Firefox 4 Mozilla has dropped the statusbar in favor of a link-target bar popping up whenever appropriate. Whether or not this is a good thing is open for discussion but there is one thing that annoys the hell out of me and that’s the fact that the popup shows in different places whether or not the searchbar is showing.

I’m not a usability expert but that is a huge fail.

An official bug report has been posted at Mozilla but it hasn’t been picked up and resolved yet, even with the rapid release cycles they adopted. What makes it worse is that apparently the fix is as trivial as modifying the default user stylesheets shipped with Firefox.

I’m still an active Firefox user and am amazed by the superb updates the push out lately but this is just a plain old fail from the purest kind. Fix it Mozilla!

statusbar switching