Skip to content

Instantly share code, notes, and snippets.

View vangberg's full-sized avatar

Harry Vangberg vangberg

View GitHub Profile
#!/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.
#--
# 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
# 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
require 'rubygems'
require 'sinatra'
get '/no-hidden' do
erb :no_hidden
end
get '/hidden' do
erb :hidden
end
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!"
@vangberg
vangberg / gist:54192
Created January 28, 2009 21:15
moved to github.com/ichverstehe/nancie
moved to ichverstehe/nancie
# 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 / base.rb
Created January 30, 2009 01:57 — forked from bmizerany/base.rb
host "sinatrarb.com"
accept :xml
provides :xml
get '/' do
"Welcome!"
end
get '/' do
"You are not to be welcomed!"
end
1. I copy http://github.com/ichverstehe/foo/commit/17a5a5d55cb28ea1440be1f704497a588694aab3
2. In jello.rb L17 pasteboard.gets sets @current = http://github.com/ichverstehe/foo/commit/17a5a5d55cb28ea1440be1f704497a588694aab3
3. I have shortener enabled, so after all moulds have been ran, the pasteboard now contains http://tr.im/f7v7?github
4. The loop is repeated, and at jello.rb L17 pasteboard.gets sets @last to @current, which is still the original github-url, and thus pasteboard.gets (which is http://tr.im/..) != @last and the moulds are walked through once more.
On the other hand, if Pasteboard#puts updates @current (which is logically correct, as the current pasteboard *is* whatever #puts sets it to) each copy will only get one time through the moulds.
Doesn't matter much, except, for my Growl mould, where I really prefer only getting one notification :)
@vangberg
vangberg / app.rb
Created February 8, 2009 14:34
file upload w/ sinatra
require 'rubygems'
require 'sinatra'
get '/' do
@files = Dir['public/*'].map {|f| File.basename(f) }
erb :index
end
post '/upload' do
filename = params[:file][:filename]