Skip to content

Instantly share code, notes, and snippets.

View bernd's full-sized avatar

Bernd Ahlers bernd

View GitHub Profile
@bernd
bernd / gist:58327
Created February 4, 2009 20:27 — forked from railsdog/gist:58158
function parse_git_dirty {
[[ $(git status 2> /dev/null | tail -n1) != "nothing to commit (working directory clean)" ]] && echo "*
"
}
function parse_git_branch {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/\1/"
}
function git_prompt {
local dirty=$(parse_git_dirty)
local branch=$(parse_git_branch)
@bernd
bernd / .vimrc
Created February 10, 2010 19:38 — forked from auxesis/.vimrc
" sessions, backups, temporary files
"set backup " Enable creation of backup file.
"set backupdir=~/.vim/backups " Where backups will go.
set directory=~/.vim/tmp " Where temporary files will go.
set viminfo='100,f1
" how long key sequences can take to complete
set timeoutlen=250
" color schemes
" http://vim.wikia.com/wiki/Remove_unwanted_spaces
"
" Removes trailing spaces
function TrimWhiteSpace()
%s/\s*$//
''
:endfunction
au FileWritePre * :call TrimWhiteSpace()
au FileAppendPre * :call TrimWhiteSpace()
module CouchDBAttachments
def attachment(*args)
lambda do |env|
request = ActionDispatch::Request.new(env)
doc = DocWithAttachments.get(request.params[:doc])
serve_attachment(doc, request.params[:path])
end
end
private
# /etc/security/limits.conf
* soft nofile 999999
* hard nofile 999999
root soft nofile 999999
root hard nofile 999999
===========================================================
# /etc/sysctl.conf
# sysctl for maximum tuning
@bernd
bernd / example.rb
Created April 7, 2011 13:29 — forked from jbarnette/example.rb
@jbarnette's state machine stuff
require "stateful"
class Folder < ActiveRecord::Base
include Stateful
# ...
stateful do
state :active
state :inactive
@bernd
bernd / gist:942970
Created April 26, 2011 19:46 — forked from schacon/gist:942899
delete all remote branches that have already been merged into master
$ git branch -r --merged |
grep origin |
grep -v -e '>' -e master |
xargs -L1 |
cut -d '/' -f2 |
xargs git push origin --delete
@bernd
bernd / app.rb
Created May 3, 2011 10:17
Trying a modular sinatra app
require 'sinatra/base'
require 'post'
class App < Sinatra::Base
include Post
end
@bernd
bernd / gossip.rb
Created May 9, 2011 13:16
Playing with a gossip protocol based on EventMachine
require 'rubygems'
require 'eventmachine'
# Playing around with a gossip protocol idea.
class NodeList
attr_reader :owner, :count
def initialize(owner)
@owner = owner
@bernd
bernd / capy-test.rb
Created October 6, 2011 14:55
Simple test with a capybara server.
require 'open-uri'
require 'capybara/rspec'
app = lambda do |env|
[200, {'Content-Type' => 'text/plain'}, ['Hello rat!']]
end
Capybara.app = app
server = Capybara::Server.new(Capybara.app).boot