Skip to content

Instantly share code, notes, and snippets.

@lyondhill
lyondhill / scheduledjobs.rb
Created December 21, 2011 17:59
scheduledjobs
class ScheduledJob
include Mongoid::Document
field :minute, :type => Array, :default => ['*']
field :hour, :type => Array, :default => ['*']
field :day, :type => Array, :default => ['*']
field :month, :type => Array, :default => ['*']
field :week, :type => Array, :default => ['*']
field :url
@lyondhill
lyondhill / crontest.rb
Created December 29, 2011 23:13
cron test
require 'spec_helper'
describe ScheduledJob do
it "should return an empty criteria" do
time = Time.new(1111,1,1,1,1,1)
ScheduledJob.create(:minute => [time.min])
ScheduledJob.create(:hour => [time.hour])
ScheduledJob.create(:day => [time.day])
ScheduledJob.create(:month => [time.month])
global:
env:
- APP_NAME: lucy
- ENV: production
web1:
cron:
- "* * * * *": "ls -la"
- "*/3 */2 1-3 2,6,7 2": "echo 'im a little teapot'"
@lyondhill
lyondhill / componentstats
Created February 24, 2012 23:50
component-stats
http://analytics.pagodabox.com/components/4ea893f048afd85b6500014e/hardware-usage
should return:
hardwareUsage({"data":[{"cpu":0,"mem":0,"hour":"0"},{"cpu":0,"mem":0,"hour":"1"},{"cpu":0,"mem":0,"hour":"2"},{"cpu":0,"mem":0,"hour":"3"},{"cpu":0,"mem":0,"hour":"4"},{"cpu":0,"mem":0,"hour":"5"},{"cpu":0,"mem":0,"hour":"6"},{"cpu":0,"mem":0,"hour":"7"},{"cpu":0,"mem":0,"hour":"8"},{"cpu":0,"mem":0,"hour":"9"},{"cpu":0,"mem":0,"hour":"10"},{"cpu":0,"mem":0,"hour":"11"},{"cpu":0,"mem":0,"hour":"12"},{"cpu":0,"mem":0,"hour":"13"},{"cpu":0,"mem":0,"hour":"14"},{"cpu":0,"mem":0,"hour":"15"},{"cpu":0,"mem":0,"hour":"16"},{"cpu":0,"mem":0,"hour":"17"},{"cpu":0,"mem":0,"hour":"18"},{"cpu":0,"mem":0,"hour":"19"},{"cpu":0,"mem":0,"hour":"20"},{"cpu":0,"mem":0,"hour":"21"},{"cpu":0,"mem":0,"hour":"22"},{"cpu":0,"mem":0,"hour":"23"}],"description":""})
@lyondhill
lyondhill / options.txt
Created March 2, 2012 18:21
Options of Hierarchical analogy
1 Military
Battalion
Platoon
Squad
FireTeam
2 Biology
Kingdom
Phylem
Genis
scale up
+> Booting web1.1
+> Building secure tunnel to component
- [16-Mar-2012 16:39:58] NOTICE: fpm is running, pid 54
- [16-Mar-2012 16:39:58] NOTICE: ready to handle connections
+> Booting web1.2
+> Building secure tunnel to component
- [16-Mar-2012 16:40:22] NOTICE: fpm is running, pid 54
- [16-Mar-2012 16:40:22] NOTICE: ready to handle connections
worker1:
exec: QUEUE=default php /var/www/worker.php
start:
ready: ready to accept jobs
timeout: 10
exec: QUEUE=default php /var/www/worker.php
stop:
signal: QUIT
timeout: 60
exec: php /var/www/worker.php --quit-graceful
@lyondhill
lyondhill / riak_sample.rb
Created June 27, 2012 19:48
I need help figureing out how to do this
# I have data that looks like this
{
timestamp: 123466 # unix timestamp since epoc
component: 'id1' # some unique id
processes: 'id2' # another unique id
cpu: 30 # a cpu usage statistic for the component/process
mem: 79 # a memory usange stat
}
<?php
/**
* Part of the Fuel framework.
*
* @package Fuel
* @version 1.0
* @author Fuel Development Team
* @license MIT License
* @copyright 2010 - 2012 Fuel Development Team
* @link http://fuelphp.com

Things Andrew

  • First I would like a quick way archatechtural talk with big squares and circles and arrows
  • turn diagram into a walk through of the calls as it starts in a invoice sync
  • ::Pagoda::Landlord::App (line 124) is there a reason to use the result of the block to change the sum?

billable_components.inject(0) do |sum, component| amount = component.calculate_rent_on_processes(start_at, stop_at) if block_given?