How the gym and Japanese made me a better developer

Posted on August 18th, 2011 in Computer Science, Opinion, Programming, tips | View Comments

For the past ten years or so, even before I graduated from college, a large chunk of my spare time has been dedicated to studying. More specifically, it’s been dedicated to studying technology. Everything from programming languages I’ve wanted to use to new frameworks that look shiny and new to electronics and Arduinos and everything in between. I’ve spent lots of time and money reading up on anything tech. It’s really my passion. That’s why I got into Computer Science to begin with. I love this.

But after all those years, I’ve been getting burned out doing this. There’s just a lot of little things that lead to me feeling this way. The biggest reason, however, is the following: I’ve read and studied about a lot of cool things that I never got to do at my current day job, making it impossible to retain anything long-term and making me eventually lose interest. This would then spiral into me feeling guilty on spending so much time on something and not use it. To compensate, I would jump to some other tech-related book or project that excited me, only to have the same thing happen again. It was a vicious cycle that I hated and was desperate to get out of. But I didn’t want to dump tech at all. I love this stuff.

Finally, I decided to just hold back on all the new learning. I stopped buying books and trying to jump on the bandwagon of the latest hotness out on the streets. But that made me even more miserable. I felt like I was getting left behind. Like a drug junkie, I yearned to get my fix, even though I knew it was slowly killing me inside. So I had to focus on something else, far away from the things I’ve been doing for the past ten years. And oddly enough, shifting my focus away from tech was just what I needed to get my focus back on tech.

First off, I finally decided to go to a gym. Before last year, I had never stepped into a gym before in my life. Outside of walking around town or visiting a new park from time to time, I never really made an attempt to make physical activity a part of my routine. So at age 29, my electronic scale at home read 298.8 pounds, and a recent blood test showed my cholesterol levels a bit on the high side. I knew I had to do something. Since my current office is located right next door, literally, to a gym, I signed up and started going.

Going to the gym and exercising regularly has been by far the best decision I’ve ever made in my life. Outside of weight loss and other physiological benefits, I never really believed the mental benefits of exercising, but they’re very, very true. I feel much more alert during the day, up to the point where I don’t need a caffeine boost during the day. I also got much better at retaining new things I’ve learned. Work seems to come out effortlessly, and I think the quality of my code has gone noticeably up in the last couple of months, since I’ve been going to the gym more often. Finally, I’ve noticed myself in a much better mood every single day, with rarely any “bad hair days”, as I used to have periodically. Seeing the benefits of the hard work put at the gym helps with that a lot: Yesterday I weighed myself using the same scale that mockingly showed 298.8 over a year ago, and now it ready ’258.8′. Suck it, electronic scale.

Besides the gym, I wanted something else to focus on, but nothing related to technology. So I decided to take up learning a new language – a natural language, in particular, Japanese. I’m already fluent in English and Spanish, so I wanted to take something that was totally different, something not a Germanic or Romance language. I thought that Japanese was one of the most difficult languages outside of those groups, so I signed up for a class to feel challenged by something new. I’m about to finish my introductory class next week, and I loved it so much that I’m planning to stay at the language school for at least a full year, and then I’ll be taking a few weeks to actually visit Japan.

The thing is, since I’ve been spending a noticeable chunk of time with the gym and learning Japanese, I’ve noticed a surprising side-effect – I’ve been doing much better in the tech department. Taking time to study Japanese clears my mind and really energizes me, so when I go back to coding I put in a much better effort than I did before. And the physical and mental energy boost that the gym has given me helps me be able to learn and retain more than I ever did. It’s an awesome feeling, and I’m loving studying all over again.

As developers and engineers, our passion leads us to spend too much time on technology, but in the long haul that’s not sustainable. I’ve heard the phrase “sometimes we need to step back to be able to move forward” many, many times before. It’s totally true. Believe it.

My Quick Recap of MongoSF 2011

Posted on May 25th, 2011 in Computer Science, Conferences, Open Source, Opinion, Programming | View Comments

