Skip to content

Instantly share code, notes, and snippets.

require 'sinatra'
get "/" do
"<h1>Your files, sir.</h1>"
end
@bhb
bhb / butler.rb
Created November 20, 2008 22:50
require 'sinatra'
require 'pathname'
get "/" do
html = "<h1>Your files, sir.</h1>"
dir = "./files/"
Dir[dir+"*"].each do |file|
html+=file_link(file)
end
html
@bhb
bhb / butler.rb
Created November 20, 2008 21:58
require 'sinatra'
require 'pathname'
get "/" do
dir = "./files/"
@links = Dir[dir+"*"].map { |file|
file_link(file)
}.join
erb :index
end
require 'sinatra'
get "/" do
"<h1>Your files, sir.</h1>"
end
require 'sinatra'
require 'pathname'
get "/" do
html = "<h1>Your files, sir.</h1>"
dir = "./files/"
html += file_link("./files/foo.txt")
html
end
require 'sinatra'
require 'pathname'
get "/" do
dir = "./files/"
@links = Dir[dir+"*"].map { |file|
file_link(file)
}.join
erb :index
end
<html>
<head>
<meta name="viewport" content="width=320; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;"/>
<style type="text/css" media="screen">@import "/stylesheets/iui.css";</style>
<script type="application/x-javascript" src="/javascripts/iui.js"></script>
</head>
<body>
<div class="toolbar">
<h1 id="pageTitle"></h1>
helpers do
def file_link(file)
filename = Pathname.new(file).basename
"<li><a href='#{file}' target='_self'>#{filename}</a></li>"
end
end
require 'rubygems'
require 'ruby-growl'
g = Growl.new("localhost", "ruby-growl", ["ruby-growl Notification"], ["ruby-growl Notification"], nil)
g.notify("ruby-growl Notification", "It Came From Ruby-Growl", "Greetings!", 1, true)
// This is a slightly altered version of the script at
// http://userscripts.org/scripts/show/43545
// I simply replaced
// 'w'.charCodeAt(0)
// with
// 23
document.addEventListener('keypress', function(event){
var target = event.target;
if (event.ctrlKey && event.charCode == 23