Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env ruby
require 'net/http'
require 'uri'
require 'json'
require 'optparse'
opts = {}
option_parser = OptionParser.new do |o|
o.banner = "Usage: #{$0} [-h] [-vq] -H HOST -t TOKEN -n NODE -p PROFILE -i IMPACT"
@paulmooring
paulmooring / thing.go
Created June 13, 2015 04:37
concurrency problem with golang
files, err := ioutil.ReadDir("./plugins/")
if err != nil {
panic(err)
}
var plugin_group sync.WaitGroup
plugin_group.Add(len(files))
for _, f := range files {
fmt.Println("Found: " + f.Name())
@paulmooring
paulmooring / collections_example.rb
Created November 25, 2014 21:16
Example of collections in Ruby
#!/usr/bin/env ruby
require 'pry'
# A bit about working with collections in Ruby
txt01_01 = <<EOT
In Ruby every expression, regardless of length or content returns exactly 1
value. In a simple single line case this behavior is unsuprising and intuative
to new Ruby programmers:
-- rbenv: 2.1.2 - git: master - knife: rs-prod --------------------- /Users/paul/Github/mon-cli --
-- Wed Aug 27 17:23:54 - paul@galactica $ go run sensu-cli.go -H 192.168.112.120 /clients
[{"name":"i-a8409ba7","address":"192.168.112.94","subscriptions":["base","all"],"timestamp":1409185437},{"name":"i-516cb55e","address":"192.168.112.231","subscriptions":["base","graphite-server","all"],"timestamp":1409185423},{"name":"i-48a37d47","address":"192.168.112.120","subscriptions":["base","sensu-server","all"],"timestamp":1409185436}]
null
-- rbenv: 2.1.2 - git: master - knife: rs-prod --------------------- /Users/paul/Github/mon-cli --
-- Wed Aug 27 17:23:59 - paul@galactica $ go run sensu-cli.go -H 192.168.112.120 /info
{"sensu":{"version":"0.12.6"},"rabbitmq":{"keepalives":{"messages":0,"consumers":1},"results":{"messages":0,"consumers":1},"connected":true},"redis":{"connected":true}}
{
"rabbitmq": {
"connected": true,
{
"name": "awstest001",
"chef_environment": "Testing",
"normal": {
"mysql": {
"version": "5.5"
},
"tags": [
]
@paulmooring
paulmooring / thing.md
Created July 1, 2014 22:28
sensu-metric-relay config

The sensu-metric-relay extension starts up, and iniates a tcp connection to graphite, but no data ever gets sent and the queue always stays at 0. Relevant configs are below, the check is from the sensu-community-plugins and sensu-metric-relay is unmodified and pulled from master (at a95718c4c0dd7ecbd472cdec2926ca3496d217bb)

/etc/sensu/conf.d/config_relay.json:

{
  "relay": {
    "graphite": {
      "host": "192.168.112.14",
      "port": 2003
    }
#!/usr/bin/env ruby
require 'optparse'
require 'json'
require 'hipchat-api'
def send_message(message, format, options)
@hipchat_api.rooms_message(
options[:room],
options[:from],
@paulmooring
paulmooring / 0_reuse_code.js
Created February 18, 2014 23:00
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
#!/usr/bin/env ruby
require 'json'
require 'leankitkanban'
require 'trello'
require 'pp'
require 'pry'
def get_json_card(card)
card[:name] = "From Trello" unless card.key? :name
(defn pe_1
"Returns the sum of all numbers below [x] that are multiples of 3 or 5"
[x]
(pe_1_acc x 0))
(defn pe_1_acc [x acc]
(cond
(= x 0) acc
(or (= 0 (rem x 3)) (= 0 (rem x 5))) (pe_1_acc (dec x) (+ acc x))
:else (pe_1_acc (dec x) acc)))