Skip to content

Instantly share code, notes, and snippets.

View trobrock's full-sized avatar

Trae Robrock trobrock

View GitHub Profile
@trobrock
trobrock / goliath.rb
Created November 9, 2012 04:42
System calls with goliath
require 'goliath'
module EventMachine
module Synchrony
# Fiber-aware EM.system
#
def self.system cmd, *args
fiber = Fiber.current
EM.system(cmd, *args){ |out, status| fiber.resume( [out, status] ) }
Fiber.yield
diff --git a/.gitignore b/.gitignore
index fc5b76d..702ef6c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -2,3 +2,4 @@
.cache
.kitchen
bin
+*.sw*
diff --git a/attributes/source.rb b/attributes/source.rb
include_recipe "chef_handler"
# Mail handler
chef_gem "chef-handler-mail"
chef_handler "MailHandler" do
source 'chef/handler/mail'
arguments :to_address => "root"
action :nothing
end.run_action(:enable)
alfredapp://customsearch/Search%20opscode%20community%20for/cook/ascii/url=http://community.opscode.com/search?query={query}&scope=home
[2013-02-15T19:46:05+00:00] DEBUG: Sending HTTP Request via GET to ec2-54-234-210-155.compute-1.amazonaws.com:4000/nodes/ip-10-151-63-76.ec2.internal
[2013-02-15T19:46:05+00:00] DEBUG: ---- HTTP Status and Header Data: ----
[2013-02-15T19:46:05+00:00] DEBUG: HTTP 1.1 200 OK
[2013-02-15T19:46:05+00:00] DEBUG: content-type: application/json; charset=utf-8
[2013-02-15T19:46:05+00:00] DEBUG: connection: close
[2013-02-15T19:46:05+00:00] DEBUG: server: thin 1.5.0 codename Knife
[2013-02-15T19:46:05+00:00] DEBUG: ---- End HTTP Status/Header Data ----
[2013-02-15T19:46:05+00:00] DEBUG: Re-raising exception: NoMethodError - undefined method `reset_defaults_and_overrides' for #<Hash:0x2ac09c0>
/usr/lib/ruby/gems/1.8/gems/chef-10.20.0/bin/../lib/chef/client.rb:251:in `build_node'
/usr/lib/ruby/gems/1.8/gems/chef-10.20.0/bin/../lib/chef/client.rb:412:in `do_run'
@trobrock
trobrock / cpu.sh
Last active December 14, 2015 04:59
#!/bin/zsh
cpu=$(top -l 1 | awk '/CPU usage/{ print $3 }')
percent=$(echo $cpu | awk '{ print $1+0 }' | xargs -I'{}' ruby -e "print {}.to_i")
color="default"
if [ "$percent" -gt 90 ]; then
color="red"
elif [ "$percent" -gt 75 ]; then
color="yellow"
@trobrock
trobrock / bundler_clean_env.rb
Created March 2, 2013 04:44
Gem path problems with bundler clean env, notice the executable dir in `gem env` and that it does not point to ree
# Run from rbenv 1.9.3-p392
require 'open3'
Bundler.with_clean_env do
stdin, stdout, stderr, wait_thr = Open3.popen3 <<-SH
eval "$(rbenv init -)" ;
rbenv shell ree-1.8.7-2012.02 ;
gem env
SH
@trobrock
trobrock / cap.txt
Created March 13, 2013 20:27
Unable to bundle in jruby
jruby -Sbundle install --gemfile /var/apps/application/releases/20130313202409/Gemfile --path /var/apps/application/shared/bundle --deployment --quiet --without development test
** [out :: 127.0.0.1] Unfortunately, a fatal error has occurred. Please see the Bundler
** [out :: 127.0.0.1] troubleshooting documentation at http://bit.ly/bundler-issues. Thanks!
** [out :: 127.0.0.1] /opt/jruby-1.5.6/lib/ruby/gems/1.8/gems/bundler-1.3.3/lib/bundler/cli.rb:867:in `without_groups_message': undefined method `empty?' for :test:Symbol (NoMethodError)
** [out :: 127.0.0.1] from /opt/jruby-1.5.6/lib/ruby/gems/1.8/gems/bundler-1.3.3/lib/bundler/cli.rb:866:in `reject'
** [out :: 127.0.0.1] from /opt/jruby-1.5.6/lib/ruby/gems/1.8/gems/bundler-1.3.3/lib/bundler/cli.rb:866:in `without_groups_message'
** [out :: 127.0.0.1] from /opt/jruby-1.5.6/lib/ruby/gems/1.8/gems/bundler-1.3.3/lib/bundler/cli.rb:254:in `install'
** [out :: 127.0.0.1] from /opt/jruby-1.5.6/lib/ruby/gems/1.8/gems/bundler-1.3.3/lib/bundler/vendor/thor/t
@trobrock
trobrock / recipe.rb
Last active December 18, 2015 03:08
include_recipe "aws"
include_recipe "ec2-consistent-snapshot"
ruby_block "get attached ebs volumes" do
block do
# volumes = Opscode::Aws::Ec2.ec2.describe_volumes.detect{ |v| v[:aws_instance_id] == instance_id }
run_context["ebs_volumes"] = ["vol-abcd123"]
end
end
@trobrock
trobrock / notify.rb
Created June 20, 2013 17:06
weechat ruby notifications, thanks @joelteon
require 'ruby_gntp'
Weechat.register "notify", "otters", "0.2", "GPL", "notify: A real time notification system for weechat", "", ""
Settings = {
:show_hilights => "on",
:show_priv_msg => "on"
}
def notify_show data, buffer, empty, tagsn, isdisp, ishilight, prefix, msg