Skip to content

Instantly share code, notes, and snippets.

View bernd's full-sized avatar

Bernd Ahlers bernd

View GitHub Profile
@bernd
bernd / fpm-cookery-rails-app.rb
Created January 21, 2014 22:18
Simple example to package a Rails app with fpm-cookery. (missing some setup for permissions, etc)
class RailsApp < FPM::Cookery::Recipe
description 'A rails app'
name 'my-rails-app'
version '1.0'
source '/tmp/foo', :with => :git
def build
gemhome = Pathname.pwd.join('.gemhome').to_s
@bernd
bernd / array-bench.rb
Created October 8, 2013 07:59
Benchmark Array vs. ThreadSafe::Array
require 'thread'
require 'thread_safe'
require 'benchmark'
core = []
ts = ThreadSafe::Array.new
mutex = Mutex.new
iterations = 5_000
threads = 1000
@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.
#
@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
#!/usr/bin/env ruby
require 'rubygems'
require 'json'
require 'net/http'
require 'net/https'
require 'optparse'
class CheckPuppetRunHealth
def self.run
@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:

@bernd
bernd / fpm-cookery-puppet.rb
Created February 25, 2013 07:00
Playing with puppet for fpm-cookery
require 'puppet'
require 'puppet/application'
require 'puppet/configurer'
Puppet::Util::Log.newdesttype :fpm do
def initialize(i)
$stderr.sync = true
$stdout.sync = true
rescue => e
puts e.message
@bernd
bernd / gitlab.pp
Last active October 21, 2016 13:34
Quick & dirty puppet manifest to install GitLab
# Gitlab installation via puppet on Debian/Ubuntu (quick & dirty)
#
# Based on https://github.com/gitlabhq/gitlabhq/blob/stable/doc/install/installation.md
#
# Tested on Ubuntu 12.04.
#
# Run it:
# $ apt-get install puppet
# $ puppet apply puppet.pp
#
require 'celluloid'
class URLResolver
include Celluloid
def resolve(num, url)
sleep 1
puts "[#{Time.now.to_f}] #{Thread.current.object_id} #{num} Resolving #{url}"
end
end