F
Florian Groß
Moin.
I've written a system service for OS X that allows you to execute
selected Ruby code in any OS X application by hitting Apple-* --
Adium, Safari, X-Chat, Mail, TextMate, more. Use it as a calculator or
for quickly executing any kind of Ruby code.
It will turn
The number is rand
into
The number is 0.70682595577091
when you select rand and hit Apple-*.
It will turn
"Hello World".reverse
into
"dlroW olleH"
when you select the line and hit Apple-*.
It also supports these things:
2**32#
x = 0
5.times do
x += 5#
end
raise#
They result in this when you select everything and hit Apple-*:
2**32 # => 4294967296
x = 0
5.times do
x += 5 # => 5, 10, 15, 20, 25
end
raise # ~> -:7: unhandled exception
It uses mfp's xmpfilter.rb and ThisService and is written in Ruby.
To install:
1) Download http://flgr.0x42.net/ExecuteasRubycode.service.zip
2) Unextract the archive if your browser hasn't done so already.
3) Move ExecuteasRubycode.service to ~/Library/Services or /Library/
Services.
4) Relogin to OS X.
You can use Service Scrubber (http://www.manytricks.com/
servicescrubber/) to assign a custom hot key.
To see or modify the source code right click the service, select 'Show
package contents' and navigate to Contents/Resources.
Kind regards,
Florian Gross
I've written a system service for OS X that allows you to execute
selected Ruby code in any OS X application by hitting Apple-* --
Adium, Safari, X-Chat, Mail, TextMate, more. Use it as a calculator or
for quickly executing any kind of Ruby code.
It will turn
The number is rand
into
The number is 0.70682595577091
when you select rand and hit Apple-*.
It will turn
"Hello World".reverse
into
"dlroW olleH"
when you select the line and hit Apple-*.
It also supports these things:
2**32#
x = 0
5.times do
x += 5#
end
raise#
They result in this when you select everything and hit Apple-*:
2**32 # => 4294967296
x = 0
5.times do
x += 5 # => 5, 10, 15, 20, 25
end
raise # ~> -:7: unhandled exception
It uses mfp's xmpfilter.rb and ThisService and is written in Ruby.
To install:
1) Download http://flgr.0x42.net/ExecuteasRubycode.service.zip
2) Unextract the archive if your browser hasn't done so already.
3) Move ExecuteasRubycode.service to ~/Library/Services or /Library/
Services.
4) Relogin to OS X.
You can use Service Scrubber (http://www.manytricks.com/
servicescrubber/) to assign a custom hot key.
To see or modify the source code right click the service, select 'Show
package contents' and navigate to Contents/Resources.
Kind regards,
Florian Gross