Skip to content

Instantly share code, notes, and snippets.

View krobertson's full-sized avatar

Ken Robertson krobertson

View GitHub Profile
@krobertson
krobertson / set_environment.rb
Created July 14, 2011 22:18 — forked from nstielau/set_environment.rb
A Knife plugin to set node environment
## Knife plugin to set node environment
# See http://wiki.opscode.com/display/chef/Environments
#
## Install
# Place in .chef/plugins/knife/set_environment.rb
#
## Usage
# Nick-Stielaus-MacBook-Pro:chef-repo nstielau$ knife node set_environment mynode.net my_env
# Looking for mynode.net
# Setting environment to my_env
@krobertson
krobertson / launchd.rb
Created July 2, 2011 15:12 — forked from raggi/launchd.rb
A first stab at a launchd provider for chef
class Chef::Provider::Service::Launchd < Chef::Provider::Service::Simple
LAUNCHCTL_FORMAT = /([\d-]+)\s+([\d-]+)\s+([[:print:]]+)/
def initialize(new_resource, run_context)
raise ArgumentError, "run_context cannot be nil" unless run_context
super
run_context.node
end
HTTP/1.1 200 ...
Server: nginx/0.7.65
Date: Wed, 12 Jan 2011 23:59:05 GMT
Content-Type: text/html
Transfer-Encoding: chunked
Connection: keep-alive
Content-Encoding: gzip
Transfer-Encoding: chunked
Vary: Accept-Encoding
#!/usr/bin/env ruby
require 'jruby/vm'
vms = []
queue = 'background_tasks_LP'
instance_count = 30
Signal.trap('HUP') { vms.map(&:join) }
g++ -DPACKAGE_NAME=\"scribe\" -DPACKAGE_TARNAME=\"scribe\" -DPACKAGE_VERSION=\"1.5.0\" -DPACKAGE_STRING=\"scribe\ 1.5.0\" -DPACKAGE_BUGREPORT=\"\" -DPACKAGE=\"scribe\" -DVERSION=\"1.5.0\" -DHAVE_BOOST= -DHAVE_BOOST_SYSTEM= -DHAVE_BOOST_FILESYSTEM= -I. -I.. -I/usr/local/include -I/usr/local/include/thrift -I/usr/local/include/thrift -I/usr/local/include/thrift/fb303 -I/usr/local/include -I/usr/include -Wall -O3 -MT store.o -MD -MP -MF .deps/store.Tpo -c -o store.o store.cpp
In file included from env_default.h:24,
from common.h:57,
from store.cpp:28:
/usr/local/include/thrift/server/TNonblockingServer.h:33:19: error: event.h: No such file or directory
In file included from env_default.h:24,
from common.h:57,
from store.cpp:28:
/usr/local/include/thrift/server/TNonblockingServer.h:93: error: expected ‘;’ before ‘*’ token
require 'rubygems'
require 'dm-core'
require 'dm-timestamps'
DataMapper.setup(:default, "sqlite3:///#{Dir.pwd}/test.db")
class User
include DataMapper::Resource
property :id, Serial
@krobertson
krobertson / gist:233480
Created November 13, 2009 00:58
Ruby SMTP to XMPP server/gateway
require 'gserver'
require 'rubygems'
require 'xmpp4r'
require 'xmpp4r/roster'
require 'daemons'
JABBER_USER = 'service@domain.com'
JABBER_PASS = 'secret'
EMAIL_DOMAIN = 'domain.com'
/opt/ruby-enterprise-1.8.7-2009.10/lib/ruby/gems/1.8/gems/bluepill-0.0.15/bin/../lib/bluepill/application.rb:136:in `send_to_server': undefined local variable or method `buffer' for #<Bluepill::Application:0x9a7e9b0> (NameError)
from /opt/ruby-enterprise-1.8.7-2009.10/lib/ruby/gems/1.8/gems/bluepill-0.0.15/bin/../lib/bluepill/application.rb:73:in `status'
from /opt/ruby-enterprise-1.8.7-2009.10/lib/ruby/gems/1.8/gems/bluepill-0.0.15/bin/../lib/bluepill/controller.rb:35:in `send'
from /opt/ruby-enterprise-1.8.7-2009.10/lib/ruby/gems/1.8/gems/bluepill-0.0.15/bin/../lib/bluepill/controller.rb:35:in `send_cmd'
from /opt/ruby-enterprise-1.8.7-2009.10/lib/ruby/gems/1.8/gems/bluepill-0.0.15/bin/bluepill:59
from /opt/ree/bin/bluepill:19:in `load'
from /opt/ree/bin/bluepill:19
/opt/ruby-enterprise-1.8.7-2009.10/lib/ruby/gems/1.8/gems/bluepill-0.0.15/bin/../lib/bluepill/application.rb:15:in `initialize': undefined method `+' for nil:NilClass (NoMethodError)
from /opt/ruby-enterprise-1.8.7-2009.10/lib/ruby/gems/1.8/gems/bluepill-0.0.15/bin/../lib/bluepill/controller.rb:34:in `new'
from /opt/ruby-enterprise-1.8.7-2009.10/lib/ruby/gems/1.8/gems/bluepill-0.0.15/bin/../lib/bluepill/controller.rb:34:in `send_cmd'
from /opt/ruby-enterprise-1.8.7-2009.10/lib/ruby/gems/1.8/gems/bluepill-0.0.15/bin/bluepill:59
from /opt/ree/bin/bluepill:19:in `load'
from /opt/ree/bin/bluepill:19
@krobertson
krobertson / fakeldap.rb
Created January 10, 2009 01:34
fakeldap - fake data generator for LDAP
#
# Ugly little script I used when I needed to generate an LDAP DB with 100k sample users
#
require 'rubygems'
require 'faker'
require 'active_ldap'
ActiveLdap::Base.establish_connection(
:host => '10.0.0.8',