Pastie paradise
Summary: click to select
Ever tried emailing someone a chunk of code? Some program output?
It starts in the default font, then you change it to a fix-width font, but you still don’t have any syntax highlighting; and the end user has no easy way to extract it from their email and reuse it.
Oh, how about sharing chunks of text/code/program output via Skype/GoogleTalk where the IM makes no effort what-so-ever to keep your pasted text nicely formatted.
Or, IRC, where its definitely poor form to paste in multi-line chunks of anything. Plus it looks ugly and is completely non-reusable.
The solution is to store the chunk somewhere else (website) and forward that (url) to all and sundry.
The solution is pastie (or TextMate pastie or other pastie services), by Josh Goebel
How to use?
Hands up if you’ve never driven in a car and used its seatbelts.
Ok, then why does every airline around the world show you how to use one?
Right. So, I’m not going to show you how to use pastie. Its a form and a submit button.
Moving on…
The other day, Chris Wanstrath, took another step closer to becoming a Deity for Novel Helper Apps, with the release of sake – the system-wide Rake tool. A tremendous way to access Ruby code (coded as Rake tasks) from anywhere, without polluting your path, or requiring you to bundle the code as a RubyGem to share it easily.
What does this have to do with pasties?
There is a sake task for sending anything to pastie. Cop a look…
# sake 1.0.6 available now gem install sake -y sake -i http://pastie.caboo.se/73801.txt sake -T sake pastie:send # Sends STDIN or FILE=file to Pastie; # USAGE: cat some_code.rb | sake pastie:send # OR: sake pastie:send FILE=some_code.rb
On OSX, you can get the url for your new pastie in the clipboard using pbcopy:
cat some_code.rb | sake pastie:send | pbcopy
Want to send a patch to someone via pastie?
svn diff | sake pastie:send | pbcopy
and the pastie url is now in your clipboard ready to paste in trac/irc/email, etc.
Pastie-ing sake tasks
Theoretically, you could send someone your beloved sake tasks with:
sake -e my_task | sake pastie:send | pbcopy
As of sake 1.0.6, you can use the -P option instead:
sake -P my_task | pbcopy
Coming from the future
Rumour has it, (because Chris told me) that Chris and PJ are building an app to take pastie-ing to the next level.
I’m guessing the magic formula will be:
- Create a pastie clone
- Add social networking
- Add versioning of pasties
- Write wicked-cool blog post and link the whole store to a dubious personal trait, such as drinking sake and beer at the same time
- Watch their Working With Rails popularity rankings climb (see Chris and PJ)
Bonus - Railscast competition
I love the Railscast videos, by Ryan Bates. Short video chunks of Rails/Ruby goodness.
To motivate people to submit Rails Documentation Patches he’s now running a competition with prizes!
Capistrano variables
Here’s an example of how you can pass variables to your capistrano actions via the cap command.
So, the above action could be called as follows:
cap log cap log -s lines=1000 cap log -s rails_env=test
For reference, you pass values to Rake tasks via environment variables:
rake db:migrate RAILS_ENV=test
Inside the db:migrate task, you’d retrieve the value ‘test’ via ENV['RAILS_ENV'].
And further more, this then compares to how you’d normally pass option values into normal command-line apps:
tail -n 1000 log/production.log
Who said the unix command line wasn’t easy peasy. Bah.

