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
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 / git-pull-request.md
Created March 25, 2013 09:15 — forked from piscisaureus/pr.md
Fetch pull request branches

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = git@github.com:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this:

#!/usr/bin/env ruby
require 'rubygems'
require 'json'
require 'net/http'
require 'net/https'
require 'optparse'
class CheckPuppetRunHealth
def self.run
@bernd
bernd / jruby-startup-tuning.txt
Created September 5, 2013 14:19 — forked from BanzaiMan/gist:6450251
JRuby startup tuning (TieredCompilation)
$ jruby -v
jruby 1.7.5.dev (1.9.3p392) 2013-09-04 090d5dd on Java HotSpot(TM) 64-Bit Server VM 1.7.0_25-b15 [darwin-x86_64]
$ time jruby -J-XX:+TieredCompilation -J-XX:TieredStopAtLevel=1 -J-Xverify:none -e 'require "rails"'
jruby -J-XX:+TieredCompilation -J-XX:TieredStopAtLevel=1 -J-Xverify:none -e 5.18s user 0.47s system 136% cpu 4.142 total
$ time jruby -e 'require "rails"'
jruby -e 'require "rails"' 14.60s user 0.44s system 202% cpu 7.444 total
@bernd
bernd / tar.rb
Created September 16, 2013 16:45 — forked from sinisterchipmunk/LICENSE
require 'rubygems'
require 'rubygems/package'
require 'zlib'
require 'fileutils'
module Util
module Tar
# Creates a tar file in memory recursively
# from the given path.
#