Recent Projects

Collecting all attachments using Paperclip

Paperclip is a great way to allow file uploads in your Rails application. However, it doesn’t give you much in the way of tools to move those files around once they’re on the server, so I concocted a little strategy for doing so.

I tried to get this into Paperclip itself, but it looks like I’m the only person who actually needed it, but I’m hoping this blog post will come in handy for someone eventually.

If you have a User model with an avatar attachment, you’d need the following:

class User < ActiveRecord::Base

  has_attached_file :avatar # etc...

  def avatars
    versions = self.avatar.styles.keys << :original
    versions.map do |version|
      {:path => self.avatar.path(version), :url => self.avatar.url(version)}
    end
  end

end

This would give you an array to access the path and url for each avatar like so:

User.last.avatars.each do |avatar|
 puts avatar[:path]
end

Weekly Digest, 1-25-09

Trevor

Craft the perfect gem with Jeweler

You should have a good idea of what Jeweler is all about by now. It makes gem creation an impulse action. It makes managing versions of gems nice and automated. Oh, and did I mention it is the GitHub recommended way for maintaining your gem? Now go forth, and craft the perfect gem.

My Git Workflow

…what I will do is give you a snapshot of my personal Git workflow(s). I have several, depending on the kind of project…

The Big Picture: The Inauguration of President Barack Obama

On January 20th, 2009, Barack H. Obama was sworn in as the 44th President of the United States of America – the first African-American ever to hold the office of U.S. Commander-in-Chief. The event was witnessed by well over one million attendees in chilly Washington D.C., and by many millions more through coverage on television and the Internet. Collected here are photographs of the event, the participants, and some of the witnesses around the world.

Change has come to WhiteHouse.gov

Welcome to the new WhiteHouse.gov. A short time ago, Barack Obama was sworn in as the 44th president of the United States and his new administration officially came to life. One of the first changes is the White House’s new website, which will serve as a place for the President and his administration to connect with the rest of the nation and the world.

The 37signals Effect

Every time 37signals gives out advice, there’s this 900 pound gorilla in the room that no one seems to notice. They wrote Ruby on Rails. They have a huge cult following. They have a blog with 80,000 RSS subscribers. Do you? The next time you read some of their advice ask yourself if it makes sense for them only because of all these things you can’t reproduce. I’m pretty sure there isn’t a chapter in Getting Real that says “First, write and release one of the most important and popular open source projects of the last 10 years”. But should there be?

Confreaks: RubyConf 2008

The Eighth International Ruby Conference, A.K.A. RubyConf 2008 was held in Orlando, Florida on November 6-8 of 2008. [I just got around to watching some of the videos. You can watch the 30min summary to see if there's anything you're interested in checking out.]

Timothy

7 Myths About Managed Hosting

This is a lit of pro/con points about managed vs. unmanaged hosting. You may be called upon to take up one side or the other at a point in the very near future. Best to be prepared.

nru | lastminute.com labs

Unfortunately, this app is only currently available for UK Android users, but you gotta figure that something like it is on its way to the States. Basically, it’s a merge of Google Maps and a compass app–an annotated compass–that functions as a kind of personal radar for "events" or, (more likely) places.

Comcast Quits Throttling BitTorrent, Targets Heavy Users Instead

Comcast: just boycott it. Throttling anyone who attempts to use the service for which he has paid is not a solution to the problems they created when they started overselling the ever-loving shit out of their network. Seriously: just act like Comcast doesn’t exist.

Debian on Android installer released. – AndroidFanatic Community Forums

While I wouldn’t do this to my phone–partially for fear of bricking (and having to social engineer myself a replacement) it and partially for fear of having to add it to the list of computers that require daily attention/maintenance–it represents substantial progress towards the dream of a world in which phones are like computers: you buy them, ignore the pre-installed Microsoft OS, install your favorite Linux distro and do your thing however you decide that you need to do it.

GameDev.net – How To Build a Game In A Week From Scratch With No Budget

So, dude makes a bet that he can whip up an overhead dungeon crawler in the style of old-timey Dragon Warrior school RPG’s and documents his progress on this page. What makes it a worthwhile read is the pre-writing he did: when he starts working on a component of his game, he often lists certain assumptions or rough ideas he had going into that work. Those insights are, IMO, the valuable ones. Knowing how to pre-write is as important as being able to debug/edit.

Mobile Device Management Software – Mformation Technologies Inc. – 95% of Mobile Users Would Use More Data Services If Setup Were Easier

Cellphones, like non-HD TV, are dead and deprecated. And, much like non-HD TV signals, lots of people are still sticking to their cellphones because of laziness, confusion, ignorance, fear, etc. This little survey suggests that it’s mostly fear of lost information that’s keeping people from switching out their cellphones for smart phones. Interesting little factoid, that.

Events: Lifehacker’s Guide to Catching the Inauguration from Anywhere

Major props to LifeHacker for having the authoritative guide to catching the inauguration ready to go by Monday morning. It’s nice to see dudes practicing what they preach (i.e. getting things /done/).

