This post originated from an RSS feed registered with Ruby Buzz
by Red Handed.
Original Post: Wiki Shell Scripting for MouseHole
Feed Title: RedHanded
Feed URL: http://redhanded.hobix.com/index.xml
Feed Description: sneaking Ruby through the system
A wiki. That stores scripts. Run them from the URL. You have a personal Yubnub. This idea is Jake Donham’s and he dropped in on the MouseHole list a few weeks ago. My incarnation of his script is called MouseCommand.
To give you an idea of what’s possible, a few recipes du jour. For best effect in Firefox, go to about:config and set keyword.URL to http://127.0.0.1:37004/cmd/. Restart Firefox and make sure MouseHole is running and MouseCommand is installed.
Display the system date and time. Arguments optionally passed into String#strftime.
if args.empty?
Time.now.to_s
else
Time.now.strftime( args.join( ' ' ) )
end
url
For debugging. Pass another command in (try: url date or url del ruby) and get a dump of the headers and content generated by that command.
run( args.join '/' ) rescue nil
body = "
"
response.header.map do |k,v|
body += k + ": " + v + " "
end
body + "
#{ response.body }
"
links
Make a list of links for a given URL.
body = "
"
doc = read_xhtml_from "http://#{ args.join '/' }"
doc.each_element( "//a" ) do |link|
if link.attributes['href']
body += "
#{ link.attributes['href'] }
"
end
end
body + "
"
If you have MouseCommand setup as keyword.URL, you can also type new shortcut to create a new command with the name shortcut. Also, list all to see your command list and edit shortcut to… you know… (Again, credit goes to Jared. A bunch of useful command ideas is elsewhere.)