Mack Framework

The Mack Framework is a pretty nifty combination of Rails, Merb and many other Ruby frameworks. It’s built off Rack and therefore should be simple to deploy. I really want to work with it, but what to do? Does anyone have any ideas? I need a project.

What is a reflow?

Have you ever heard of reflows in terms of browser rendering? I hadn’t but this short blog post has some neat videos of them in action. Check it out, let me know what you think.

Arduino + RAD Looks Like Fun

Lately I’ve been lacking any personal projects. To compensate I finding myself working on code for my employer (Leapfrog Online) during my free time. That’s not very fun, but my lack of creativity wasn’t able to provide a solution.

All of that changed tonight. For some unknown reason I suddenly came up with a project. I’m not going to say what the actual project is yet, but I will say I’ve been doing a lot of reading on the Arduino, and was thrilled to find this: RAD. I will probably end up ordering one of these starter kits when I get back from RailsConf in a week.

I went to RIT for Computer Engineering, and I’ve always loved working with hardware as a hobby. Since I’ve been out of school I really haven’t done much with my soldering iron or bit mask knowledge, mostly Rails work, so this will be a fun change.

Postgres Query to CSV

Today at work I was asked to generate a report from some data we’ve been recording for the past month. The query I came up with ended up producing ~3000 rows. Far to many to copy and paste into a text file and email to anyone. I knew there had to be a way to produce a CSV from PSQL, but how? Googling returned a number of informative links, but I was still a bit confused.

I ended up asking my fellow devs, and received a few possible solutions.

The first was to start PSQL with the the following flags:

psql -A -F , *connection specifics*

The second was to enter PSQL like normal and then apply these two commands:

\a
\f ,

Both suggestions 1 and 2 require you to also run the following command before running your query:

\o filename.csv

The third, and by far most elegant solution came from one of our DBAs. He recommend entering PSQL like normal and then using the following command all in one fell swoop:

\copy (select statement) to '/my/file/name' with delimiter AS ',' NULL AS ''

It is worth noting that the previous command will only work in Postgres >= 8.2

I’m posting this here in hopes others searching for this will find this a clear succinct description, but also, for my own reference as I’m sure I’ll be asked to perform something similar again in the future.

Random Thoughts Involving Computers

This is the output from a cool command I found on ones zeros majors and minors

history 1000 | awk '{a[$2]++}END{for(i in a){print a[i] " " i}}' \
| sort -rn | head
124 rake
106 svn
84 ss
36 cd
30 git
26 rm
26 ls
16 sc
10 mate
5 psql

How about you?

And, again from ozmm is the try command. I think I’m going to start adding this to my projects, seems really simple and helpful.

class Object
  ##
  #   @person ? @person.name : nil
  # vs
  #   @person.try(:name)
  def try(method)
    send method if respond_to? method
  end
end

GitHub and Me

This weekend a fellow member of Rochester On Rails was nice enough to share an invite to Git Hub. Check out my account, I just published two little plugins I use all the time at work and at home when building Rails apps.

The first is Fixture Manager. This plugin adds a few methods to ActiveRecord classes allowing you to save database contents to YAML (either in your test/fixtures folder, or in cms/fixtures). The plugin also provides a few Rake tasks that wrap these methods as well as a simple static class (FixtureManager) giving you two options as to how you want to save and load your data.

The second is Rcov Task. This plugin contains almost no code, its a Rake task that simplifies running your test suite with rcov (and opening your browser if your in Mac OS X).