Gist of the Day #001 – Irb Syntax Coloring

July 19th, 2010 0 Comments

To get sweet syntax coloring in irb like this:

Do this in your .irbrc file:

iPhone Development

June 17th, 2010 0 Comments iPhone Development

I can develop your iPhone application and help you get it approved in the app store!

ViKing

June 17th, 2010 0 Comments ViKing

ViKing is first ever Vi-like navigation tool for OSX.

http://vikingapp.com

A Better sudo for Dreamhost PS

June 11th, 2010 0 Comments

Tired of having to su to your sudo users on your dreamhost server?  Here’s a quick script to help.

Requirements:

  • You have a sudouser setup on your dreamhost account.  These are only available for private servers.
  • Make sure ~/bin is in your path.

Now to the good stuff.

Puth the following code into ~/bin/sudo

    #!/bin/sh
    su yoursudouser -c "/usr/bin/sudo $*"

    Make the file executable

      $ chmod +x ~/bin/sudo

      You can now do the following from your normal user:

      $ sudo ls

      Getting Started With iCuke

      June 1st, 2010 1 Comments

      Tonight I decided to give iCuke a try but I couldn’t find any good getting started guides.  iCuke is a BDD gem for cucumber that enables integration testing for the iPhone.  I’m familiar with using cucumber with Rails so getting going wasn’t terribly difficult but thought the pre-reqs should be a little more clear.

      Here are five simple steps for getting started:

      Step 1: Setup directories

      $ cd path/to/your/iphone/app
      $ mkdir features
      $ cd features
      $ mkdir support step_definitions

      Step 2: Create cucumber.yml with the following content:
      default: -r support -r step_definitions .

      Step 3: Create support/iphone.rb with the following content:
      require 'icuke/cucumber'

      Step 4: Enable the iPhone Simulator Accessibility Inspector in System Preferences
      Step 5:  Create app.feature with the following content:

      Background:  Given "MyApp" from "../MyApp.xcodeproj" is loaded in the simulator
      Scenario: User views the Home screen When I tap "Home"   Then I should see "Welcome"

      Show Path in Finder Window Title Bars

      March 26th, 2010 0 Comments

      Here’s a quick way to show your path in Finder windows.  Open a Terminal window and enter the following:

      To enable:

      $ defaults write com.apple.finder _FXShowPosixPathInTitle -bool YES
      $ killall Finder

      To disable:

      $ defaults write com.apple.finder _FXShowPosixPathInTitle -bool NO
      $ killall Finder

      Vim Screencasts

      March 16th, 2010 0 Comments

      Derek Wyatt’s Screencasts – By far the best series on learning Vim I’ve seen.  Must see.
      http://www.vimeo.com/user1690209/videos

      UPDATE – Derek Wyatt has created a new, more organized site for his Vim tutorials
      http://www.derekwyatt.org/vim/vim-tutorial-videos/

      Vimcasts – This is a good link to add to your rss reader. Updates fairly often with good vim tips.
      http://vimcasts.org/

      Codeulate Screencasts’ Vim for Rails Developers – I actually haven’t gotten to watch this yet but I will be getting it soon.
      http://www.codeulatescreencasts.com/products/vim-for-rails-developers

      Using a Seperate Browser for Selenium with Cucumber

      December 30th, 2009 0 Comments

      If you’re using Selenium with Cucumber on a Mac you probably know that Firefox 3.5.3 is that latest version that works with Selenium. I was getting fed up with not being able to update to the latest version of Firefox so here’s what I did. Simply install Firefox 3.5.3 (the latest Selenium compatible browser at the time of this writting) and name it /Applications/Firefox-3.5.3.app

      This will be the Firefox installation Selenium will use and now you’re free to upgrade your /Applications/Firefox.app install.

      Now add the following code to your RAILS_ROOT/features/environments/selenium.rb file.

      Webrat.configure do |config|

      config.mode = :selenium

      # Selenium defaults to using the selenium environment. Use the following to override this.

      config.application_environment = :test

      config.selenium_browser_key = *firefox /Applications/Firefox-3.5.3.app/Contents/MacOS/firefox-bin

      end

      Don’t forget to do this hack:

      $ cd /Applications/Firefox-3.5.3.app/Contents/MacOS
      $ mv libsqlite3.dylib _libsqlite3.dylib

      For more help setting up Cucumber and Selenium, check my other post Setting Up Cucumber to Use Webrat and Selenium with Rails.

      Fixing Airfoil Speakers for Ubuntu

      December 13th, 2009 0 Comments

      Airfoil is a great piece of software that I use for playing music on all the computers and iPhones in my house.  This weekend I tried to install Airfoil speakers on the Unbuntu machine in my workshop and ran into trouble.  Long story short, I needed to replace the installed DLLs with those of the Windows client.  This works because DLLS are .NET libraries and run on Mono on Ubuntu.

      I’ve packaged the DLLs here so you don’t have to find a Windows machine to install Airfoil speakers on.

      Setting Up Cucumber to Use Webrat and Selenium with Rails

      December 8th, 2009 0 Comments

      The following is the result of having to setup cucumber to use webrat and selenium twice from scratch and not finding a very good resource for doing so. I hope this can help someone else. Corrections and feedback are welcome.

      Install selenium-client version 1.2.16
      $ gem install selenium-client --version=1.2.16

      Generate cucumber environment
      $ ./script/generate cucumber

      Cucumber Setup:

      Use can use my cucumber_setup rails generator. It’s on github at http://github.com/kevincolyar/rails_generators and run:

      $ ./script/generate cucumber_setup

      and you’re done.

      Otherwise, here’s how you can setup your rails environment to use both webrat and selenium with rails from scratch.

      Create a cucumber.yml file in the root of your rails project containing the following:

      1 default: -r features/support -r features/environments/plain.rb -r features/step_definitions features/plain
      2 selenium: -r features/support -r features/environments/enhanced.rb -r features/step_definitions features/enhanced
      3 autotest: -r features/support -r features/environments/plain.rb -r features/step_definitions --color --format pretty --tags ~@selenium
      4 autotest-all: -r features/support -r features/environments/plain.rb -r features/step_definitions --color --format progress --tags ~@selenium
      5

      Create the following directories:

      $ mkdir features/environments features/plain features/enhanced

      Create features/environments/plain.rb containing the following:

      1 #Cucumber::Rails.use_transactional_fixtures
      2 #Cucumber::Rails.bypass_rescue # Comment out this line if you want Rails own error handling
      3
      4 Webrat.configure do |config|
      5   config.mode = :rails
      6 end
      7 # (e.g. rescue_action_in_public / rescue_responses / rescue_from)

      Create features/environments/enhanced.rb containing the following:

      1
      2 Webrat.configure do |config|
      3 config.mode = :selenium
      4 # Selenium defaults to using the selenium environment. Use the following to override this.
      5 # config.application_environment = :test
      6 end
      7
      8 # this is necessary to have webrat "wait_for" the response body to be available
      9 # when writing steps that match against the response body returned by selenium
      10 World(Webrat::Selenium::Matchers)
      11
      12 Before do
      13 # truncate your tables here, since you can't use transactional fixtures*
      14 end

      Firefox hack:
      $ cd /Applications/Firefox.app/Contents/MacOS
      $ sudo mv libsqlite3.dylib _libsqlite3.dylib

      If anyone knows a better fix for this please let me know.

      Running Cucumber:

      Now just place your webrat stories in features/plain and your selenium stories features/enhanced

      To run your webrat stories, simply run:
      $ cucumber

      To run your selenium stories, run:
      $ cucumber -p selenium