Now that I live on the West Coast, I’ve been able to attend many of the wonderful tech conferences that are hosted in the Bay Area. Yesterday, I attended MongoSF in beautiful San Francisco. I’ve been using MongoDB for a while now, mostly for personal projects. I’ve written some projects on GitHub that uses MongoDB as the primary data store, and I have also migrated some existing MySQL tables in other projects to use MongoDB instead. Having read MongoDB: The Definitive Guide from front to back, and spending quite some time on the MongoDB docs, I feel like I have a good grasp on the tool. So I was pretty excited to go to this conference and discover some more things about my one of favorite pieces of tech.

There were multiple tracks in this conference, and unfortunately I still can’t clone myself in this day and age, so I’ll just briefly touch on those sessions that I was able to attend.

Monitoring & Queuing MongoDB: This talk, given by David Mytton from Server Density touched on some of the integrated monitoring tools and commands that MongoDB has baked in. He also showed a bit of Server Density’s MongoDB monitoring system, which looks to be incredibly useful. Overall, the talk was decent, but anyone who has MongoDB running in production should know most of this stuff already.

Evolving from relational to document store: Graham Tackley, lead for the web development team over at the U.K.’s Guardian news site, gave an interesting talk on how the site has evolved over time since the mid-90s (Lots of Perl / CGI goodness). Currently they are in the process of moving certain parts of the site to use MongoDB. Besides the history lesson on the site, he also mentioned how they are dealing with possible future changes in architecture, notably by building APIs around the site functionality. This talk got my gears running about some of my own projects, and how I might build any new projects I have in my mind.

MongoDB Profiling and Tuning: This talk was given by Kenny Gorman, who works as a data architect at Shutterfly. Kenny went through some of the steps used to profile MongoDB, like using explain() on your queries, and how to make things faster, not only on the software side, but also on hardware. He brought up Facebook’s Flashcache, and how it makes MongoDB speed up. I particularly enjoyed hearing the hardware side of things, as I feel like hardware is mostly overlooked by developers.

MongoDB’s New Aggregation Features – A Sneak Peek: Chris Westin is a core MongoDB contributor, and he gave us a sneak peek at a new framework for aggregating records in MongoDB. This framework is really not meant to replace Map/Reduce, which will still serve very well for massive data. But for people like me, who need to aggregate smaller amounts of data (thousands of documents instead of millions), this will be much easier and faster to deal with. Very cool stuff, and I can’t wait to use it.

Lessons Learned from Migrating 2+ Billion Documents at Craigslist: Former Yahoo! and current Craigslist employee Jeremy Zawodny spoke about how Craigslist is using MongoDB for their posting archive, and the lessons learned along the way, like the usage of replica sets even in development, document encoding, and how important data types are when migrating collections. He had a similar talk at MongoSV a few months ago, so I didn’t feel like there wasn’t much new information here. Still, a good talk about migrating a large amount of data from MySQL to MongoDB – it can be done.

Practical Scaling and Sharding: Eliot Horowitz is one of the main MongoDB contributors, and the CTO of the company that backs MongoDB, 10gen. He went through the features and usage of Replica Sets and Sharding, with a few use cases and live examples. This seemed more like an introductory talk more than anything else, so there was nothing groundbreaking here.

MongoDB at Foursquare: This talk was given by Jorge Ortiz, an engineer at Foursquare, who proceeded to mention briefly how MongoDB was being used at Foursquare, some of the lessons they’ve learned throughout the years with MongoDB, and talked about their Scala library for querying MongoDB called Rogue. Frankly, I was disappointed with this talk, as Jorge didn’t give much insight outside of a few numbers and oft-repeated tips. I was expecting a more informative talk here.

Indexing & Query Optimization: Alvin Richards, a West Coast 10gen employee, gave an in-depth talk about indexes in MongoDB. He went through everything, from basic indexes, to indexing order, to new indexing options in MongoDB 1.8 (sparse indexes and covered indexes), to even showing representations of the internal B-Tree implementation. Very informative.

Lightning Talks: This was divided in three shorter talks. First up was Michael Goff, who spoke about how his company, Cocoafish uses MongoDB to serve up data to mobile apps. Next was Chris Carrier (Is he on Twitter? I couldn’t find an account to link here) from Zuberance, speaking about how to create a reporting backend using MongoDB. Last, but not least, was Chad Arimura, who went through SimpleWorker, a cloud-based job scheduling service that uses MongoDB. These talks were short – which you might have figured out with ‘Lightning’ in the title – and seemed to be mostly about the speakers’ particular sites more than anything else.

