Archive for the 'Software/Scripts' Category

Thursday, September 4th, 2008

BasecamPHP Updates

Over the past 2 years (!!!) since I put up my little basecamp API wrapper I’ve received a lot of great feedback and comments from other developers. In using it for their various projects they ran into some inevitable bugs and defects. Unfortunately, I haven’t been very responsible and didn’t compile the fixes into a new release. In general I’m pretty much exclusively doing ruby these days so I’m not even really making use of the wrapper anymore. Thanks to github (see previous post) I now have a very easy way of putting up the library for not only easy download but for community development (woohoo!). I’ve already incorporated the changes and given credit to the astute developers responsible in the commit messages.

Check it out: http://github.com/quirkey/basecamphp/tree/master

Thursday, August 28th, 2008

The Scout: my new home away from home on the internet about my home

The Scout

Here’s the big reveal of the biggest thing I’ve been working on over the past forever: The Scout.

There’s a lot to say about this, but my partner in the project, Tom Ran, already said it much more eloquently in an interview with psfk.

I can, however, speak to the technical aspects of the project. It is (of course??) running on Ruby on Rails. I can pat myself on the back about it’s very powerful but easy to use CMS. Were working on adding a lot more articles right now and the whole set up seems to be chugging along without a hitch.

The whole project was a beautiful idea about a year ago but after a lot of lunch and dinner conversations I can finally say that it’s a reality.

I learned a lot on the project and used it as an excuse to grok some new technologies (or at lest new to me) like the Google Maps API.

Were hoping to continue to push our features and content in the coming weeks and months. To keep up:

1. Join the mailing list
2. “follow the site’s RSS Feeds: Blog, Retail, Dining/Bars, Features, and Tours
3. follow thescout on twitter

If you’re interested in contributing email info at the scout mag dot com.

Were just so excited it’s real.

Friday, February 29th, 2008

DRYing up Rails Flash with Flashdance

Flashdance

The scenario: Its 3AM. You've been coding all day and youre just about ready to launch this sweet social networking app for steel workers who love to dance. One last thing - you need to replace all the crappy copy you stuck in to your 'flash' messages with real informative text. "sucesfil post" might make sense to you, but wont make sense to the blue collar guy doing the electric slide all over your server. You go to replace these warnings and feedback messages but theyre all over your code. You think: If Rails is so DRY and the business and display logic are all supposed to be separate, then why am I putting messages that will end up in my views all through my controllers?!

Introducing Flashdance

The get-the-view-out-of-the-controller-so-you-can-rest plugin.

Instead of all-up-in your controller files, messages are stored in a single YAML file:

# in app/views/shared/flash.yml

all_is_good: This is great
this_failed: This failed
using_erb: you are an idiot, <%= @email %>
section:
  subsection: I'm nested
my_controller:
  my_action:
    message: I'm soaking wet

Examples

At its most unobtrusive:

# in your controller
  def update
    # . . . booring part where record gets updated
    flash[:warning] = flashdance(:this_failed) #=> This failed
  end

A little nicer:

def update
    # . . .
    flash(:message => 'all_is_good') # YAML entries can be referred to by strings or symbols
    # equivalent to flash[:message] = "This is great"
  end

ERB is evaluated in the context of the controller so you can do fun things like:

  def tell_off_the_spammer
    # . . .
    @email = 'jon@example.com'
    flash(:warning => :using_erb)
    # equivalent to flash[:warning] = "you are an idiot, jon@example.com"
  end

So what if your app is huge and you use these flash thingies all over the place? Your YAML file might get big and unreadable. Well, thats why you can nest! Nested sections are refered to by arrays.

  def make_a_nest
    #  . . .
    flash(:nest => [:section,:subsection])
    # equivalent to flash[:nest] = "I'm nested"
  end

Flashdance automatically checks for entries nested in the controller/action path where you call it from. And heres where you get splashed with that big bucket of water:

class MyController < ApplicationController
  # . . . 
  
  def my_action
   # . . . where you dance your heart out
   flash(:message)
   # equivalent to flash[:message] = "I'm soaking wet"
  end
end

Install it

From subversion:

./script/plugin install -x svn://svn.quirkey.com/quirkey_tools/trunk/flashdance

or Download: flashdance.tar.gz

You can email me at aaron at this domain for bug reports/comments/suggestions - and I'm looking to set up Trac or something else soon.

Photo credit: http://www.flickr.com/photos/tzofia/185003069/

Thursday, February 28th, 2008

QuirkeyTools

I’ve been such a Rails mooch. Relying on everyone else’s plugins, gems, and helpful blog posts. A while ago I said how I wanted to be a real part of this community. Well its time to stop coding (briefly) and start sharing. It’s time to give back.

Over the past year and a half (!!!) of doing Rails and Ruby full time, I’ve come up with a lot of code thats useful, at least to me. For a while its all been packaged as a plugin on my private SVN server called QuirkeyTools. It’s chock full of helpers, generators, extensions, macros - its bursting at the seems.

So the idea over the next couple of weeks is to start splitting out the code, cleaning up the tests, and releasing them as separate Rails plugins. I’m also going to look into packaging some gems - which sounds like fun.

All of this is made possible in part by the fact that I’ve got a new VPS from slicehost. I’m not getting paid to say this but its awesome! Super fast, haven;t had any reliability problems and its a blank slate - meaning install whatever you want. They also have some great of the best tutorials for setting up. This blog remains (for the time being) on my shared host at Site5, but I’ve set up an SVN server and repositories with public read permissions. So here comes the code . . .

Photo Credit: http://www.flickr.com/photos/docman/36125185/sizes/m/

Monday, January 15th, 2007

Replacing the ‘rails’ command

I always forget about the ’svn copy’ command, and Josh Susser has reminded me of its awesome usefulness. In this case, its usefulness as a way to start projects.

I took his advice a step further. Rolling on the idea of an ‘Image’ of a basic Rails project with its own repository, on top of setting the svn:ignore properties for log/ and tmp/ I also installed a couple things I use in almost every project:

  1. acts_as_authenticated
  2. ar_fixtures
  3. Capistrano rake and deploy tasks

I also generated an authenticated controller/model and added an initial user to my migration, so I’m all set to login. Before importing my ‘basicauth’ Rails image to subversion, I created my svn best practices directories (branches/ tags/ trunk/) and put the rails code into trunk.

After importing, I’m all set to start as many rails projects as I want. Why not use bash scripting to make it even easier.

#!/bin/bash
echo 'Creating new rails app'
cd ~/Sites/
echo 'Creating repository'
svn copy svn+ssh://myuser@myrepos.com/svn/rails/basicauth svn+ssh:/myuser@myrepos.com/svn/rails/$1
echo 'Checking out code'
svn co svn+ssh://myuser@myrepos.com/svn/rails/$1/trunk $1
cd $1
mate .

If I save this, chmod +x it, and copy it to /usr/local/bin/ - Now all I have to do to start a new rails app is:

myrails anewapp

It will copy the repository, checkout the code, and even open it in TextMate.