Skip to content

Instantly share code, notes, and snippets.

View macournoyer's full-sized avatar

Marc-André Cournoyer macournoyer

View GitHub Profile
class ModifyResponseHeaders
def initialize(app)
@app = app
end
def call(env)
status, headers, body = @app.call(env)
headers["cache"] = "..."
[status, headers, body]
end
@macournoyer
macournoyer / .gitconfig
Last active September 30, 2015 23:18
Git shortcuts
[alias]
st = status
s = status
co = checkout
c = commit -v
ci = commit -a -v
b = branch
d = diff
p = pull
a = add -A .
@macournoyer
macournoyer / gist:1812942
Created February 13, 2012 02:53
My bash prompt
function parse_git_branch {
ref=`git symbolic-ref HEAD 2> /dev/null` || return
branch="${ref#refs/heads/}"
if [ $branch != "master" ]
then
echo "($branch)"
fi
}
function parse_rvm_prompt {
@macournoyer
macournoyer / app.ru
Created August 19, 2011 17:02
The invisible block web framework. In honor of _why.
# rackup app.ru
require "./invisible"
app = Invisible.new do
get "/" do
render do
h1 "Why?"
p "Because."
end
@macournoyer
macournoyer / tm_reveal_in_github.rb
Created January 14, 2011 15:31
Reveal in GitHub TextMate command
#!/usr/bin/env ruby
# Reveal in GitHub TextMate command
require 'pathname'
path = Pathname.new(ENV["TM_FILEPATH"]).relative_path_from(Pathname.new(ENV["TM_PROJECT_DIRECTORY"]))
repo_path = `/usr/local/bin/git remote show origin`[/Fetch URL: git@(.*)\.git$/, 1].tr(":", "/")
branch = `/usr/local/bin/git symbolic-ref HEAD`[/refs\/heads\/(.*)$/, 1]
exec "open 'http://#{repo_path}/blob/#{branch}/#{path}'"
# In your .gitconfig
[alias]
ptp = !git pull && rake && git push
push-retry = !git push || git ptp
// compile: gcc 0L.c
// example:
// ./a.out 00201320130
// expanded:
// ./a.out \
// 002 # LOAD R[0] = 2 \
// 013 # LOAD R[1] = 3 \
// 201 # ADD R[0] += R[1] \
// 30 # PRINT R[0]
// should print: 5
require "talker"
module Connection
attr_accessor :client
def data_received(data)
client.send_message data
end
end
@macournoyer
macournoyer / ghi.rb
Created December 7, 2009 21:20
CLI for github issues WITH COLORS!
#!/usr/bin/env ruby
require "rubygems"
require "mutter"
require "httparty"
REMOTE = "origin"
REPO = `git config --get remote.#{REMOTE}.url`.chomp[/github\.com[\/\:]([^\/]+\/[^\/]+)\.git/, 1]
USER = `git config --get github.user`.chomp
TOKEN = `git config --get github.token`.chomp