Running multiple instances of MySQL on the same machine | MDLog:/sysadmin

As you phase MySQL out of your life, you may find that you want to centralize all your legacy MySQL db’s (e.g. your 4.x MySQL db that you can’t upgrade and your current 5.x that you don’t want chewing up resources on your production machines and that 5.1.x that you had to install in order to make it clear to your superiors that MySQL was dead) on a single machine. This is a good guide to getting started on that.

YouTube – ChangeDotGov’s Channel

Obviously going to be slashdotted all to shit this week: I’d feel remiss if I didn’t do my bit to help Google set all kinds of bandwidth records on this Inauguration.

Building desktop Linux applications with JavaScript: Page 1

Java apps are ugly and programming them is confounding (full disclosure: I think QT looks great, generally speaking, and I really, really like the way Opera looks). But as far as user-land goes, they’re preferable to anything that’s nailed to a single OS. Especially in ye olde enterprise setting. This Ars piece makes the case for more "extensibility" and interoperability en route to a primer on "Seed". Worth a quick read, if only to have it as a talking point the next time someone wants an application developed for the office Windroids.

Stubbing out S3 calls in Paperclip

Here’s a quick tip for people using Paperclip that I mentioned on the Google Group. You can easily stub out calls to S3 in your tests using mocha like so:

Photo.any_instance.stubs(:save_attached_files).returns(true)
Photo.any_instance.stubs(:destroy_attached_files).returns(true)

Of course, you’d want to change the Photo bit depending on the model you have using Paperclip.

Hopefully this little tip will save others the fruitless Googling and annoying code digging I did :)

Weekly Digest, 1-18-09

Links. Enjoy.

Also: only 2 more days until Barack Obama is our President!!!

Trevor

Dan Gilbert researches happiness

Dan Gilbert presents research and data from his exploration of happiness — sharing some surprising tests and experiments that you can also try on yourself. Watch through to the end for a sparkling Q&A with some familiar TED faces.

A Fresh Look at Callbacks

The entire Rails request cycle is around 4ms. This may have shaved off 1/2ms, which isn’t going to be that big a deal for any app, but like I said, a few more of these optz and the full Rails request cycle will moot Metal.

Gently exceeding expectations

Exceeding expectations is the point of this post, but if you go too far, you don’t just exceed them, you change them. The next time your client comes back for more work, not only will they not believe you when you said that you haven’t completed the work in half the time, they’ll be disappointed that you didn’t go to the same effort as before. It’s a vicious, unfair reality.

Google Quick Search

Mac OS X only: We’ve been crazy about Quicksilver—a free application launcher for Macs—for years now. Today Google is releasing a new search-and-launch application called Google Quick Search developed by Nicholas Jitkoff, the developer of Quicksilver.

Your idea sucks, now go do it anyway

…people could share game objects by dragging them into chat windows… plans for the game fizzled out the engineers created a Flash application for real-time chat plus file-sharing with a particular emphasis on image-sharing… people were interested in the sharing part more than the real-time part… in yet another upheaval they rewrote the Flash application as a regular website and lo, Flickr was born.

Requests Per Second

Durations are a much more useful, and more honest, metric when comparing performance changes in your applications. Requests per second is too wide-spread for us to stop using it entirely, but please don’t use it when talking about performance of your web applications or libraries. [Fantastic to see this blog back in action!]

path to * mastery

Tutorials tend to go by the assumption that the listed code works as advertised, and that you’ll be massively productive. That rarely happens to be the case. There are many times when little edge cases make the code blow up in strange ways. Don’t panic, just learn how to debug the errors and fix the issue. I don’t mean just commenting out enough code until it starts working, but actually finding the root of the error.

Regarding The Personal Web

I don’t think it’s possible to have a successful presence or brand today without being a part of the social networks, without contributing more than just one kind of content, without using multiple channels. But I have no plans to stop writing and publishing here. Actually, I still feel like I’m just getting started.

10 things to be aware of in moving to Ruby 1.9

I thought I’d share my personal list of things you need to be careful of as you go from 1.8 to 1.9. This is not a list of changes; it’s a list of changes that you really need to know about to get your 1.8 code to work in 1.9, things that have a relatively high likelihood of biting you if you don’t know about them.

Writing Decisions: Headline tests on the Highrise signup page

We’ve been rotating some headlines and subheads on the Highrise signup page to see if they have an effect on signups. Answer: They do, sometimes significantly. [Amazing that these small changes could make such a huge difference!]

Subdomains in Rails

A quick how-to for creating Basecamp-style subdomains with Rails.

Timothy

Extended G1 battery life anyone? | Android Community

Thinking about getting that extended life battery for your G1? Take a look at the graphic on this page and notice the size increase. Not necessarily a deal breaker, but definitely a game changer.

InformIT: Software [In]security: Top 11 Reasons Why Top 10 (or Top 25) Lists Don’t Work > The 2009 Software Security Bug Parade

Courtesy of Schneier’s blog, this is an interesting take on software bugs and security from the security perspective: good reads for admins, programmers and CSO’s, I think.

