Anton Zolotov

My name is Anton Zolotov. I'm a software developer, drinker of tea, and CEO of GunpowderLabs. Feel free to email me.

Copy a Remote File to S3 with Ruby


Heroku Releases $50 Production Database →

Finally, all my dreams have come true:

Today, we are launching into public beta two new plans: Crane and Kappa. These plans are part of our production tier, offering the same monitoring, operations, support, and data protection features as our more expensive plans.

Crane is available for $50 per month and features a 400 mb cache. Kappa is $100 per month and features a 800 mb cache.

I have a ton of apps for which the shared database is too slow, but the $200 Ronin database is too expensive. These two plans fill the gap perfectly.


Backbone.js Rocks

Here are my favorite things about Backbone.js:

It’s lightweight

Backbone.js weighs in at 16.3 KB (minified), it’s dependency Underscore.js at 12.2 KB.

It makes your apps faster

Rendering views in Rails is slow. By using Rails as an API, you can spread the rendering workload on your user’s browsers, rather than putting it all on your servers. The result? - blazing fast applications that are easy to cache. Diasporate rewrote their newsfeed with Backbone and loved it.

One of the most frequent requests from my clients is higher speed. Nobody wants to wait for a page to reload to see their changes anymore.

It doesn’t force anything on you

There are many ways in which you can use Backbone.js. You can write a completely client-side application that communicates to the back-end via a JSON API. Or you can enhance your existing pages with dynamically loaded resources, such as sidebars.

It pushes you towards a cleaner separation between data and presentation.

Your controllers become responsible for just one thing: delivering data. That makes them incredibly easy to test. Code that’s easy to test is easy to change and maintain.

It’s extensible

Even if you’re not a JavaScript wizard, Backbone.js is trivial to extend. There’s already a solid library of plugins out there.


How Not To Sort By Average Rating →

You are a web programmer. You have users. Your users rate stuff on your site. You want to put the highest-rated stuff at the top and lowest-rated at the bottom. You need some sort of “score” to sort by.

Evan Miller describes an accurate scoring algorithm and how to implement it.


Rubber Duck Problem Solving →

The critical part of rubber duck problem solving is to totally commit to asking a thorough, detailed question of this imaginary person or inanimate object. Yes, even if you end up throwing the question away because you eventually realize that you made some dumb mistake. The effort of walking an imaginary someone through your problem, step by step and in some detail, is what will often lead you to your answer. But if you aren’t willing to put the effort into fully explaining the problem and how you’ve attacked it, you can’t reap the benefits of thinking deeply about your own problem before you ask others to.


Which new iPad should I get? →

My iPad 2 version of this post has been extremely popular for the last year. It’s time for the same choice with the iPad 3 (a.k.a. the “third-generation iPad”).


Rails Scripts: Clone Heroku Database to Development

Sometimes, you need to quickly clone your production database to your local environment. Taps is an option, but at 10 minutes, it’s way too slow for some of my databases.

The faster option is to create a Postgres dump for your database, download it, and import it locally. Initially, I used this code, which lived in each project’s readme, and copied it into the terminal.

heroku pgbackups:capture --expire --remote production
curl -o latest.dump `heroku pgbackups:url --remote production`
pg_restore --verbose --clean --no-acl --no-owner -h localhost \
    -U azolotov -d project_development latest.dump
rm latest.dump

That’s better, but not good enough, because the snippet has to be modified for each project, and user who uses it.

The better solution

I wanted a short script that is run with one command. It should have sensible defaults that can be overriden and gather all information from it’s environment.

Here’s what I came up with:

Thor

I use thor because it’s very lightweight and makes passsing options to the script a breeze. From thor’s description:

Thor is a simple and efficient tool for building self-documenting command line utilities. It removes the pain of parsing command line options, writing “USAGE:” banners, and can also be used as an alternative to the Rake build tool. The syntax is Rake-like, so it should be familiar to most Rake users.

Usage

Make sure you have thor installed

gem install thor

Put the script in your Rails root directory, and run it with

thor heroku:db:clone

Assumptions

  • The production application lives under the git remote production.
  • The database host is localhost.
  • The database user is the same as the currently logged in user.
  • Import into the development database as specified in config/database.yml.
  • We don’t need the dump file after importing it.

Configuration

If those assumptions don’t match your environment, you can override them:

To keep the dump file after importing it:

thor heroku:db:clone --keep

To change the name of the remote:

thor heroku:db:clone --remote staging

To change the name of the user:

thor heroku:db:clone --user bob

TSA: Fail →

Frankly, the professional experience I have had with TSA has frightened me. Once, when approaching screening for a flight on official FBI business, I showed my badge as I had done for decades in order to bypass screening. (You can be envious, but remember, I was one less person in line.) I was asked for my form which showed that I was armed. I was unarmed on this flight because my ultimate destination was a foreign country. I was told, “Then you have to be screened.” This logic startled me, so I asked, “If I tell you I have a high-powered weapon, you will let me bypass screening, but if I tell you I’m unarmed, then I have to be screened?” The answer? “Yes. Exactly.” Another time, I was bypassing screening (again on official FBI business) with my .40 caliber semi-automatic pistol, and a TSA officer noticed the clip of my pocket knife. “You can’t bring a knife on board,” he said. I looked at him incredulously and asked, “The semi-automatic pistol is okay, but you don’t trust me with a knife?” His response was equal parts predictable and frightening, “But knives are not allowed on the planes.”

Great and insightful account of everything that’s wrong with the TSA by a former FBI agent and counter terrorism specialist.


Fusion Ads: A Great Source for Top Notch Blogs

By controlling the quality and relevancy of the sites on our network, we preserve the integrity of the network’s target audience. Sites and services on Fusion are the best in their class – chosen based on their exceptional content and established readership.

Fusion Ads is an ad network only displays ads on a small number of hand-picked blogs of

designers, developers, publishers, creative professionals, and tastemakers in tech-related circles.

So there you go, someone has done all the hard work of curating a list of great writers for you. Go on, check them out.