# 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) |
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)) |
module ActionController | |
class Metal | |
attr_internal :cached_content_for | |
end | |
module Caching | |
module Actions | |
def _save_fragment(name, options) | |
return unless caching_allowed? |
# 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" |
# 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: |
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.
#! /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\" |
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"). |