Skip to content

Instantly share code, notes, and snippets.

@assaf
assaf / gist:205689
Created October 9, 2009 03:55
MySQL/EBS volume hourly snapshot
We couldn’t find that file to show.
# a Rack middleware component that enables ActiveRecord query caching
# To use, put "use QueryCaching" in your Sinatra app.
class QueryCaching
def initialize(app)
@app = app
end
def call(env)
if is_static_file?(env)
@wtaysom
wtaysom / where_is.rb
Created September 23, 2011 08:57
A little Ruby module for finding the source location where class and methods are defined.
module Where
class <<self
attr_accessor :editor
def is_proc(proc)
source_location(proc)
end
def is_method(klass, method_name)
source_location(klass.method(method_name))
@bibendi
bibendi / gist:1315929
Created October 26, 2011 09:57
make action and fragment caching of rails 3.0.9 compatible with content_for
module ActionController
class Metal
attr_internal :cached_content_for
end
module Caching
module Actions
def _save_fragment(name, options)
return unless caching_allowed?
@poobury
poobury / recipe.rb
Created November 9, 2011 10:20 — forked from casualjim/recipe.rb
S3 File Resource for Chef
# Source accepts http/https or the protocol region:// with the host as the bucket
# access_key_id and secret_access_key are just that
# Note resource name has changed from s3_file to s3_aware_remote_file
# for the eu-west-1 region:
s3_aware_remote_file "/var/bulk/the_file.tar.gz" do
source "s3-eu-west-1://your.bucket/the_file.tar.gz"
access_key_id your_key
secret_access_key your_secret
owner "root"
@garybernhardt
garybernhardt / selectable_queue.rb
Last active November 23, 2022 12:42
A queue that you can pass to IO.select.
# A queue that you can pass to IO.select.
#
# NOT THREAD SAFE: Only one thread should write; only one thread should read.
#
# Purpose:
# Allow easy integration of data-producing threads into event loops. The
# queue will be readable from select's perspective as long as there are
# objects in the queue.
#
# Implementation:
@cornchz
cornchz / sy.md
Created August 10, 2012 10:05
Notes from the Mystery Machine Bus - Steve Yegge

Notes from the Mystery Machine Bus

I've spent the past eight years (starting back in June 2004) writing elaborate rants about a bunch of vaguely related software engineering issues.

I was doing all that ranting because I've been genuinely perplexed by a set of "bizarre" world-views held dear by -- as far as I can tell -- about half of all programmers I encounter, whether online or in person.

Last week, after nearly a decade of hurling myself against this problem, I've finally figured it out. I know exactly what's been bothering me.

In today's essay I'm going to present you with a new conceptual framework for thinking about software engineering. This set of ideas I present will be completely obvious to you. You will probably slap yourself for not having thought of it yourself. Or you might slap the person next to you. In fact you probably have thought of it yourself, because it is so blindingly obvious.

@kisom
kisom / mydaemon
Created April 28, 2013 06:10
Sample Upstart and sysvinit script for Go daemons.
#! /bin/sh
### BEGIN INIT INFO
# Provides: mydaemon
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: mydaemon does stuff
# Description: this is an actual executable script, and should be saved in
# /etc/init.d/mydaemon.
AWS_ACCESS_KEY_ID="YOURAWSACCESSKEYID"
AWS_SECRET_KEY="YOURAWSSECRETKEY"
EC2_REGION=$(wget -q -O - http://169.254.169.254/latest/dynamic/instance-identity/document | grep region | awk -F\" '{print $4}')
EC2_INSTANCE_ID=$(wget -q -O - http://169.254.169.254/latest/meta-data/instance-id)
EC2_CLOUDWATCH_NAMESPACE='WebService'
NGINX_CONNECTIONS=$(wget -q -O - http://127.0.0.1/nginx_status | grep 'connections' | awk '{print $3}')
/usr/bin/mon-put-data --region \"$EC2_REGION\" --metric-name HttpConnections --namespace \"$EC2_CLOUDWATCH_NAMESPACE\" --dimensions \"InstanceId=$EC2_INSTANCE_ID\" --value \"$NGINX_CONNECTIONS\" -I \"$AWS_ACCESS_KEY_ID\" -S \"$AWS_SECRET_KEY\"
@kxxoling
kxxoling / locale-c
Created June 8, 2015 04:13
perl: warning: Falling back to the standard locale ("C").
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LANGUAGE = (unset),
LC_ALL = (unset),
LANG = "en_US.utf8"
are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").