Pastie paradise

Posted by Dr Nic on June 28, 2007

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.

Pastie

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!

Trackbacks

Use this link to trackback from your own site.

Comments

Leave a response

  1. Steve Tooke Thu, 28 Jun 2007 11:12:51 UTC

    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 Thu, 28 Jun 2007 12:12:39 UTC

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

  3. Hakan Thu, 28 Jun 2007 13:59:07 UTC

    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.

    http://www.apple.com/getamac/ads/

    SKÅL! (Skoooaaal)

  4. Dr Nic Thu, 28 Jun 2007 14:32:27 UTC

    @steve - thx, fixed.

    @hakan - I’ll need to practise my SKÅL (”cheers”) more often :)

  5. Brett Thu, 28 Jun 2007 15:26:32 UTC

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

  6. Kevin Marsh Thu, 28 Jun 2007 16:35:16 UTC

    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 Thu, 28 Jun 2007 18:13:51 UTC

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

  8. Pauliephonic Fri, 29 Jun 2007 09:51:41 UTC

    OT:
    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?

    P

  9. Dr Nic Fri, 29 Jun 2007 10:11:16 UTC

    @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 Thu, 05 Jul 2007 08:17:50 UTC

    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 Mon, 09 Jul 2007 10:46:41 UTC
    open `sake pastie.send < some_file`
    
  12. Aníbal Mon, 10 Sep 2007 07:33:52 UTC

    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 Mon, 10 Sep 2007 09:36:08 UTC

    @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 Mon, 10 Sep 2007 23:08:26 UTC

    @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.

Comments