Skip to content

Instantly share code, notes, and snippets.

View oogali's full-sized avatar

Omachonu Ogali oogali

  • Ordinary Stack
  • Princeton, NJ
  • 04:01 (UTC -04:00)
View GitHub Profile
@oogali
oogali / voltron-irb.txt
Created October 20, 2012 19:37
new and improved voltron, with classes!
marvin:voltron oogali$ irb -rapp
>> vm = Voltron::VirtualMachine.new 'oo-test', 1, 1024
=> #<Voltron::VirtualMachine:0x1026033c8 @nics=[], @memory=1024, @actions={:on_poweroff=>:destroy, :on_reboot=>:restart, :on_crash=>:restart}, @disks=[], @name="oo-test", @clock_offset="utc", @emulator="/usr/libexec/qemu-kvm", @cpu={:set=>[], :count=>1}, @uuid="3352397d-52a8-4377-8af2-43027592d34b", @features=["acpi", "apic", "pae"]>
>> vm.disks << Voltron::Disk.new('oo-test_disk0', 10240, 'vg_nutmeg_vms')
=> [#<Voltron::Disk:0x1025fa480 @size=10240, @name="oo-test_disk0", @device="disk", @uuid="060aba12-d8c2-4452-8699-a01f1fe37386", @volume_group="vg_nutmeg_vms">]
>> vm.nics << Voltron::NetworkInterface.new
=> [#<Voltron::NetworkInterface:0x1025f4d00 @vlan="default", @mac="54:52:00:9c:44:bd", @model="e1000">]
@oogali
oogali / centos-advisory-parser.pl
Created October 29, 2012 14:30
CentOS Advisory Parser (from September 2009, never got a chance to put this into production)
#!/usr/bin/perl
$rc = 0;
while(<STDIN>) {
chomp;
## Grab severity, CentOS version, architecture, and package name
##
## Sometimes, whitespace is missing between package name and "Update"
@oogali
oogali / cidrdns.c
Created October 29, 2012 14:33
Do reverse DNS on a CIDR block (circa May 2006)
/*
* Copyright (c) 2006 Omachonu Ogali <[email protected]>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
@oogali
oogali / test-after-sparkup.html
Last active December 10, 2015 09:58
vim + sparkup
$ cat test.html
<html>
<style type="text/css"></style>
<body>
<div id="header"></div>
<div id="content"></div>
<div id="footer"></div>
</body>
</html>
Message from VCC-compiler:
Expected CSTR got 'server.ip'
(program line 300), at
(/etc/varnish/routing/02-xforwardedfor.vcl Line 3 Pos 22)
if (client.ip != server.ip) {
---------------------#########---
Running VCC-compiler failed, exit 1VCL compilation failed
Command failed with error code 106
@oogali
oogali / rack-middleware-ip.rb
Created January 10, 2013 03:08
Really? I still have to do this in 2013?
require 'ipaddr'
module Monitoring
module Middleware
class Ip
def initialize(app, options = {})
trusted = options[:trusted] || [ '127.0.0.1/32' ]
@trusted = trusted.map { |network| IPAddr.new network }
@app = app
end
@oogali
oogali / daterange.rb
Created January 12, 2013 22:13
Display a human-readable range of date/times using the least amount of text possible.
require 'active_support/all'
def is_midnight?(time)
time == time.beginning_of_day
end
def datetime_range(starting, ending, seconds = false)
if (starting > ending)
starting, ending = ending, starting
end
grammar MozillaCKA
rule document
( comment / newline / cvsid / beginning / root / certificates / trusts )*
end
# LOL!
rule cvsid
'CVS_ID' text newline
end
@oogali
oogali / ssh-agent.sh
Created March 9, 2013 07:36
SSH agent snippet for your .bash_profile -- stop launching ssh-agent every time you log in.
# append this to your .bash_profile
start_agent() { eval `ssh-agent` >/dev/null; echo "${SSH_AGENT_PID}:${SSH_AUTH_SOCK}" > "${HOME}/.ssh/agent"; }
use_existing_agent() { export SSH_AGENT_PID=`head -1 ${HOME}/.ssh/agent | awk -F ':' '{ print $1 }'`; export SSH_AUTH_SOCK=`head -1 ${HOME}/.ssh/agent | awk -F ':' '{ print $2 }'`; }
if [ ! -f "${HOME}/.ssh/agent" ]; then
start_agent
else
use_existing_agent
if [ -z "${SSH_AUTH_SOCK}" ] || [ ! -S "${SSH_AUTH_SOCK}" ]; then
start_agent
@oogali
oogali / Gemfile-puma.diff
Created March 15, 2013 15:46
Switching from Thin to Puma...
diff --git a/Gemfile b/Gemfile
index ae735c6..0c19644 100644
--- a/Gemfile
+++ b/Gemfile
@@ -2,10 +2,11 @@ source :rubygems
gem 'SystemTimer', :platforms => :ruby_18
gem 'eventmachine'
gem 'thin'
+gem 'puma', :git => 'git://github.com/puma/puma.git'
gem 'hiredis'