Skip to content

Instantly share code, notes, and snippets.

app = Rack::Auth::Digest::MD5.new(my_unprotected_app) do |username|
{ 'Alice' => 'correct-password' }[username]
end
app.realm = realm
app.opaque = 'this-should-be-secret'
run app
@cypher
cypher / scm_tasks.thor
Created May 8, 2009 21:33
A Thor file for keeping a folder with scm repositories up to date
require 'find'
class Scm < Thor
desc "fetch", "Fetches the newest updates for all repositories (git, svn, bzr, hg, darcs) in your current working directory and its subdirectories"
def fetch
#run_pager
find_scm_dirs(File.expand_path(Dir.getwd)) do |scm|
case scm
when ".svn"
require 'sinatra'
get "/" do
dir = "./public/files/"
@links = Dir[dir+"*"].map { |file|
file_link(file)
}.join
erb :index
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!"
# Add the alias
git config --global alias.retrack '!retrack() { git config "branch.$1.remote" $(dirname "$2"); git config "branch.$1.merge" "refs/heads/$(basename "$2")"; }; retrack'
# We want the local branch 'mybranch' to track the remote branch 'origin/mybranch':
git retrack mybranch origin/mybranch
require 'rubygems'
require 'sinatra'
get '/test' do
html = <<-HTML
<html>
<body>
<a href="/">root</a>
</body>
</html>