Skip to content

Instantly share code, notes, and snippets.

View gist:22909
require "openssl"
require "net/smtp"
Net::SMTP.class_eval do
private
def do_start(helodomain, user, secret, authtype)
raise IOError, 'SMTP session already started' if @started
check_auth_args user, secret, authtype if user or secret
sock = timeout(@open_timeout) { TCPSocket.open(@address, @port) }
@bhb
bhb / foo.rb
Created Nov 13, 2008
undefined
View foo.rb
class Foo
def bar
puts "Hello, world!"
end
end
View butler.rb
require 'sinatra'
require 'pathname'
get "/" do
dir = "./files/"
@links = Dir[dir+"*"].map { |file|
file_link(file)
}.join
erb :index
end
View butler.rb
require 'sinatra'
get "/" do
"<h1>Your files, sir.</h1>"
end
View butler.rb
require 'sinatra'
get "/" do
"<h1>Your files, sir.</h1>"
end
View butler.rb
require 'sinatra'
require 'pathname'
get "/" do
html = "<h1>Your files, sir.</h1>"
dir = "./files/"
html += file_link("./files/foo.txt")
html
end
View butler.rb
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
View butler.rb
require 'sinatra'
require 'pathname'
get "/" do
dir = "./files/"
@links = Dir[dir+"*"].map { |file|
file_link(file)
}.join
erb :index
end
View index.erb
<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>
View butler_helpers.rb
helpers do
def file_link(file)
filename = Pathname.new(file).basename
"<li><a href='#{file}' target='_self'>#{filename}</a></li>"
end
end