Skip to content

Instantly share code, notes, and snippets.

require 'rubygems'
require 'sinatra'
get '/test' do
html = <<-HTML
<html>
<body>
<a href="/">root</a>
</body>
</html>
# 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
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 'sinatra'
get "/" do
dir = "./public/files/"
@links = Dir[dir+"*"].map { |file|
file_link(file)
}.join
erb :index
end
@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"
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
--sort-files
--color
--context=1
--follow
--group
--all
#!/bin/bash
git push ${1:-origin} $(git branch | sed -ne 's/^\*\ \(.*\)$/\1/p')
# Put this file somewhere in your PATH, call it 'git-up', make it +x,
# and then you can call "git up" to push to origin, or "git up foo"
# to push to 'foo'
git config --global alias.track '! track() {
branch=$(git branch | sed -ne "s/^\*\ \(.*\)$/\1/p")
remote=$1
git config "branch.$branch.remote" $(dirname "$remote")
git config "branch.$branch.merge" "refs/heads/$(basename "$remote")"
}
track'
@cypher
cypher / gist:150248
Created July 20, 2009 10:45
A git pre-commit hook that makes sure any Ruby Syntax is OK
#!/usr/bin/env ruby
#
# A hook script to verify that only syntactically valid ruby code is commited.
# Called by git-commit with no arguments. The hook should
# exit with non-zero status after issuing an appropriate message if
# it wants to stop the commit.
#
# Put this code into a file called "pre-commit" inside your .git/hooks
# directory, and make sure it is executable ("chmod +x .git/hooks/pre-commit")
#