At the end, Eliot Horowitz gave a quick rundown on the upcoming features for MongoDB 2.0, like TTL collections, online data compaction, faster Map/Reduce, etc. Surprisingly, this 2.0 release is scheduled for June 2011, as in next month. Seems like they’re going to be doing quicker iterations and getting new stuff out there as soon as possible, which can only lead to good stuff for users. There was an after-party, but when I swung by the place there was a massive line outside to get in, so I decided to head home instead. Unfortunately, this is the third time in as many conference after-parties that I’ve had to do this, so it seems like these after-parties don’t scale well.

Overall, while the conference was pretty good, and everything was organized very well, most of the times I felt like I was out of place or at the wrong talk. Judging from the few people I spoke to, and those that I overheard, it seems like most people at the conference hadn’t used MongoDB much (or at all), and many talked I went to touched on what I consider some of the basics of MongoDB. Even if they weren’t basic topics, like Replica Sets or Sharding, if you have read a recent MongoDB book, you knew what most of the speakers were talking about. Also, there was plenty of repeating of the same tips over and over again in a lot of the talks. For example, in the nine talks I went to, the speaker mentioned the “always keep indexes in memory” rule of thumb in at least five of those talks. Truth be told, MongoDB isn’t really a super-deep technology (even the aforementioned O’Reilly book clocks in at a bit north of 200 pages), so this can be the reason why. But I wanted to know more on the upcoming features in MongoDB (I only really saw one talk in the schedule like this, which was the new aggregation framework), and some more in-depth views of how companies are leveraging MongoDB in their technology stack instead of just pointing out how awesome MongoDB is – which we already know.

In any case, I had tons of fun, learned some new tips and tricks, and got some fresh inspiration to use in my own work soon. The best thing about these conferences is knowing that what you’re learning and using is valuable not just to you, but to many out there, and it just gives you motivation to keep on using those tools in familiar and new ways. Much props go out to 10gen for making this conference go smoothly, and hopefully there’s another one of these sometime next year.

How I’m Learning iOS Development

Posted on March 29th, 2011 in Books, Mac, Programming | View Comments

Lately, I’ve been on a hardcore iOS development learning phase. To be honest, I’ve been wanting to learn iOS development for a while (probably since I got my first iPhone two years ago). But I either never had the time to sit down and learn something new, or whenever I did try to take time to learn, I’d get totally confused with something and felt like I was stuck. I don’t know if it was due to spending too much time on Ruby and vi, that Xcode, Objective-C and Interface Builder totally threw me off my game, but the learning curve initially seemed steep to me.

I finally decided to put my foot down and do whatever it takes it finally get a grasp of iOS development. And the dedication is finally paying off. I finally feel like I’m getting used to the development environment and most of the basics to actually get something done. It’s not like I have a million-dollar app I want to develop or anything, but seeing that mobile development is one of the hottest trends out there and will most likely be for the foreseeable future, I want to be a part of that wave while it’s still peaking.

I wanted to share some of the material that has been greatly helping me out during this journey. Note that there isn’t a lot of material updated with info on iOS 4 or Xcode 4, and although there are minor changes, like slightly different method names, for the most part the material is still very much useful.

Beginning iPhone 4 Development: Exploring the iOS SDK by Apress

Of all the books I’ve read on iPhone development, this seems to be the one that made it all click in my head. The writing feels a bit on the simplified side, which really made my brain be able to grasp and retain the concepts presented in it. The way the chapters progress is smooth, and doesn’t really overwhelm you with a lot of new concepts. I’ve noticed that a lot of books give you examples with a lot of new stuff that they haven’t covered yet, then proceed to say something like “trust us, ignore this for now and we’ll explain later”. This book doesn’t really do that much, besides when it’s apparently necessary to hold off.

This book also contains probably the most updated print material I’ve seen anywhere, as of this writing. If you were only to get a single book on iOS development, I would highly recommend this book above anything else.

Peepcode Screencasts – iPhone View Controllers, Part I, iPhone View Controllers, Part II and iPhone Views I

