This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/ruby | |
require 'ostruct' | |
require 'rubygems' | |
require 'sequel' | |
DB = Sequel.sqlite('syslogdb') | |
DB.create_table :syslogs do | |
primary_key :id | |
column :time, :timestamp |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/ruby | |
require 'ostruct' | |
syslog = '/var/log/syslog' | |
lines = File.read(syslog).split "\n" | |
rows = lines.map do |line| | |
fields = line.split(' ', 6) | |
o = OpenStruct.new |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'eventmachine' | |
module Socky | |
module Policy | |
DEBUG = true | |
HOST = 'localhost' | |
PORT = 843 | |
EOF = "\r\000" | |
REQUEST = "<policy-file-request/>\000" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
EventMachine::run do | |
# Policy Socket Server | |
EventMachine::start_server( Socky::HOST, | |
Socky::Policy::PORT, | |
Socky::Policy::Server ) | |
# XML Socket Server | |
EventMachine::start_server( Socky::HOST, | |
Socky::XmlSocket::PORT, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'rubygems' | |
require 'eventmachine' | |
@config = { | |
:host => "127.0.0.1", | |
:port => 9666 | |
} | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# bin/console.rb | |
# a nice little ruby console for your Sinatra app | |
ENV["RACK_ENV"] ||= ( ARGV[0] || 'development' ) | |
this_file = File.expand_path( __FILE__ ) | |
app_file = File.expand_path( File.join( File.dirname( __FILE__), '../app' )) | |
cmd = "irb -r #{ this_file } -r irb/completion --simple-prompt" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'activerecord' | |
module Foo | |
def foo | |
puts "foo" | |
end | |
end | |
ActiveRecord::Validations::ClassMethods.send(:include, Foo) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'active_support' | |
require 'active_record' | |
# punch the duck | |
# Module initialisation and plug-in code inspired by will_paginate... | |
module MoneyHandler | |
module Validations | |
module ClassMethods |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/ruby | |
require 'rubygems' | |
require 'thor' | |
require 'chef' | |
require 'chef/node' | |
require 'chef/rest' | |
Chef::Config.from_file("/etc/chef/server.rb") | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
munin_nodes = Chef::Node.list.map do |name| | |
Chef::Node.load(name) | |
end.select do |node| | |
node.recipe_list.include?( "munin-node" ) | |
end | |
munin_node_list = {} | |
munin_nodes.each do |node| | |
munin_node_list[node.attribute[:fqdn]] = node.attribute[:ipaddress] |