Skip to content

Instantly share code, notes, and snippets.

@dmerrick
dmerrick / update_json_for_nagios.rb
Created March 8, 2012 16:43
tool for adding required json attributes to add hosts to nagios
#!/usr/bin/env ruby
require 'rubygems'
require 'json'
require 'pp' if $DEBUG
class UpdateJsonForNagios
KNIFE_CONFIG = "~/work/chef/.chef/knife.rb"
require 'cgi'
require 'open-uri'
class TorrentManager
def initialize
# configuration options
@list_file = "torrents.txt"
@watch_dir = File.expand_path "~/watch"
class ChangeCalculator
QUARTER = 0.25
DIME = 0.10
NICKEL = 0.05
PENNY = 0.01
COINS = [QUARTER, DIME, NICKEL, PENNY]
def calculate(x)
remaining = x
$h = COINS.inject({}) do |hash, coin|
# this is an example migration template for you to tweak
# it is assumed that this file will be located in script/migrations
require File.expand_path('../../../config/environment', __FILE__)
class ExampleMigration < Migrations::KatamaMigration
# you can use DateTime.now.to_i
@@db_version = 1234567890
def up
#!/usr/local/bin/perl
$ _=
qq
.CG
T--A
A---T
A----T
C----G
T----A
#!/usr/local/bin/perl
undef$/;$_=<DATA>;y/ODA\n / /ds;@yoda=map{length}split;print chr
oct join('',splice(@yoda,0,3))-111 while@yoda;
__DATA__
00O00O000O00O0000 000O DD000000O0
0DO0000000O0000O00 O00000 00O00000O0O
0000 0O0 O00 O00 00D 0DO
00O0 0O0 00D 000 DO0D00000D
0O00 DOD 000000O00000 000 O00O
#!/bin/bash
# This script fills in some of the gaps on an Engine Yard cluster deploy.
# -Dana
# I could probably use ARGV for this, but whatever.
THIS_ENV=staging
# move into our home directory
cd
------- Apache processes --------
### Processes: 0
### Total private dirty RSS: 0.00 MB
--------- Nginx processes ----------
PID PPID VMSize Private Name
------------------------------------
# a mixin to provide logging and nagios monitoring to cron jobs
module Utils
module BCMCronJob
# set up the log file
# we could also simply use RAILS_DEFAULT_LOGGER
def before_job
log_file_name = "bcm_cron.log"
@log_file ||= File.open(File.join(Rails.root, 'log', log_file_name), 'a')
@dmerrick
dmerrick / autotest.rb
Created July 21, 2010 18:32
Use this to make autotest work with Growl.
# save this file as ~/.autotest
# start autospec with ./script/autospec
# you may need to install the "autotest" and "autotest-rails-pure" gems
# if you have any issues getting this to work (like Growl notifications not appearing),
# take a look at the README found here: http://github.com/svoop/autotest-growl
begin