Skip to content

Instantly share code, notes, and snippets.

View ploubser's full-sized avatar

Pieter Loubser ploubser

View GitHub Profile
@ploubser
ploubser / gist:1122494
Created August 3, 2011 12:13
JGrep wildcards
% cat ../ohlol.json |ruby -I ../lib/ jgrep -s data.*.parameters
[
[
{
"time_server": "time.mit.edu"
},
{
"time_server": "time.stanford.edu"
}
]
@ploubser
ploubser / gist:1477502
Created December 14, 2011 17:14
JGrep matchers
require 'jgrep.rb'
a = JGrep::JGrep.new
a.expression = "foo=bar"
puts a.match_value('{"foo":"bar"}')
a.value = {"foo" => "bar"}
puts a.match_expression("foo=bar")
@ploubser
ploubser / host.c
Created May 22, 2012 13:38
C calling Lua
#include <stdio.h>
#include <lua.h>
#include <lauxlib.h>
#include <lualib.h>
int main(void) {
lua_State *L = lua_open();
luaL_openlibs(L);
luaL_loadfile(L, "host.lua");
lua_pcall(L, 0, 0, 0);
@ploubser
ploubser / host.lua
Created May 22, 2012 13:38
Some janky Lua
hostname = os.execute("hostname")
@ploubser
ploubser / gist:2827931
Created May 29, 2012 11:29
Curses generator
module MCollective
class Generator
attr_accessor :container, :iwindow, :dwindow, :owindow, :plugin
def initialize
@plugin = {:actions => [], :metadata => {}}
@container = Curses::Window.new(Curses.lines, Curses.cols, 0, 0)
@iwindow = Curses::Window.new(Curses.lines - 2, Curses.cols / 2, 1,0)
@dwindow = Curses::Window.new(Curses.lines - 2, Curses.cols / 2, 1, Curses.cols / 2)
@owindow = Curses::Window.new(1, Curses.cols, Curses.lines - 1, 0)
@ploubser
ploubser / mco collective_info output
Created June 27, 2012 16:53
Updated Summary plugin
Summary of All Collectives:
mcollective : 10
subdev2 : 7
subdev1 : 3
@ploubser
ploubser / outliers.rb
Created June 28, 2012 16:30
Simple client side function for determining outliers in a set
module MCollective
class Aggregate
class Outliers<Base
def startup_hook
result[:value] = {:high => [], :low =>[]}
result[:type] = :collection
@aggregate_format = "%s : %s" unless @aggregate_format
@data_set = []
@ploubser
ploubser / gist:3077098
Created July 9, 2012 15:14
Illume language prototype
/* Check if foo is present in an array */
/* General language functions */
#import “stdlib”
func main: argv {
list = [‘foo’, ‘bar’, baz’];
return find_value(list, ‘baz’);
}
func find_value: list, value{
@ploubser
ploubser / gist:3297752
Created August 8, 2012 19:13
hpacu output
Smart Array P212 in Slot 1
Bus Interface: PCI
Slot: 1
Serial Number: PACCPID1130064H
Cache Serial Number: PACCQID1140110N
RAID 6 (ADG) Status: Disabled
Controller Status: OK
Chassis Slot:
Hardware Revision: Rev C
Firmware Version: 5.12
class ThreadsafeQueue
require 'thread'
require 'timeout'
def initialize
@queue = []
@mutex = Mutex.new
@cv = ConditionVariable.new
end