Skip to content

Instantly share code, notes, and snippets.

View mostlyobvious's full-sized avatar

Paweł Pacana mostlyobvious

View GitHub Profile
# Hook into unicorn, unicorn middleware, not rack middleware
#
# Since we need no knowledge about the request we can simply
# hook unicorn
module Middleware::UnicornOobgc
MIN_REQUESTS_PER_OOBGC = 5
MAX_DELTAS = 20

NOTE TO CONTRIBUTORS : Take this wherever you like. If you have articles that really helped you, add them to the list of resources at the end. All content added to this EtherPad is considered public domain. Add your name to the list of contributors at the end of you want attribution.

Suggestions on where to eventually take this content are welcome. I was thinking of making it into a Github pages branch, or maybe on a wiki somewhere?

Testing Chef Cookbooks : A Landscape

There seem to be many approaches to test driving your Chef infrastructure, and the amount of projects to pick from is overwhelming. This document tries to provide some overview.

@eric
eric / README.md
Last active December 17, 2015 00:39
Zookeeper-based storage adapter for rollout

Update

You can now find this packaged up nicely in a rubygem as rollout-zk.


Zookeeper storage adapter for rollout

I've implemented a zookeeper-based storage adapter for [rollout][] that does not require any network roundtrips to check if a feature is active for a user.

@perplexes
perplexes / buildpacks.md
Last active June 24, 2025 15:18
Heroku custom compiled library .bundle/config

Buildpacks

Heroku uses buildpacks to compile your application into a slug that is used across dynos for scaling horizontally quickly. A slug is a tar.gz archive of your app’s repository with certain pre-deploy features baked into the filesystem. Since everything to run your application is included in the archive, scaling becomes a simple matter of transferring it to a dyno, unpacking, and running the appropriate process. This is how Heroku achieves scaling-by-moving-a-slider.

For example, the Ruby buildpack will:

  • install ruby locally
  • install the jvm/jruby (if you’re using it)
  • install/run bundler and install your gems to Rails.root/vendor
  • create your database.yml (which ends up reading from your app’s environment variables)
@paneq
paneq / page.conf
Created April 3, 2013 14:57
nginx maintenance page that is JSON friendly
if (-f $document_root/system/maintenance.html) {
return 503;
}
error_page 503 @maintenance;
location @maintenance {
internal;
if ($http_accept ~ json) {
return 503 "{}";
}
@myronmarston
myronmarston / stack_overflow_debugger.rb
Created March 30, 2013 21:20
Debug SystemStackError with this utility file.
max_stack_frames = 500
TooManyStackFrames = Class.new(StandardError)
set_trace_func proc { |event, file, line, id, binding, classname|
if event == "call" && caller.size >= max_stack_frames
raise TooManyStackFrames, "Stack has exceeded #{max_stack_frames} frames"
end
}
@polarblau
polarblau / jquery.baseplugin.coffee
Created February 11, 2013 13:08
Base for new jQuery plugins written in Coffeescript. Enables plugin methods. Based on http://coffeescriptcookbook.com/chapters/jquery/plugin and http://docs.jquery.com/Plugins/Authoring#Plugin_Methods .
$ = jQuery
$.fn.extend
foobar: (method) ->
settings =
option1: true
option2: false
@rwjblue
rwjblue / readme.md
Last active May 13, 2016 18:10
Guide to using drip with JRuby

#Overview drip is an awesome command line tool that can be used to dramatically lower perceived JVM startup time. It does this by preloading an entirely new JVM process\instance and allowing you to simply use the preloaded environment. This has extraordinary results with jruby.

We reduced time to run rake environment from 13 seconds to a mere 3.5 seconds. This is actually at or near MRI 1.9.3p327 (with falcon patch) speeds!

Adding a few addition jruby options will reduce startup time even further (down to 1.69 seconds).

#Install Drip Install drip if you haven't already (see https://github.com/flatland/drip)

@overplumbum
overplumbum / gist:4473076
Last active March 15, 2022 12:03
OpenVPN server as an LXC container
#!/bin/bash
set -ve
lxc-create -n vpn -t ubuntu
# ln -s /var/lib/lxc/vpn/config /etc/lxc/auto/vpn.conf
perl -i -ple 's/#lxc.aa_profile = unconfined/lxc.aa_profile = unconfined/' /etc/lxc/auto/vpn.conf
perl -i -ple 's/^exit 0/# exit 0/' /etc/rc.local
cat >>/etc/rc.local <<hello
mkdir -p /var/lib/lxc/vpn/rootfs/dev/net/
class Safeware
def initialize(app)
@app = app
end
# This dup pattern is used frequently to avoid race conditions on state stored
# inside this middleware. It's not foolproof, but if you're just using
# single-reference instance variables (instance variables with primitive
# values (not data structures)) then it works well.