ls -a
[Flash 9 is required to listen to audio.]
41 plays

This song is pure bliss, with an overtone of despair.

Wildcat - Ratatat

Listening to some new additions to my collection courtesy of Marie. My favorite holiday gift thus far.

Listening to some new additions to my collection courtesy of Marie. My favorite holiday gift thus far.

Spam
Me: I just got an email: "Your zoosk matches are waiting", we need to start spamming people! This stuff works.
Peter: Spam people... Check. You can't spell success without spam.
Me: gem install mail_spammer
Peter: Error : Dependency Check... "It seems you have morals, this gem requires you to run 'gem remove morals' before you continue."
Me: Weird.. I don't get that error.
Scaling on up [part 1]

For a recent ongoing project, I realized that I had to begin offloading a sub-system from mySQL to a key/value store for efficient retrieval. We all know that mySQL heavily depends on power to read as opposed to write. Therefore, when dealing with joins, and sometimes IN’s on non trivial queries, it can become fairly expensive. Not to mention my budget is finite, so I can’t (and wouldn’t, even if I could) just throw metal at the DB.

The sub-system in question is a user’s activity stream. A user has friend’s those friends perform activities such as post photos, comments, be-friend other people etc. Naturally to display all this data from mySQL, lots of joins are required from various tables Users,Friends,Photos,Comments. An alternate solution is to employ a mySQL strategy which keeps track of redundant fields in a separate table that is populated asynchronously. With this method, all data can be pulled in a simple SELECT, again this is nothing more than just a patch, and not really a viable long term solution for scaling.

The real way to alleviate this, is to replace the way activities are displayed, and persisted with an alternate key/value store that is quick to serve data from even when sometimes retrieving non-cached content. In addition, it has to be an augmented key/value store, so that it somewhat facilitates basic relationships.

So now which one do I choose? There are a couple of factors that lead to my decision:

1. Something with very low latency on reads.

2. Something that plays nice with THRIFT or HTTP.

3. A system that is truly distributed and fault tolerant.

4. Eventually consistent system, since availability is more important than inconsistent reads.

5. Decent developer community contributing to the project.

After looking at a couple of options, I narrowed it down to two; Cassandra, or Riak. Both great distributed systems, one system battle tested (Cassandra), the other not so much, but both very much still experimental. I am familiar with Cassandra from a previous endeavor, so I know what it can do. It is also proven to handle well in production (Facebook,Twitter,Digg), so it’s a solid contender, but I’m not going to go with it until I experiment with Riak a bit more. Right off the bat, I was impressed by some of RIAK’s core features, such as virtual node replication and linking between documents, just to mention the attractive ones. The only drawback so far is the lack of documentation and community, since it is so new.

I will have to make a decision soon, and when I do, a post will follow with some more technical details about the move and which system I eventually chose. Until then I’ll be hacking away at Riak to see if it’s a viable option for putting something like this in production, if not then good ol’ Cassandra it is :-)

A new addition to the family. My 1972 Raleigh Super Course with a fresh coat of old English racing green. Wondering what I should name it..

The Bucket List

Here is a list of the 10 things I’d like to do in my lifetime, in no particular order.

1. Write a book

I have no idea what I would write about, but it would definitely be gratifying.

2. Write a horror movie screen play

As some of you may know, I have a passion for all things gore and horror, I have tons of sick ideas that could really be put to good use.

3. Be involved in a music project

Wether directly or indirectly I want to be involved in a music based project. I have no musical talent whatsoever but that doesn’t stop modern day artists does it!?

4. Sky dive

Because I wanna come as close to flying without attempting a base jump.

5. Travel the world for at least a year

Live and experience everything through different perspectives is the goal here.

6. Live in San Francisco, NYC, or Paris

These are my 3 favorite cities, all for different reasons, I don’t know if one stands above the rest as of now.

7. Open a restaurant or small bookstore

The minute I have a sizable amount of disposable income this is what it would go in to. I have always wanted to do this at some point in my life.

8. Get invited to TED

By far some of the brightest minds in science, business, social issues, technology and more. This is one conference I would love to attend just for the sake of absorbing.

9. Finish my PHD

I am currently on leave from my PHD, I left because I wasn’t ready to dedicate myself to a life of research and academia. I do however want to revisit my studies because I know I have so much more to contribute and learn.

10. Be more of a humanitarian

I definitely lack in this department, and would like to make up for it down the line.

CakePHP Error Handling

So a couple of people asked me about the correct way of handling errors in CakePHP, and defining custom error pages for websites, so I decided to not explain this any more and just hand out a url to this post.

Using standard error messages

For common errors such as 404, Controller not found etc, you could easily use CakePHP’s built in cakeError function. So if you wanted to define a 404 error you would simply call the following from your controller or component:

$this->cakeError('error404');

Ok, this is all good, but what if we want more control over error handling, what if we want to define our own error handlers.

Creating custom error messages

1. Extend the default error handler by creating a file: app/app_error.php with the following definition:

<?php
class AppError extends ErrorHandler {
}?>

2. Now that you have this class all you have to do is define custom error handling functions. Include as many custom errors in this class. So lets take a situation where a user is not found in the database when people try to access domain.com/username from your site root.

function userNotFound($params) {
$this->controller->set('file', $params['username']);
$this->_outputMessage('user_not_found');
}

$this->_outputMessage(<view-filename>) will just display the view found in views/errors/<view-filename>.ctp

3. Next create the views and override the default layout.

app/views/user_not_found.ctp
<h2>User not found</h2>
<p>Sorry, but we couldn't find <?php echo $username ?>
in the system.</p>

If you want to customize the layout for your errors, simply create app/views/layouts/default.ctp and include any custom css you want. Don’t forget to include the standard $content_for_layout and $title_for_layout variables in your layout.

4. Call your custom functions from your controllers or components:

$this->cakeError('userNotFound', array('username'=>$username));

That’s pretty much it, you can now handle errors easily and elegantly :-)

This always reminds me of sitting in a car, outside of certain a bowling alley in 2006.

One rough pigeon.

One rough pigeon.

Some Cardboard Lovin

cardboard love

I came across a great find today. Cardboard love, it’s by a buddy of mine Joey Hall who also happens to be the king of all fashion, just in case you need any glamor advice.

So hit up Cardboard Love and let me know what you think.