Skip to content

Instantly share code, notes, and snippets.

def ask_question(question, opts={})
question = question + "[#{opts[:default]}] " if opts[:default]
STDOUT.print question
a = STDIN.readline.strip
if opts[:default]
a.empty? ? opts[:default] : a
else
a
@rottenbytes
rottenbytes / nagios.coffee
Created October 2, 2012 12:05 — forked from oremj/nagios.coffee
Nagios script for hubot
# Description:
# This script receives pages in the formats
# /usr/bin/curl -d host="$HOSTALIAS$" -d output="$SERVICEOUTPUT$" -d description="$SERVICEDESC$" -d type=service -d state="$SERVICESTATE$" $CONTACTADDRESS1$
# /usr/bin/curl -d host="$HOSTNAME$" -d output="$HOSTOUTPUT$" -d type=host -d state="$HOSTSTATE$" $CONTACTADDRESS1$
#
# Author:
# oremj
irc = require('irc')
@rottenbytes
rottenbytes / pkgng.rb
Created September 5, 2012 08:29
chef+pkgng
require 'chef/mixin/shell_out'
require 'chef/platform'
require 'chef'
include Chef::Mixin::ShellOut
class Chef
class Provider
class Package
class Pkgng < Chef::Provider::Package
@rottenbytes
rottenbytes / pkgng.rb
Created September 4, 2012 11:09
package provider
require 'chef/mixin/command'
require 'chef/log'
require 'chef/file_cache'
require 'chef/platform'
require 'chef'
class Chef
class Provider
class Package
class Pkgng < Chef::Provider::Package
@rottenbytes
rottenbytes / .vim_chef.rb
Created August 29, 2012 11:54
Hook chef to your vim
def test(cb_name)
result=%x[knife cookbook test #{cb_name}]
if $? != 0 then
VIM::message("Testing cookbook '#{cb_name}' failed")
else
VIM::message("Cookbook '#{cb_name}' is OK.")
end
end
@rottenbytes
rottenbytes / pkgng.rb
Created August 28, 2012 20:11
quick & dirty chef pkgng provider
require 'chef/mixin/command'
require 'chef/log'
require 'chef/file_cache'
require 'chef/platform'
require 'chef'
class Chef
class Provider
class Package
class Pkgng < Chef::Provider::Package
@rottenbytes
rottenbytes / redmine_css.js
Created July 3, 2012 10:05
Grease monkey to change CSS in redmine/chiliproject
// ==UserScript==
// @name Redmine color change
// @namespace nico
// @description Change CSS in redmine
// @include https://XXXXX*
// @version 1
// ==/UserScript==
function addCss(cssString) {
@rottenbytes
rottenbytes / caching.diff
Created June 21, 2012 08:35
Add caching to @opscode/chef-rundeck
diff --git a/bin/chef-rundeck b/bin/chef-rundeck
index 5ea22d7..b665ca5 100755
--- a/bin/chef-rundeck
+++ b/bin/chef-rundeck
@@ -46,6 +46,12 @@ class ChefRundeckCLI
:long => "--port PORT",
:description => "The port to run on, default 9980",
:default => 9980
+
+ option :cache_file,
@rottenbytes
rottenbytes / ideal ops.md
Created May 28, 2012 13:53 — forked from bhenerey/ideal ops.md
ideal ops checklist

In a perfect world, where things are done well, not just quickly, I would expect to find the following when joining the company:

Documentation

  • Accurate / up-to-date systems architecture diagram

  • Accurate / up-to-date network diagram

  • Out-of-hours support plan

  • Incident management plan

#
# Cookbook Name:: haproxy
# Recipe:: default
# Author:: Joe Williams <[email protected]>
package "haproxy" do
action :install
end
haproxy_templates = [ "global", "defaults", "frontend", "SOMEBACKEND" ]