Skip to content

Instantly share code, notes, and snippets.

View skippy's full-sized avatar

Adam Greene skippy

  • San Juan County, WA
  • 23:03 (UTC -07:00)
View GitHub Profile
working_directory '/data/myapp/current/'
worker_processes 16
listen '/var/run/engineyard/unicorn_myapp.sock', :backlog => 1024
timeout 60
pid "/var/run/engineyard/unicorn_myapp.pid"
# Based on http://gist.github.com/206253
logger Logger.new("log/unicorn.log")
> db.currentOp()
{
"inprog" : [
{
"opid" : 101690,
"active" : false,
"lockType" : "read",
"waitingForLock" : true,
"op" : "getmore",
"ns" : "?ocal.oplog.$main",
db.currentOp()
{
"inprog" : [
{
"opid" : 242886,
"active" : true,
"lockType" : "write",
"waitingForLock" : false,
"secs_running" : 893,
"op" : "query",
m/r overview:
map: break date/value into various time buckets (multiple emits)... retrieve values from collectionA
reduce: merge key and each item into key => array of values
finalize: search to see if stored calc already exists in collectionB... if so, use some of that meta-data. populate a hash, run calculations for each key, and then insert/upsert into collectionB
Failing test:
ruby acceptance test
6 threads:
> db.data_points.find({ sensor_id: 247, faulty: { $ne: true }, orig_relative_time: { $lte: new Date(1299305991280) }, deleted_at: { $exists: false } }).sort({ orig_relative_time: -1 }).limit(-1).explain()
{
"cursor" : "BtreeCursor orig_relative_time_-1_sensor_id_-1",
"nscanned" : 11859,
"nscannedObjects" : 11859,
"n" : 11859,
"millis" : 1896,
"indexBounds" : {
"orig_relative_time" : [
[
@skippy
skippy / middleware.rb
Created June 6, 2011 17:19 — forked from xdissent/middleware.rb
delete vagrant vm's chef client and node from chef server on destroy
class OnDestroyMiddleware
def initialize(app, env)
@app = app
end
def call(env)
env["config"].vm.provisioners.each do |provisioner|
env.ui.info "Attempting to remove client #{provisioner.config.node_name}"
`knife client show #{provisioner.config.node_name}`
if $?.to_i == 0
@skippy
skippy / gist:1037128
Created June 21, 2011 02:38
chef oddness with ssh_known_hosts
We couldn’t find that file to show.
@skippy
skippy / Node::Attribute#[]
Created July 4, 2011 08:13
ssh_known_hosts
def [](key)
@current_nesting_level << key
# We set this to so that we can cope with ||= as a setting.
# See the comments in []= for more details.
@has_been_read = true
# If we have a set type, our destiny is to write
if @set_type
a_value = @set_type == :automatic ? value_or_descend(current_automatic, key, auto_vivifiy_on_read) : nil
@skippy
skippy / embed.js
Created July 5, 2011 06:46
require within own namespace
window.myApp = window.myApp || {};
(function( myApp, undefined ) {
var require, define;
(function () {
//wrap require.js in our namespace!
var version = "0.24.0".........
}());
myApp.require = require;
@skippy
skippy / gist:1108661
Created July 27, 2011 04:17
knife search node "name:i-2f525a41" -l
$ knife search node "name:i-2f525a41" -l
1 items found
Node Name: i-2f525a41
Environment: development
FQDN:
IP:
Run List:
Roles:
Recipes