Skip to content

Instantly share code, notes, and snippets.

@ktheory
ktheory / gist:1596165
Created January 11, 2012 18:51
chef log
[Wed, 11 Jan 2012 17:02:10 +0000] INFO: Processing service[nagios-nrpe-server] action enable (nagios::client line 63)
[Wed, 11 Jan 2012 17:02:10 +0000] INFO: Processing nagios_nrpecheck[check_load] action add (nagios::client line 69)
[Wed, 11 Jan 2012 17:02:10 +0000] INFO: Adding check_load to /etc/nagios/nrpe.d/
[Wed, 11 Jan 2012 17:02:10 +0000] INFO: Processing template[/etc/nagios/nrpe.d/check_load.cfg] action create (/var/chef/cache/cookbooks/nagios/providers/nrpecheck.rb line 23)
...
[Wed, 11 Jan 2012 17:02:10 +0000] INFO: template[/etc/nagios/nrpe.d/check_load.cfg] sending restart action to service[nagios-nrpe-server] (delayed)
[Wed, 11 Jan 2012 17:02:10 +0000] ERROR: Running exception handlers
@ktheory
ktheory / check_aws_status.rb
Created January 13, 2012 05:11
Nagios plugin to check AWS Status RSS feeds
#!/usr/bin/env ruby
require 'rubygems'
require 'nokogiri'
require 'net/http'
# check_aws_status.rb
# A nagios plugin for fetching RSS feeds from http://status.aws.amazon.com.
# Source: https://gist.github.com/1604786
# Written by Aaron Suggs: https://github.com/ktheory
@ktheory
ktheory / fib.rb
Created January 31, 2012 16:52
Ruby benchmarking
#!/usr/bin/env ruby
def slow_fib(n)
case n
when 0, 1
1
else
slow_fib(n-1) + slow_fib(n-2)
end
end
@ktheory
ktheory / git_io.gemspec
Last active March 15, 2016 14:25
A ruby helper for making git.io short urls
Gem::Specification.new do |s|
s.name = 'git_io'
s.version = '1.0.0'
s.platform = Gem::Platform::RUBY
s.author = 'Aaron Suggs'
s.email = '[email protected]'
s.summary = 'Shorten urls with git.io'
s.description = 'GitIo.shorten(url)'
s.homepage = 'https://gist.github.com/1762136'
@ktheory
ktheory / shit_ror_devs_say.txt
Created February 13, 2012 15:22
Shit Ruby on Rails Developers Say
Did you upgrade to rails 3 yet?
I made a rake task for that.
1.8.7, or 1.9.3?
Did you know there's a rake task for that?
Did you upgrade to rails 3.1 yet?
Did you see my pull request?
Did you upgrade to rails 3.2 yet?
I commented on your pull request.
You need to run bundle install first
rb-env or rvm?
@ktheory
ktheory / enumerable_pluck.rb
Created February 15, 2012 22:54
An Enumerable#pluck method for ruby
module Enumerable
def pluck(key)
map {|obj| obj[key] }
end
end
@ktheory
ktheory / query_trace.rb
Created February 29, 2012 16:58 — forked from belt/query_trace.rb
QueryTrace... ported to rails3
require 'term/ansicolor'
# yeilds a stacktrace for each SQL query
# put this file in config/initializers
class QueryTrace < ActiveSupport::LogSubscriber
include Term::ANSIColor
attr_accessor :trace_queries
def sql(event) #:nodoc:
return unless QueryTrace.enabled? && logger.debug? && Rails.env.development?
Gem::Specification.new do |s|
s.name = 'bang'
s.version = '0.1.0'
s.platform = Gem::Platform::RUBY
s.author = 'Jeff Kreeftmeijer'
s.email = '[email protected]'
s.summary = 'Bang!'
s.description = 'Bangs existing model methods'
s.files = ['bang.rb']
@ktheory
ktheory / 0001-Whitespace-tabs-to-spaces.patch
Created May 9, 2012 19:56
Patch to unicorn example init script: better upgrade task
From 130b610b4e67bcad522a268f1d3f221e8d12ebb0 Mon Sep 17 00:00:00 2001
From: Aaron Suggs <[email protected]>
Date: Fri, 6 Apr 2012 18:35:38 -0400
Subject: [PATCH 1/2] Whitespace: tabs to spaces
---
examples/init.sh | 90 +++++++++++++++++++++++++++---------------------------
1 file changed, 45 insertions(+), 45 deletions(-)
diff --git a/examples/init.sh b/examples/init.sh
@ktheory
ktheory / 0001-Whitespace-tabs-to-spaces.patch
Created June 25, 2012 13:36
Patch to unicorn example init script: better upgrade task
From 233f504a39aca6e8b2d9332ef324b4c5cc397eca Mon Sep 17 00:00:00 2001
From: Aaron Suggs <[email protected]>
Date: Fri, 6 Apr 2012 18:35:38 -0400
Subject: [PATCH 1/2] Whitespace: tabs to spaces
---
examples/init.sh | 90 +++++++++++++++++++++++++++---------------------------
1 files changed, 45 insertions(+), 45 deletions(-)
diff --git a/examples/init.sh b/examples/init.sh