RSS

tumble.lukeredpath

Dec 04
Permalink
Nov 01
Permalink

Bundlemate, a TextMate bundle manager

Bundlemate is a little utility that I started work on a few months ago but didn’t really have a chance to finish. I’ve done a fair bit of work on it over the last week and have managed to push out an initial release. You can download it using RubyGems:
$ sudo gem install bundlemate
If it isn’t showing up because Rubyforge’s gem cache hasn’t updated, you can grab it directly from my new personal Rubyforge project page. Run bundlemate help for instructions.
Permalink
I love deadlines. I like the whooshing sounds they make as they fly by.
— Douglas Adams
Oct 31
Permalink
Oct 24
Permalink
Oct 16
Permalink
Oct 02
Permalink
Sep 23
Permalink

Timeout on any Ruby method


require 'timeout'

class TimeoutProxy
  include Timeout
  
  def initialize(receiver, timeout_in_seconds)
    @receiver = receiver
    @timeout_in_seconds = timeout_in_seconds
  end
  
  def method_missing(method, *args, &block)
    timeout(@timeout_in_seconds) do
      @receiver.send(method, *args, &block)
    end
  end
end

class Object
  def with_timeout(timeout_in_seconds)
    TimeoutProxy.new(self, timeout_in_seconds)
  end
end

# EXAMPLE:
#  class Foo
#    def self.some_long_running_method
#      sleep 10; puts 'done';
#    end
#  end
#
#  # without timeout
#  Foo.some_long_running_method
#  #=> 'done'
#
#  # with timeout
#  Foo.with_timeout(3).long_running_method
#  #=> raises Timeout::Error
Sep 20
Permalink
Sep 19
Permalink

Using pastie from the command line

I was having some problems with the Ruby and Curl scripts on Pastie so I hacked together a quick script of my own. It takes the text you want to paste from STDIN and sends it to pastie (run pastie -h for options) and if successful it prints the resulting pastie URL.

Its easy to chain common unix commands together with the pastie script - try this to send the contents of a file to pastie then open the resulting paste in your default browser (OSX/*nix):


$ cat ~/somefile.html | pastie -f html | xargs open