Monday, August 22, 2011

Setting up your work environment with automator

I frequently find myself having to open the same set of applications in order to work (textmate, terminal with several tabs, browser, etc.). So I figured I'd spend some time figuring out how to automate the process.


  • open automator
  • create a new application
  • find "run shell script" <-- try it with this one first, if it doesn't work, use "run applescript"
  • input the following into the shell scripting area (it's a rather small textarea). Change the settings for your particular set of applications you need to use. For me, I want to open my default browser to my local app, open textmate with my project, open my text file with my ongoing notes, and open several terminal tabs with various commands already entered.


open http://myapp.localhost
open ~/Work/myapp/myapp.tmproj
open ~/Desktop/myapp.rtf

osascript 2>/dev/null << EOF

    tell application "Terminal"
       activate
    end tell
    tell application "system events" to tell process "Terminal" to keystroke "t" using command down
    tell application "system events" to tell process "Terminal" to keystroke "t" using command down
    tell application "system events" to tell process "Terminal" to keystroke "t" using command down
    tell application "Terminal"
        do script with command "cd ~/Work/myapp; rails console" in first tab of first window
        do script with command "cd ~/Work/myapp/log; tail -f development.log" in second tab of first window
        do script with command "cd ~/Work/myapp; su -" in last tab of first window
    end tell
EOF

  • save it and put it in your applications directory (it doesn't matter where you put it, but I figure this is the best place)
  • then drag it to your dock

Saturday, July 9, 2011

Installing PostgreSQL on OSX

I've been playing around a bit with PostgreSQL on OSX, and I had to use a bit of *nix/bash general knowledge to get it working, hopefully this can save someone else a little time.

After running the installer that you can find here: http://www.postgresql.org/download/macosx
  1. Switch to root ( su - ).
  2. Then su - postgresql (the installer creates a postgresql user on your box, but you can't login directly as that user, except through root since su - as root bypasses password checks).
  3. Go to your bin directory for PostgreSQL (default on OSX through the install wizard is /Library/PostgreSQL/9.0/bin) and run ./createdb -s -P yourusername (I used my default OSX user). It will prompt you for a password that you want to use for this user. I used my default OSX user's password. One less thing to remember.
  4. Exit back to your default user.
  5. In your .bash_profile, add this to your PATH variable :/Library/PostgreSQL/9.0/bin (change this if you installed to some other directory).
  6. Be sure to run a source ~/.bash_profile so this variable takes effect in your current terminal session.
Now your default OSX user can run PostgreSQL commands.

Tuesday, May 17, 2011

OpenSuSE and mod_proxy_html

Dear OpenSuSE,

What is the point of having mod_proxy_http but not mod_proxy_html installed by default for httpd? This means that out of the box, httpd on OpenSuSE can't run a reverse proxy. Why did you do this?


Thanks,
Branden


Tuesday, April 12, 2011

$.parseJSON with Rails 3's .to_json

This one stumped me for a bit today. If you had any old code from Rails 2.3.* and converted it to Rails 3.0.*, watch out for any instance variables in your controller that you call to_json on for processing by jQuery's $.parseJSON in your view.

Because the default in Rails 3 is to make all strings html safe, you no longer need to use the "h" helper method in your views. However, this means that code like this will no longer work:

controller: @temp = {:hello =>; "world"}
view: alert($.parseJSON("<%= @temp.to_json %>"))

You will get invalid JSON errors, because the "safe" string is not in a valid format for parseJSON. To solve this, use the Rails 3 html_safe helper to tell the view that this string is ok to send through as is:

controller: @temp = {:hello =>; "world"}
view: alert($.parseJSON("<%= @temp.to_json.html_safe %>"))

Sunday, October 24, 2010

i18n bug in Rails




I just ran into a bug when we installed a new gem in the same Ruby install that runs both our test environment and our Redmine install. The problem is that the new i18n gem is not compatible with rails 2.3.5.

The solution was to change this line
gem 'i18n', '>= 0.1.3'

to this
gem '18n', '<=0.4.1'

To ensure that Redmine grabs an earlier version of the i18n gem. Hopefully this saves someone else out there from a few hours of frantic googling.

Saturday, July 24, 2010

Repository browsing with redmine

Redmine plays well with Git. It was so easy to set up, everyone who uses redmine and git should do it.


Using Redmine is now my default way to browse repository commits.

Tuesday, July 13, 2010

f.lux is saving my eyes

Like many technology workers, I suffer from overuse injuries of the fingers and wrists, as well as constant eyestrain. I do much of my programming at night with the lights off, and while OSX has good built in functionality for dimming a monitor (or using the Shades app for secondary monitors), it didn't seem like enough.

I could either have the brightness turned up so I can see, but have my retinas blasted with excess photons, or have the brightness turned down, and then squint as I try to read.

Enter f.lux.

Instead of messing with the brightness of your monitor, f.lux changes the colors of your monitor to be easier on the eyes. At first, it was kind of an uneasy yellow color, but my eyes adapted quickly.

Everything felt normal, until I turned f.lux off. My monitors colors returned to normal, and I instantly felt like icepicks were being driven into my eyes. Needless to say, f.lux was turned back on, and I use it every night. I heart f.lux.