Skip to content

Instantly share code, notes, and snippets.

@jordansissel
jordansissel / grokffi.rb
Created November 10, 2010 09:02
A more ruby-friendly usage of FFI
require "rubygems"
require "ffi"
# class for grok_t
# Attributes with '__' prefixes are not for your consumption; they
# are internal to libgrok.
class Grok < FFI::Struct
# Use FFI to hook libgrok, expose so Grok class can use it.
module CGrok
extend FFI::Library
@jordansissel
jordansissel / Running it
Created November 16, 2010 01:42
Using ruby minstrel to instrument java classes from jruby.
% jruby jruby-instrument-printstream.rb
enter Java::JavaIo::PrintStream#println(["Testing"])
Testing
exit Java::JavaIo::PrintStream#println(["Testing"])
@jordansissel
jordansissel / Makefile
Created November 19, 2010 22:58
activemq .deb building
VERSION=5.4.1
DOWNLOAD=http://apache.cs.utah.edu/activemq/apache-activemq/$(VERSION)/apache-activemq-$(VERSION)-bin.tar.gz
NAME=apache-activemq
TARBALL=$(NAME)-$(VERSION)-bin.tar.gz
BUILDDEPS=
RUNDEPS=java-runtime
#CFLAGS=-g
.PHONY: default
@jordansissel
jordansissel / solrserver-client.feature
Created November 20, 2010 07:37
cucumber for production tests
Feature: solrserver remote health
In order to remotely ensure a healthy solrserver
As a client talking to the solrserver
I want to ensure solrserver is responsive
Scenario: Check the status of solrserver
Given a dns name of "solr"
And requests timeout after 2 seconds
When I fetch "http://solr:8983/solr/admin/cores?action=status" for each dns entry
Then there should be no timeouts
@jordansissel
jordansissel / start_with.rb
Created November 23, 2010 21:28
backport String#start_with? to ruby 1.8.6
if !String.instance_methods.include?("start_with?")
class String
def start_with?(str)
return self[0 .. (str.length-1)] == str
end
end
end
@jordansissel
jordansissel / output
Created November 25, 2010 12:41
mpf parser written in ragel (for ruby, etc)
snack(~/projects/mpf/ragel) % ruby mpf.rb test.mpf
{
"pants" => [
[0] [
[0] "\"foo\"",
[1] [
[0] {
"fizzle" => [
[0] "33"
]
@jordansissel
jordansissel / Running the server
Created November 29, 2010 22:09
async_sinatra example using additional eventmachine calls
snack(~) % ruby as.rb
>> Thin web server (v1.2.7 codename No Hup)
>> Maximum connections set to 1024
>> Listening on 0.0.0.0:8080, CTRL+C to stop
@jordansissel
jordansissel / site.pp
Created December 2, 2010 09:39
My site.pp
node default {
tag("deployment::$deployment")
include truth::enforcer
case $operatingsystem {
"Ubuntu": { include os::ubuntu }
default: { err("Unsupported operatingsystem: '$operatingsystem'") }
}
exec {
@jordansissel
jordansissel / Run it:
Created December 9, 2010 21:13
Exported resource querying in Ruby Puppet DSL
% puppet apply --storeconfig --dblocation /tmp/puppet.sqlite testpuppet.rb
#<Puppet::Rails::Resource id: 13, title: "/tmp/x", restype: "File", host_id: 1, source_file_id: 1, exported: true, line: 1, updated_at: "2010-12-09 13:13:03", created_at: "2010-12-09 13:13:03">
@jordansissel
jordansissel / 1. Export stuff.
Created December 9, 2010 21:56
Exported resource query/collection in ruby puppet dsl
FACTER_fqdn=host1 puppet --certname host1 --node_name fqdn --storeconfigs --dblocation /tmp/puppet.sqlite -e '@@nagios_hostgroup { "mygroup": notes => "Hello"; }'
FACTER_fqdn=host2 puppet --certname host2 --node_name fqdn --storeconfigs --dblocation /tmp/puppet.sqlite -e '@@nagios_hostgroup { "mygroup": notes => "Hello"; }'