Skip to content

Instantly share code, notes, and snippets.

View trobrock's full-sized avatar

Trae Robrock trobrock

View GitHub Profile
@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"
[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'
alfredapp://customsearch/Search%20opscode%20community%20for/cook/ascii/url=http://community.opscode.com/search?query={query}&scope=home
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)
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
@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
@trobrock
trobrock / create_post.rb
Created November 8, 2012 19:27
Helper for creating posts with jekyll `./create_post.rb "some title"`
#!/usr/bin/env ruby
require 'stringex'
title = ARGV.first
date = "#{Time.now.year}-#{Time.now.month}-#{Time.now.day}"
file_name = "#{date}-#{title.to_url}.md"
File.open(File.join("_posts", file_name), 'w') do |f|
f.puts "---"
f.puts "layout: post"
#!/usr/bin/env ruby
wanting = ARGV[0]
role = wanting.scan(/[a-z]+/).first.to_sym
number = wanting.scan(/\d+/).first.to_i
ROLES = {}
def role(role, *hosts)
hosts.pop if hosts.last.is_a?(Hash)
ROLES[role] = hosts
#!/bin/sh
git checkout master
remote=$1
branches=$(git branch --remote --merged master | grep $remote/ | grep -v /master)
for branch in $branches
do
branch=$(echo $branch | cut -d'/' -f2)
git push $remote :$branch
@trobrock
trobrock / gist:3702453
Created September 11, 2012 22:04
jruby-openssl Bundler issues
[release@thrift1 20120911215203]$ jruby -v
jruby 1.5.6 (ruby 1.8.7 patchlevel 249) (2010-12-03 9cf97c3) (OpenJDK 64-Bit Server VM 1.6.0_24) [amd64-java]
[release@thrift1 20120911215203]$ jruby -Sgem env
RubyGems Environment:
- RUBYGEMS VERSION: 1.3.6
- RUBY VERSION: 1.8.7 (2010-12-03 patchlevel 249) [java]
- INSTALLATION DIRECTORY: /opt/jruby-1.5.6/lib/ruby/gems/1.8
- RUBY EXECUTABLE: /opt/jruby-1.5.6/bin/jruby
- EXECUTABLE DIRECTORY: /opt/jruby-1.5.6/bin
- RUBYGEMS PLATFORMS: