Porting SQLite3 Data to PostgreSQL Database in Rails 4

This past week I’ve been building a database with almost 1,000,000 records across five tables. So far, it has been just fine to use the Rails default, SQLite3, to manage it. That’s no longer the case, as I need to start thinking about the deployment environment for my application, and I have also been running into some issues with my SQLite3 database locking as I try to add records. Thus, I have ported my data over to PostgreSQL. The process is straightforward, but I did run into a few hangups and did not find a great guide to cover my situation. After some struggling, I got my new PostgreSQL database up and running with all of my data. Here’s how I did it.

Read on →

My New Favorite Programmer

Recently I discovered a Rubyist by the name of Ben Orenstein and today he is my Programmer of the Day and my new favorite programmer. He currently works for Thoughtbot in Boston. He didn’t invent Rails or the first compiler, but I think he’s a good programmer to look up to and learn from because he’s a great communicator who understands that there are real human people in front of the computer screens. A lot of his work so far has also focused on people who are new to programming, so for a new programmer like me, I find most of the things he’s got out there to be really useful.

Ben Orenstein

Read on →

Four Lessons I Learned While Porting a Gem Into a Sinatra App

My classmate Anders and I have been working on a simple forecast app (github, rubygems) for a couple of weeks now. It started as a basic command line utility, and in addition to having some neat functionality, it was a great way to explore some of the things we had learned about in the last month: command-line interfaces, interface-independent object models, simple API calls, building gems and binaries, git workflows, and pair programming. We’ve started to get into building simple web apps, so I decided to port our project over to Sinatra.

Here’s the end product: http://simple-forecast.herokuapp.com/

(A side note: before I started, this seemed like the coolest idea in the world, and one that would be sure to impress people. When I was done, though, it turned out to be a lot of headache to reproduce functionality that Google implements much better already. Honestly the more I think about it the dumber my web app seems. Even so, it was a great exercise in using Sinatra, and the groundwork I’ve laid may even prove useful to making a much more interesting, database-backed Simple Forecast web app in the future.)

Read on →

A Short Explanation of ARGV

I’d come across ARGV or ARGV[0] a few times while looking at code examples on StackOverflow or the Ruby mailing lists. I recognized it as a kind of placeholder variable, but did not really understand its purpose or use and winced everytime I saw it, worrying that I was missing something important. So now that I’m feeling more comfortable with the basics of Ruby, I decided to learn all about ARGV.

What is ARGV?

As a concept, ARGV is a convention in programming that goes back (at least) to the C language. It refers to the “argument vector,” which is basically a variable that contains the arguments passed to a program through the command line. It typically manifests as an array and can be manipulated in that way, meaning you can reference specific arguments by index or you can iterate through them in the standard ways. In languages other than Ruby, you will often run into ARGV’s companion, ARGC, which refers to the “argument count,” and this is a useful shortcut for iterating in languages that rely on for-loops to iterate. The argument vector is often a crucial component for command line utilities (you probably use it every day) and can simplify a utility’s user interface and make it much faster to use. (We’ll talk more about that towards the end of the post.)

Read on →

“The Magic Tricks of Testing” by Sandi Metz

Earlier this year, Sandi Metz gave a 30-minute talk on how to write good tests at RailsConf in Portland. It was called “The Magic Tricks of Testing.” You can watch the presentation on YouTube here: http://www.youtube.com/watch?v=URSWYvyc42M. The slides are also posted at Speakerdeck: https://speakerdeck.com/skmetz/magic-tricks-of-testing-railsconf.

Seeing as how we are dipping our ignorant feet into the test-driven development waters this week at Flatiron, I figured it wouldn’t hurt to start learning from one of the best. I’m still struggling to see the full value of testing, but Sandi promises in the first few minutes this presentation that testing doesn’t have to suck. AWESOME, I want some of that. Here’s what I learned (plus one super cool reference to Star Trek).

Read on →

Hello World