Dr Nic

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:

  1. Create a pastie clone
  2. Add social networking
  3. Add versioning of pasties
  4. 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
  5. 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!

Related posts:

  1. My attempt at sake task management I’ve used sake intermittently in my workflow. It competes...
  2. Amsterdam Rails Catchup summary It was brilliant to meet up with a dozen or...

14 Responses to “Pastie paradise”

  1. Steve Tooke says:

    I think when your installing sake tasks from pastie you need to add .txt to the url to get the text version, not the html, e.g.

    sake -i http://pastie.caboo.se/73801.txt

  2. Mislav says:

    Neat! Does anyone have a solution to login to Pastie also prior to pasting?

  3. Hakan says:

    A perfect tip for a mac user!
    Btw, I really liked your presentation on IGORUBY.se, especially your awareness of Windows OS as an development platform is bad. But the best of all was your australian accent, it kicked ass.

    I hope to see you present another solution in near future.


    SKÃ…L! (Skoooaaal)

  4. Dr Nic says:

    @steve – thx, fixed.

    @hakan – I’ll need to practise my SKÃ…L (“cheers”) more often :)

  5. Brett says:

    Thanks for another great post. BTW there is a Linux alternative to pbcopy called xclip. http://people.debian.org/~kims/xclip/

  6. Kevin Marsh says:

    This is probably cheating, but if you issue “sake pastie:send” with no arguments, you’ll get a free “editor” that you can type in. Press Ctrl+D when you’re done and this “editor” will “publish” your writings to pastie and give you the URL.

  7. Dr Nic says:

    @Kevin: That’s very cute. Nice find!

  8. Pauliephonic says:

    Dr Nic,
    whats with the click to select thingy at the top of the Article?

    Is it to make copying the article summary easier than selecting and copying?


  9. Dr Nic says:

    @paulie – I figured some of my intro paragraphs didn’t lend themselves to copy+paste into bookmark sites. Currently its manually added into the posts; I’ll figure out some javascript for it one day :)

  10. Dr Nic says:

    Oh, I’ve just discovered the wonders of xargs.

    Now I know how to pipe the url returned by sake pastie:send to the open command:

    cat some_file | sake pastie:send | xargs open
  11. Ryan Davis says:
    open `sake pastie.send < some_file`
  12. Aníbal says:

    Now we built a better way to share sakes, please feel free to check http://sakebar.railsrumble.com/ A sake directory to make simple to locate and share sake snippets. Need to go to sleep, this 48 hours of the rails rumble have been really hard.

  13. Dr Nic says:

    @Aníbal [via] – very nice. When you find another 48hrs, it’d be cool to have a comments section etc, for each task. Then we could have chats about namespaces (e.g. newgem:tag, might be better as gem:hg:tag or just hg:tag) and code etc.

    But very cool indeed!

  14. Roman says:

    @Dr Nic [via] – We worked hard (Anibal, Edgar and I) to make a tool for the whole community.
    Sometime (sooner than later) we will provide support to OpenID identification and comments. Stay tuned and please vote for us at The Rumble.

    Hope see some of your favorite Sakes made by you there. Sake is great!!! We just need to advertise it a little bit more :-D .