Online gamers in China must soon register with real names

China, re: Internet censorship, has once again FAIL’d /mightily/. The complete and utter failure of the Chinese government hivemind to grasp the basic necessities of privacy and how fundamental they are for the survival of a civilization would be hilarious if it weren’t certain to end in buckets of tears and bathtubs of blood.

Meet Son of Storm, Srizbi 2.0: next-gen botnets come online

In a nutshell, Ars explains the recent lull in spam and how the current up-tick is correctly understood as a mild prelude to the impending deluge. Good news for people who like bad news.

A diagram of the apt system

This dude basically used dot to diagram the under-the-hood of apt-get and aptitude; a must-read for anyone administering Debian boxes.

Ask reddit: What LaTeX resume template do you use? : programming

Fair warning: henceforth any links to any LaTeX projects and templates will be submitted to delicious. The world needs /MUCH/ more LaTeX and less word processing.

Make it All Opt-in and Stop Worrying So Much | AndroidGuys

AndroidGuys’ Scott Webster is completely off-base (and by "off-base" I mean "dumbfoundingly ignorant of the basic human right to privacy and the increasingly urgent battle between the privately owned Mega Corps and citizens for control of public spaces and resources into which we were all conscripted when Phil Knight declared open war on us in the 70′s") in his blithe response to the growing concern among the dudes at the Digital Democracy project re: Android’s capacity to a.) gather user info and b.) facilitate location-specific advertisements, but he does provide a handy entree to the debate.

What You Should Know Before Going to America – Topic Powered by Eve For Enterprise

Yeah, this was on reddit, but it really is too hilarious to pass up: a guide for (novice) Japanese tourists by (seasoned) Japanese tourists about how to get by in America. Mostly valuable as one of those exercises in trying to look at yourself the way that other people are looking at you.

Feb/13/2009 at 23:31:30 UTC – the Unix time number reaches 1234567890 seconds. : programming

I don’t know about you, but I’m excited.

demongin6 – Rat’s Nest Edition – Anki – Latin Deck

In what was perhaps the F/OSSiest moment of my life, I responded to my dismay at the lack of a widely available anki deck in Latin by scraping an online dictionary and creating one. The raw .txt file from my scrape can be downloaded here and imported on any contemporary version of anki.

The Sweetheart Brigade: Chicago hip-hop » The Grossest of Faux Pas

My new band just released our debut EP. In the course of the last two months we’ve a.) configured a vanilla WP install (with Disciple theme) to suit our needs, b.) set up a mediawiki install for our private, back-end stuff and c.) recorded a debut EP. The release part for same is this weekend. The Sweetheart Brigade so far has been, for me, an exercise in applying GTD principles/tools and the Linux admin and desktop publishing skills I’ve learned as an office drone to a meaningful, real-world project.

Web 2.0rhea hack mistaken for end of universe • The Register

The best postmortem on last week’s Twitter "hack" (complete misuse of word "hack"); calls the h4x0r’s lack of vision and creativity the result of "pussification". I am inclined to agree.

EU to ban plasma televisions in battle against climate change – Environment, News – Belfasttelegraph.co.uk

Ban plasma TV’s for failing to meet environmental standards? Sure–why not? It would be better to ban them for being unreliable wastes of money that are generally unloaded on unsuspecting marks by unethical, mildly-hungover hard-selling sales-kids in Mega Corp retail chains, but this’ll do.

Skype Launches on Android Platform and more than 100 Java-Enabled Mobile Phones – About Skype

Personally, I only use skype three or four times a year–I can’t stand voice communication. If, however, you need it for biz or for overseas peeps or whatever, you may now holler on your Android phone.

anki – Ancient Latin Deck

This is a guest post from Timothy O’Connell.

A recent LifeHacker article got me interested in anki, a cross-platform Simple Repetition System (SRS) or flash-card app.

anki allows users to create or import modular “decks” of “cards” that they can use to study whatever it is that they want to study. Which is, in and of itself, pretty great: as soon as I learned about this, I got excited. My enthusiasm went on the wane, however, when I discovered that there was no deck for ancient Latin (the casual study of which has long been a hobby of mine).

So I decided to create one by scraping the Latin dictionary at http://classicsunveiled.com/. The details of the scrape and the import of the entries into a Postgres database are relatively uninteresting: there are also hundreds of good tutorial on BeautifulSoup and psycopg2 out there and the world obviously has no use for another one from a self-proclaimed n00b like me.

What the world might find useful, however, is the ancient Latin deck I created. Here’s a step-by-step* on how to get it going:

  1. Download the .txt file from my personal blog: http://demongin.orghttp://s3.amazonaws.com/almosteffortless/ankiLatin.txt
  2. Start anki.
  3. Click “File” -> “Import”
  4. Click “Choose file…” and browse for ankiLatin.txt.
  5. Once you’ve selected the file, everything should be ready to go: click “Import” (to the right of the “Field mapping” controls), give the program a second to import the deck, select close and get busy.

* NB: these instructions are based on the Debian package version of anki (i.e. 0.9.9.4).