One of the most confusing things for me with iPhone development is the concept of view controllers. It was the one thing that tripped me up, despite trying to find as much info about it as possible. Although the previously mentioned book helped me the most to clarify a lot of these concepts, these Peepcode screencasts are also great for understanding how views work on iOS. It took me a couple of viewings of the first two parts (I haven’t purchased the most recent screencast) to really understand things like table views and cells and the different types of views available (Tab Bar, Navigation, etc.)

Programming in Objective-C 2.0 (2nd Edition) by Stephen Kochan

One of the mistakes I made early on in my Ruby career was the fact that I took the time to learn Ruby on Rails, but not the underlying language which is, of course, Ruby. Looking back now, that hindered my progress early on, since I knew the basics, but couldn’t really fully understand the real power behind Ruby, like metaprogramming. It limited what I could do. So instead of following that same path again with the Cocoa Touch framework, I decided to take the time to get deeper into its underlying language, Objective-C.

This book is definitely the definitive guide to Objective-C. It covers just about everything in the language – clocking in at almost 600 pages worth of material. While I don’t know if Objective-C should be someone’s very first programming language, it’s actually starts of with basic programming concepts like methods, classes, variables, looping, etc. But it gets deep pretty quickly, covering plenty of Apple’s Foundation Framework. It’s an excellent reference, and one I keep by my desk at all times.

Apple’s iOS Developer Library

I was pleasantly surprised to see that Apple’s online documentation is really well put-together. It covers everything from basic Objective-C to more specific iOS functionality, like Push Notifications or the iAd Framework. A lot of the basics are available for free, but I believe there’s a lot more documentation for users that have registered to their $99-a-year iOS Developer Program.

These have been the top resources I’ve been using these past couple of weeks to get up to speed with my iOS development. With these resources, I’m getting very close to feeling confident enough to put together a simplistic app, maybe even publish it in the App Store for the hell of it.

If you’re curious to want to start iOS development, these books, videos and online documentation will help you a lot. Don’t feel overwhelmed by the amount of material out there. Just dive into it! There’s a ton of things that iOS devices can do. It’s just a matter of digging in and exploring further those parts that interest you, whether it’s a simple app with a table view or a full-blown OpenGL ES video game. Happy hacking!

Broken Tests… I Told You To ‘Save’

Posted on December 7th, 2010 in Funny Stuff, Opinion, Programming | View Comments

Failing tests are the worst, especially when caused by a silly cut / paste mistake (an instance variable had to be changed to be a local variable, but guess who forgot to remove the ‘@’ sign…). While my tests run again to make sure it’s all good now, I thought I’d share a little routine we do here at RepairPal when this happens.

In the spirit of getting feedback as quickly as possible after we commit our code changes, we have a continuous integration server (running Hudson, which is very awesome). This, of course, will pull our code changes and run all tests we’ve written so far, letting us know when something failed along the way. But instead of being notified by emails, we decided to make things a bit more fun. We plugged in a pair of speakers to the CI server, and using the text-to-speech tool Festival, we’ll get a nice voice notification of who broke the build when tests fail. It’s a great way to get the instant feedback needed to fix things when they’re most fresh in our minds. The only drawback is the fact that one of our developers is in Romania, so he doesn’t get to hear our Hudson box yell at him. He does get notified via Campfire, though.

However, the fun doesn’t end there. I bought a cheap piggy bank that looks like a big keyboard key with the word ‘Save’ on it:

Whenever someone commits code that breaks our test suite, not only do they have to suffer the embarrassment of having Hudson bark at them, but they also have to pay a dollar to our ‘Broken Tests’ fund, and have the dreaded ‘Save’ button sit at their desk as a reminder to save things before committing. The ‘Broken Tests’ fund goes towards the bar downstairs, where us local developers spend the cash on beers for the team. Thankfully we don’t break the test suite often enough to get beer often. It’s a punishment, but it leads to a good thing, eventually.

Does your team have any sort of ‘punishments’ when one of the developers breaks the build? We’re constantly thinking about different things to add to our little routine, just to keep things light around here.

Fail Notifier – Get Real-Time Notifications When Stuff Fails

