Skip to content

Instantly share code, notes, and snippets.

jordansissel / grokffi.rb
Created Nov 10, 2010
A more ruby-friendly usage of FFI
View grokffi.rb
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 / Running it
Created Nov 16, 2010
Using ruby minstrel to instrument java classes from jruby.
View Running it
% jruby jruby-instrument-printstream.rb
enter Java::JavaIo::PrintStream#println(["Testing"])
exit Java::JavaIo::PrintStream#println(["Testing"])
jordansissel / Makefile
Created Nov 19, 2010
activemq .deb building
View Makefile
.PHONY: default
jordansissel / solrserver-client.feature
Created Nov 20, 2010
cucumber for production tests
View solrserver-client.feature
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 / start_with.rb
Created Nov 23, 2010
backport String#start_with? to ruby 1.8.6
View start_with.rb
if !String.instance_methods.include?("start_with?")
class String
def start_with?(str)
return self[0 .. (str.length-1)] == str
jordansissel / output
Created Nov 25, 2010
mpf parser written in ragel (for ruby, etc)
View output
snack(~/projects/mpf/ragel) % ruby mpf.rb test.mpf
"pants" => [
[0] [
[0] "\"foo\"",
[1] [
[0] {
"fizzle" => [
[0] "33"
jordansissel / Running the server
Created Nov 29, 2010
async_sinatra example using additional eventmachine calls
View Running the server
snack(~) % ruby as.rb
>> Thin web server (v1.2.7 codename No Hup)
>> Maximum connections set to 1024
>> Listening on, CTRL+C to stop
View site.pp
node default {
include truth::enforcer
case $operatingsystem {
"Ubuntu": { include os::ubuntu }
default: { err("Unsupported operatingsystem: '$operatingsystem'") }
exec {
jordansissel / Run it:
Created Dec 9, 2010
Exported resource querying in Ruby Puppet DSL
View Run it:
% 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 / 1. Export stuff.
Created Dec 9, 2010
Exported resource query/collection in ruby puppet dsl
View 1. Export stuff.
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"; }'