Skip to content

Instantly share code, notes, and snippets.

View ryangraham's full-sized avatar
😝

Ryan Graham ryangraham

😝
View GitHub Profile
@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
@chrismay
chrismay / iostat_to_graphite.rb
Created April 12, 2011 16:37
send Solaris iostats to Graphite
#!/opt/csw/bin/ruby
#
# run with something like iostat -nx 10 | iostat_to_graphite.rb
#
require 'socket'
graphite_host='graphite'
graphite_port=2003
@hodzanassredin
hodzanassredin / prototype-based.py
Created April 9, 2011 19:38
implementation of internal DSL for Prototype-based programming in Python
import copy
# Имплементация прототип ориентированного internal DSL для Python по мотивам Io Language http://habrahabr.ru/blogs/crazydev/28041/
# Implementation of prototype oriented internal DSL for python based on article about Io Language http://habrahabr.ru/blogs/crazydev/28041/
class IoObject(dict):
def __init__(self):
self.clone = copy.copy
def __getattr__(self, attr):
if 'get_slot' in self:
val = self["get_slot"](attr)#может вызвать бесконечность / infinite loop can occur
@timdiggins
timdiggins / chef-roles-to-json-task.rb
Created February 19, 2011 06:53
rake task to convert existing ruby roles to json
# ADD this to Rakefile and run it by issuing rake roles.to_json
ROLE_DIR = File.expand_path(File.join(TOPDIR, "roles"))
namespace :roles do
desc "Convert ruby roles from ruby to json, creating/overwriting json files."
task :to_json do
Dir.glob(File.join(ROLE_DIR, '*.rb')) do |rb_file|
role = Chef::Role.new
role.from_file(rb_file)
json_file = rb_file.sub(/\.rb$/,'.json')
import tornado.httpserver, tornado.ioloop, tornado.options, tornado.web, os.path
from tornado.options import define, options
define("port", default=8888, help="run on the given port", type=int)
class Application(tornado.web.Application):
def __init__(self):
handlers = [
(r"/", HomeHandler),
(r"/upload", UploadHandler)