Skip to content

Instantly share code, notes, and snippets.

View mostlyobvious's full-sized avatar

Paweł Pacana mostlyobvious

View GitHub Profile
@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.
@errordeveloper
errordeveloper / Unicorn_and_Upstart.md
Last active February 9, 2022 09:21
Upstart config for a Rails app using Unicorn HTTP server

Using Unicorn with Upstart

This configuration works with Upstart on Ubuntu 12.04 LTS

The reason why it needs to be done this way (i.e. with the pre-start and post-stop stanzas), is because Upstart is unable to track whever Unicorn master process re-execs itself on hot deploys. One can use it without hot-deploys and run Unicorn in foreground also, it then only needs one exec stanza.

This presumes you are not using RVM, so no voodoo dances.

@ku1ik
ku1ik / gist:3930651
Created October 22, 2012 09:38
You don't need bundle exec, rbenv-bundler and other bundler integration scripts

You don't need bundle exec, rbenv-bundler or other bundler integration scripts

You just need 2 things

Just prepend $PATH with .bundle/bin:

$ cat ~/.bashrc
...
export PATH=".bundle/bin:$PATH"

...