Bob Zoller
script/runner script that doesn't require an absolute path
the output from Rails’ script/runner -h says you can create custom scripts with a fancy shebang line:
You can also use runner as a shebang line for your scripts like this:
-------------------------------------------------------------
#!/usr/bin/env /Users/bob/Projects/glowworm/script/runner
Product.find(:all).each { |p| p.price *= 2 ; p.save! }
-------------------------------------------------------------
but I hate the idea of hardcoding a path like that. Here’s a workaround: open up your new script, something like script/my_custom_script and fill it like so
#!/usr/bin/env ruby
unless $0 =~ /runner/
system("#{File.dirname(__FILE__)}/runner", __FILE__)
exit 0
end
puts 'your code goes here'
file search similar to TextMate's CMD-T, in bash.
I’m a command line guy. I code Rails apps in vim. I’m happy. I am, however, slightly jealous of TextMate’s CMD-T feature, where you can open a file just by typing a part of the name.
Dusty pointed me to a vim tip for CMD-T like search in vim, but I don’t usually open files from within vim - I do it from the command line.
Here’s my hacked up way to get the same feature from within my normal bash shell. It requires dialog, which I installed with a sudo port install dialog.
add this code to your .bash_login (or equivalent)
function _vfind {
find -E . -type f -name "*$1*" ! -regex '.*/(\.git|\.svn|vendor|log).*' | sed 's/^\.\///' > /tmp/_$$_vfind_files
FOUND=`wc -l /tmp/_$$_vfind_files | awk '{ print $1 }'`
if [ "$FOUND" = "0" ]; then
echo 'no matching files...'
return
fi
cat /tmp/_$$_vfind_files | awk '{ print NR " " $0 }' | xargs dialog --menu 'Choose a file:' 0 0 0 2>/tmp/_$$_vfind_num
tput clear
if [ $? -eq 0 ]; then
FILENUM=`cat /tmp/_$$_vfind_num`
vi `awk "FNR == $FILENUM" /tmp/_$$_vfind_files`
fi
rm -f /tmp/_$$_vfind_files /tmp/_$$_vfind_num
}
alias f=_vfind
Close and re-open your terminal, or simply source ~/.bash_login, and try it out:
# cd my_rails_app # f helper
And here’s what you get:

Arrow around, hit enter to open a file, or escape to cancel. We’ll see if I stick with this in my daily workflow ;)
shared git repo (using ssh transport)
As a quick followup to my last post, here’s the steps I took to make my remote git repo usable by a group of developers, not just me:/etc/group
After you’ve added accounts for everyone, make a group and add everyone to it. This line should look something like:
coders:x:114:bob,docyes,phillip
git repo-config
After creating the remote repo (git —bare init), we need to set the core.sharedRepository variable to “group” - this tells git to create directories and files with group-write permissions.
git repo-config core.sharedRepository group
fix permissions
Now that git will do the right thing, we need to fix the permissions on the existing files and directories.
sudo chgrp -R coders .
sudo chmod -R g+ws .
migrate from svn to git (the full story)
let’s assume you have an svn repository available on some remote server. You want to migrate to git, but not lose all that yummy commit history. None of the posts I read quite managed to cover all the steps involved, so here they are:setup the bare repo on your remote server
ssh example.com
mkdir -p /repos/my_app.git && cd /repos/my_app.git
git --bare init
exit
create a user mapping file
this temporary file will map usernames referenced in svn commit logs to new git-friendly ones. (referenced later as ~/Desktop/users.txt)
bob = Bob Zoller <bob@example.com>
carl = Carl Yestrau <carl@example.com>
phillip = Phillip Bensaid <phillip@example.com>
you might need to add strange entries for usernames like “password” or “(no author)”, so watch out for that.
use git-svn to fetch your existing svn repository
mkdir my_app_tmp
cd my_app_tmp
git-svn init svn+ssh://example.com/home/svn/my_app/trunk/ --no-metadata
git config svn.authorsfile ~/Desktop/users.txt
git-svn fetch
now wait… depending on the size of your svn repo, this can take a long time.
git-clone your tmp app
cd ..
git clone my_app_tmp my_app_clean
remove the remote branch
cd my_app_clean
git remote rm origin
add your new remote branch
git remote add origin ssh://example.com/repos/my_app.git
push local master to remote origin
git push origin master
kill the local temps and re-clone it
cd ..
rm -rf my_app_tmp my_app_clean
git clone svn://example.com/repos/my_app.git
NOW GET TO WORK!
Porchlight SF
Lea-Anne and I went to Porchlight SF last night. This month’s topic was obsession. All the storytellers were great, but two really stood out for me:
Kevin Thompson told a story about a big, barrel chested, “punker than you’ll ever fucking be or try to be” guy, who was obsessed with restoring his ‘64 Dodge Dart to full “vomiting blood” status. His impression of the guy was absolutely hilarious.
The other was Adam Savage (yes, the Mythbusters guy). Adam told a story (at break-neck speed I might add) about his obsession with rare things that were rare for a very specific reason. He described a folder on his computer (“that should be called fucking obsessions”) that contained 40+ gigs of pictures of things he found fascinating. The Dodo bird was one, specifically an exact scale replica of its skeleton. The Maltese Falcon was another. Stories of life-size digital prints, his (apparently false) self-imposed stigma that he wasn’t able to model organic objects, 3D laser scanners and friends with foundries ensued, and were simply fantastic.
Check out Porchlight SF, or don’t, it’s already crowded enough.