Skip to content

Instantly share code, notes, and snippets.

View vangberg's full-sized avatar

Harry Vangberg vangberg

View GitHub Profile
# We start with no Content-Type, and in Response#finish it is set to text/html
get "/one" do
erb :example
end
# Start with no Content-Type, sass() sets Content-Type to text/css, Response#finish doesn't touch it,
# because it already has been set, and thus what should have been text/html is now text/css
get "/two" do
erb :sass_example
end
@vangberg
vangberg / gist:54192
Created January 28, 2009 21:15
moved to github.com/ichverstehe/nancie
moved to ichverstehe/nancie
Let's make a list of Sinatra-based apps!
Apps:
- http://github.com/cschneid/irclogger "Sinatra based irclogger.com"
- http://github.com/rtomayko/wink "minimalist blogging engine"
- http://github.com/foca/integrity "The easy and fun Continuous Integration server"
- http://github.com/sr/git-wiki "git-powered wiki"
- http://github.com/entp/seinfeld "Seinfeld-inspired productivity calendar to track your public github commits."
- http://github.com/karmi/marley "Marley, the blog engine without <textareas>."
- http://github.com/ichverstehe/gaze "Serve up your Markdown files with this tiny Sinatra app!"
require 'rubygems'
require 'sinatra'
get '/no-hidden' do
erb :no_hidden
end
get '/hidden' do
erb :hidden
end
# the lil' deployment script
APP_PATH = '/var/webapps/ltt'
APP_REPO = '/home/harry/git/ltt.git'
APP_SERVER = 'ak'
def ssh(command)
`ssh #{APP_SERVER} sh -c '#{command.inspect}'`
end
# Easy view testing for Rails with Hpricot.
#
# Prefix 'response' with @ for Sinatra.
class Test::Unit::TestCase
# elements('h1') returns a Hpricot::Elements object with all h1-tags.
def elements(selector)
Hpricot(response.body).search(selector)
end
#!/usr/bin/env ruby
#--
# Name : git_watch.rb
# Author : Jerod Santo
# Contact : "[email protected]".reverse
# Date : 2008 October 14
# About : Checks a git repository for changes and emails provided email
# address if changes have been made. Schedule with cron.
#--
require 'rubygems'
require 'addressable/uri'
require 'socket'
class IRC
def self.shoot(uri, options={}, &block)
raise ArgumentError unless block_given?
uri = Addressable::URI.parse(uri)
irc = new(uri.host, uri.port, options.delete(:as)) do |irc|
require 'socket'
server = "irc.freenode.net"
channel = "#awesome_channel"
s = TCPSocket.open("irc.freenode.net", 6667)
s.puts "NICK simplebot"
s.puts "USER simple simple simple :simple"
s.puts "JOIN #{channel}"
s.puts "PRIVMSG #{channel} :foo bar"
# Grass.new takes two arguments: 1. a dataset consisting of an array of arrays:
#
# [["Label", 10], ["Second label", 78]]
#
# the second argument is optional, and should be a hash of desired options:
#
# :width - specify a CSS width, e.g. '100px' or '70%'
# :height - specify a CSS height, e.g. '200px' or '60%'
# :color - color of the bars, e.g. '#224488'
# :text_color - color of label when placed inside a bar, e.g. '#DDDDDD'