Posted on October 27th, 2010 in Announcements, Linux, Open Source, Programming, Ruby, Services | View Comments

Last week, I was doing some routine maintenance on my VPS (which I should definitely do more often, as well as writing some more blog posts) and I noticed that one of my cron jobs that backed up some files to Tarsnap was incorrect and silently failing. Now, I could modify this simple Bash script to shoot off an email to me whenever something happens. But I was feeling a bit creative and didn’t want to just write a few lines of Bash and be done with it.

As any software engineer is prone to do, I wanted to build something a bit more cool. That’s when I figured out that this would be the perfect chance to finally do something useful with Notifo. Notifo is an awesome service that provides real-time notifications to a number of devices, in particular to iPhones (although their list of supported devices seems to be rapidly expanding). I’ve been using Notifo just for setting up simple timed reminders and to get notified of replies and mentions from Twitter using push.ly. Getting notifications in real-time of failures would be something great to have.

Using Ruby,, Sinatra and the Notifo gem, I quickly whipped up a small app called Fail Notifier. Basically it’s a service where any application / server can make a simple HTTP POST to where Fail Notifier is running, and it will relay the message to the user in real-time using Notifo. Simple, but very useful. The best thing is that you can use it anywhere to notify you about anything from any app, programming language, server, or anything else that can make a simple HTTP request. For example, I have Fail Notifier installed on my VPS (nginx and the recently-released cURL about some failures, and I also have some notifications for very important background tasks in a Rails app.

Of course, Fail Notifier is entirely open-source for you to do with it as you please. Feel free to fork the code on Github and hack away to your hearts content.

Bye, Slicehost – Hello, Linode

Posted on July 26th, 2010 in Linux, Open Source, Opinion, Ruby, Ruby On Rails, Services | View Comments

It’s been a few months since my last post around these parts. I’ve mostly been keeping busy with fitting into the whole West Coast lifestyle and, of course, busy at the job. Although I do miss New York City from time to time, particularly while watching older episodes of How I Met Your Mother, I’ve really enjoyed my time in the Bay Area. People here are interesting, and tech is such a huge part of the culture. It’s been a fun ride.

This post, however, is not about the adventures of a Puerto Rican being thousands of miles from home (although it could certainly make for an interesting story for another day). This post is about me pulling the trigger on something I’ve wanted to do for a long time – switch my VPS (which is where this very blog is running) from Slicehost to Linode.

To begin, I wanted to state that Slicehost is very, very awesome. I’ve been a customer of theirs for more than two years, and never had any major issues with them. With the exception of some outages, their service ran smoothly for the most part. This is more than anyone can ask for. So, if Slicehost is so awesome, why didn’t I marry them? I was perfectly content in staying with them.

However, as I was experimenting more and more with Ruby, Rails, Python and other languages / frameworks, my VPS – which was the smallest slice available at 256 MB – was obviously starting to suffer under the memory constraints. Since these were mostly experiments, I didn’t want to splurge and pay almost double for a 512 MB slice. That’s when Linode announced that they would be increasing the RAM sizes of all their slices. So it was either to stay with Slicehost and have my VPS struggle to keep up with my experiments (or pay more per month), or switch VPS providers. After reading all around the Internet about how good Linode was, I decided to go for it.

I opened an account with Linode and instantly had my sparkling new VPS running. I transferred all my files from the old Slicehost VPS and just had to point my domain names to the new Linode VPS. My main concern initially was that Slicehost had really spoiled me with their control panel, especially for DNS management. It was what had initially drawn me into their service to begin with, so leaving that behind was a bit scary. Thankfully, Linode has their own control panel that’s equally great to use. I was able to configure and point my domain names to the Linode VPS, and had everything working quickly.

As far as performance, I had been reading for years how Linode has faster I/O performance than Slicehost. Turns out that those tests seem to be true – The VPS as a whole feels much snappier, from logging in via SSH to serving up this very blog.

One of the major issues people had against Linode in the past was that they lacked any integrated backup system, a la Slicehost. They actually introduced backups a few months ago. This wasn’t a major concern for me (I’m using Tarsnap, which deserves a blog post of its own), but for those who need this sort of service, know that they have you covered.

Like I mentioned, Slicehost is great, and I wouldn’t encourage people to not use their services. I just had different needs that Linode seems to be handling as well as I expected. It’s only been a couple of days, but I think I’ll be shutting down my Slicehost VPS for good.

My Arrival To The Bay Area

Posted on February 21st, 2010 in Opinion, Programming, Ruby On Rails | View Comments

Well, after writing in my last post a month ago that I was officially unemployed, I was blessed with acquiring a new full-time job just four days later. Best of all, it’s where I always wanted to be, the Bay Area!

Tomorrow will officially be my first day as a Rails developer for RepairPal. I was in their offices last week to meet them personally, and everyone seemed very friendly and the company seems to be doing some cool stuff, so I hope I’ll be a part of all the awesome stuff that’s to come. It’s really a dream come true for me to be where I’m at right now, at this very moment. It’s proof that if you really want something bad enough, and you work hard for it, whatever you want will come true.

No Rest For The Unemployed

Posted on January 26th, 2010 in Books, Computer Science, Databases, Linux, Mac, Open Source, Opinion, Programming, Ruby, Ruby On Rails, tips | View Comments

After two years, yesterday was my final day of being a developer for BarterQuest. As anyone living in expensive New York City in the same situation, I have been focusing part of my energy looking for a new gig. I’m pretty confident, despite the current economy, that I will land on my feet sooner rather than later. I have a few leads, with one in particular that I am really hoping will come through.

In the meantime, I’m not just throwing my resumé in the face of companies everywhere in the U.S. I have also decided that since now that I have quite a few extra hours in my days, I should really do productive things instead of sitting on my couch and re-watching all previous seasons of 24 (believe me, I would watch all 7 seasons in a row if I could) or jamming away to Guitar Hero. This is a perfect chance to do lots of technical things I’ve been wanting to do for months, but just never got the time to do so. Here’s a short list of some goals I’d like to get started on.

Learning new stuff

For the past two years, I’ve been exclusively using Ruby and Ruby on Rails at my day job. I’ve always wanted to broaden my skills by doing other types of programming, but when you take into consideration that I would usually be at work more between 9-10 hours per day, plus a commute that would sap an additional two hours, there wasn’t much time for me to be able to do personal things, let along learn new stuff. Now that I’m finally free, I can now spend more time with those things I’ve wanted to experiment with.

I’ve always wanted to learn iPhone application development. I know the basics of Objective-C, and have the book iPhone SDK Development by Bill Dudney, but I was never able to sit down and code something up. I have a few ideas for apps, so even if I can make a simple app that’s accepted to Apple’s App Store will be an achievement for me.

I’ve been very interested in implementing Push technology to web apps, like Comet or Web Sockets, using nginx’s Push Module and Orbited.

Although I’ve never had the opportunity to work with extremely large data sets, I’ve always been curious about frameworks like Google’s MapReduce and Apache Hadoop, particularly how well they can “crunch” the data thrown at them.

Keep on with what I already know

As I mentioned, I’ve been using Ruby for years now, and I know Ruby on Rails and Sinatra pretty well. However, just because I want to learn new things doesn’t mean that I want to abandon this awesome language. In fact, I want to keep using it more with the latest toys.

Thanks to Ruby Version Manager, I was able to safely install the latest versions of Ruby 1.9 and MacRuby and start learning their new features. I was also able to check any possible compatibility issues in my older applications with different major Ruby versions. Seriously, if you are a Ruby developer using a Mac or Linux, install RVM now if you haven’t.

Recently, there have been more and more news about Ruby on Rails 3, the next major release for the wonderful framework. I’d like to stay one step ahead of the pack and start learning about the new changes before it officially hits the web. One of the leaders of the newest Rails changes, Yahuda Katz, has written lots of blog posts relating to the changes in Rails 3. They’re definitely worth a read.

Strengthening my shortcomings

There are quite a few things – development-wise – that have been bugging me for a long time, yet I’ve never taken the proper steps to correct. Now is as good a time as any to take on these things and finally conquer them.

My main weakness, as a web developer, is that I’m pretty bad at design. I know CSS and its properties, I know about browser incompatibilities (having been a victim many times before by the evil and immortal Internet Explorer 6 browser) and all that stuff. But as far as design goes, like font sizes, element placement, usability and colors, these things are not my strong suit. I’ve actually stocked up on some books about these subjects (like Don’t Make Me Think by Steve Krug and Web Design for Developers by Brian Hogan), so I hope that by the time my unemployment ends, I’ll be much better off making my work look good – or at least decent.

Another weakness I consider is that I get distracted from development from time to time. It’s not frequent enough to affect the quality of my work, but it’s enough to annoy me when I do it subconsciously and I then catch myself in the act. I have read some people who had some success using the Pomodoro technique, so starting tomorrow I decided that I’ll give it a try. There’s a nice little app called Concentrate for the Mac that seems to be just the thing I need during those times when I need to get stuff done and not get distracted.

Beef up my GitHub profile

I have to admit that I’m a little bit ashamed to see my GitHub profile virtually empty. For a long time, I’ve been wanting to add more of the projects that I have in my laptop to GitHub and see if some of them take a life of their own. Sadly, for whatever reason, I haven’t done that. Most of the times I’m a bit too critical at my code and think it’s embarrassing to make public, but that’s really what I need to do to get better as a developer. I can take criticism with the best of them, so there’s really no excuse. I need to make more of my code open-source, period.

Not only do I want to show my own work, I also want to give back to the community. I have used so many open-source projects over the years, yet I’ve only submitted a handful of patches to very few projects. I don’t want to be a person who takes, takes, takes and never gives anything back in return. So I’m going to take steps to correct that. I’ve started cloning some repositories of my favorite projects from GitHub to my computer to start reading their code more in-depth, which I had been doing anyway. I’ll check if these projects have Lighthouse pages with open tickets, or if there are any open issues on their GitHub page. A few years ago, Dr. Nic wrote an excellent post titled “8 steps for fixing other people’s code” that inspired me to start finding features or defects that I can handle.

I have to say, I’m only one day into this routine, and I don’t remember the last time I felt this free and liberated doing what I wanted to do. Full-time employment is great for earning money and making substantial stuff, but sometimes there’s a feeling of emptiness due to not being able to explore on your own. Being unemployed doesn’t mean that you need to spend all your time looking for work. Unless you’re truly struggling economically and can’t pay the bills in the next couple of weeks or even days, why not spend part of your time gearing up for the future?

MongoShort – URL Shortener using SInatra and MongoDB

Posted on January 14th, 2010 in Announcements, Databases, Open Source, Programming, Ruby | View Comments

As many other developers, I’ve been experimenting with the different “NoSQL” data stores. Most of them are really great, like Redis, Tokyo Cabinet and CouchDB. My favorite so far, however, is MongoDB. I think it hits the sweet spot between a normal relational databases and key-value stores. After a while playing around MongoDB, I decided to do something with it. That something that I did is called MongoShort.

MongoShort is a very simple URL shortening service, written with Sinatra and MongoDB. I originally wrote this little app to be used as part of a larger Rails application. However, it was mostly done as a way to do something with MongoDB. Particularly, I wanted to start using the awesome MongoMapper library. It’s really a breeze to use all these tools together, and it makes developing small apps on Ruby really fun. I hope someone can grab a copy of MongoShort and learn a bit of the basics of these wonderful tools.

Go fork MongoShort on GitHub now!

Redis rocks!

Posted on November 5th, 2009 in Databases, Linux, Mac, Open Source, Opinion, Programming, Software | View Comments

In my development blog, I previously wrote that MongoDB was the future of database storage. I might reconsider my decision, now that I’ve discovered Redis. In a nutshell, Redis is a key-value store. But it’s not a simple key-value database, as it has lots of commands and extra goodies, such as file persistence (so data can be stored from memory to a file, and restored in case of failure) and awesome data structures like lists (with push / pop) and sets (even ordered sets). Besides that, Redis boasts atomicity and even master-slave replication. It’s quite a lot of stuff for a lean package.

One of the things I love the most about Redis is it’s speed. Believe me, this little database is fast. Redis includes a benchmark tool, so I ran the default benchmark (Approximately 10,000 total requests per command, from 50 simultaneous clients) just to demonstrate its raw speed. These tests were run on a Mac Mini (1.83 GHz Intel Core 2 Duo, 2 GB RAM) under Ubuntu 9.10 Server:


dennmart@ubuntu:~$ redis-benchmark
====== SET ======
10005 requests completed in 0.14 seconds
50 parallel clients
3 bytes payload
keep alive: 1

34.89% <= 0 milliseconds
99.19% <= 1 milliseconds
100.00% <= 2 milliseconds
74111.11 requests per second

====== GET ======
10003 requests completed in 0.13 seconds
50 parallel clients
3 bytes payload
keep alive: 1

34.62% <= 0 milliseconds
99.79% <= 1 milliseconds
99.83% <= 2 milliseconds
99.87% <= 3 milliseconds
99.91% <= 4 milliseconds
99.94% <= 5 milliseconds
99.97% <= 6 milliseconds
99.99% <= 7 milliseconds
100.00% <= 8 milliseconds
74649.25 requests per second

====== INCR ======
10005 requests completed in 0.15 seconds
50 parallel clients
3 bytes payload
keep alive: 1

25.60% <= 0 milliseconds
99.73% <= 1 milliseconds
99.80% <= 2 milliseconds
99.83% <= 3 milliseconds
99.86% <= 4 milliseconds
99.89% <= 5 milliseconds
99.92% <= 6 milliseconds
99.95% <= 7 milliseconds
99.97% <= 8 milliseconds
100.00% <= 9 milliseconds
65392.16 requests per second

====== LPUSH ======
10001 requests completed in 0.13 seconds
50 parallel clients
3 bytes payload
keep alive: 1

37.62% <= 0 milliseconds
99.78% <= 1 milliseconds
99.82% <= 2 milliseconds
99.86% <= 3 milliseconds
99.89% <= 4 milliseconds
99.93% <= 5 milliseconds
99.96% <= 6 milliseconds
99.99% <= 7 milliseconds
100.00% <= 8 milliseconds
77527.13 requests per second

====== LPOP ======
10000 requests completed in 0.14 seconds
50 parallel clients
3 bytes payload
keep alive: 1

34.13% <= 0 milliseconds
99.69% <= 1 milliseconds
99.82% <= 2 milliseconds
99.86% <= 3 milliseconds
99.90% <= 4 milliseconds
99.93% <= 5 milliseconds
99.96% <= 6 milliseconds
99.98% <= 7 milliseconds
100.00% <= 8 milliseconds
74074.07 requests per second

====== PING ======
10000 requests completed in 0.12 seconds
50 parallel clients
3 bytes payload
keep alive: 1

43.79% <= 0 milliseconds
99.80% <= 1 milliseconds
99.85% <= 2 milliseconds
99.89% <= 3 milliseconds
99.91% <= 4 milliseconds
99.93% <= 5 milliseconds
99.97% <= 6 milliseconds
100.00% <= 7 milliseconds
86206.90 requests per second

Yeah, you read that right. On this somewhat low-end computer (by today's standards), Redis still manages to do over 74,000 SET (write) and GET (read) operations per second. Push and pop list operations also do well over 70,000 requests. On bigger hardware, expect these numbers to be much higher. Besides speed, I've also been impressed by the stability of Redis. I've been running Redis non-stop on the Mac Mini for over two weeks, and I've never had a single issue with it.

I got really interested in Redis after Defunkt (of GitHub fame) open-sourced Hurl. Hurl was an entry in this year's Rails Rumble competition. I used it quite extensively when developing with PayPal's APIs. After it was released, I noticed that Hurl used Redis for persistence. I was kind of puzzled why a key-store value was used for this. However, Defunkt wrote an excellent post mostly explaining the SORT operation, but also included some additional details on how Redis was used in Hurl. It made the decision to use Redis clear. Well, I'm also willing to bet that he used Redis because us programmers love to use the new hotness.

I feel that Redis will be something big soon. There are a few open-source projects using it, including the aforementioned Hurl and Resque. I already have a few ideas where I can use some of this functionality for current sites that I'm working on (such as simple counters, or a tag-like system where we can push and pop tags from a list). Check Redis out if you need some quick and simple storage.