Skip to content

Instantly share code, notes, and snippets.

@garthk
garthk / gist:2469318
Created April 23, 2012 07:17
apt-get install rabbitmq-server failing on lucid32
err: /Stage[main]/Rabbitmq::Server/Package[rabbitmq-server]/ensure: change from purged to present failed: Execution of '/usr/bin/apt-get -q -y -o DPkg::Options::=--force-confold install rabbitmq-server' returned 100: Reading package lists...
Building dependency tree...
Reading state information...
The following extra packages will be installed:
erlang-asn1 erlang-base erlang-corba erlang-crypto erlang-docbuilder
erlang-edoc erlang-eunit erlang-ic erlang-inets erlang-inviso erlang-mnesia
erlang-nox erlang-odbc erlang-os-mon erlang-parsetools erlang-percept
erlang-public-key erlang-runtime-tools erlang-snmp erlang-ssh erlang-ssl
erlang-syntax-tools erlang-tools erlang-webtool erlang-xmerl libltdl7
libsctp1 lksctp-tools odbcinst odbcinst1debian1 unixodbc
@garthk
garthk / dumpsqlite3tocsv.py
Created May 1, 2012 01:07
Unicode-safe Python script to dump sqlite3 tables to CSV for Trac data extraction
#!/usr/bin/env python
"""
Script to open a sqlite3 database and dump all user tables to CSV files.
Tested in Unicode-rich environment.
Usage:
dumpsqlite3tocsv foo.db
"""
import sqlite3, csv, codecs, cStringIO, os, os.path
@garthk
garthk / CreateRoutedEventArgs.cs
Created May 16, 2012 08:18
Create a RoutedEventArgs subclass (e.g. CanExecuteRoutedEventArgs) for unit testing purposes.
protected static T CreateRoutedEventArgs<T>() {
var fakeCommand = Substitute.For<ICommand>();
var nonPublicInstance = BindingFlags.NonPublic | BindingFlags.Instance;
var ev = (RoutedEvent) Activator.CreateInstance(
type: typeof(RoutedEvent),
bindingAttr: nonPublicInstance,
binder: null,
args: new object[4] {null, null, null, null },
culture: null);
var args = (T) Activator.CreateInstance(
@garthk
garthk / init.pp
Created May 29, 2012 00:55
err: Could not retrieve catalog from remote server: Error 400 on SERVER: Could not find parent resource type 'mongodb::package::params' of type hostclass in production at /etc/puppet/modules/mongodb/manifests/package.pp:1 on node X
# /etc/puppet/modules/mongodb/manifests/init.pp
class mongodb {
}
@garthk
garthk / package.pp
Created May 30, 2012 00:38
Puppet class to pull in a package. Ubuntu-friendly, but non-toxic to other UNIX.
class NAMESPACE::package (
$package = $NAMESPACE::package::params::package,
$repository = $NAMESPACE::package::params::repository,
$repokey = $NAMESPACE::package::params::repokey,
$reponame = $NAMESPACE::package::params::reponame,
$keyserver = $NAMESPACE::package::params::keyserver
) inherits NAMESPACE::package::params {
package { $package:
ensure => installed,
}
@garthk
garthk / node-yes-simplistic.js
Created August 2, 2012 04:38
Node.js does not detect process.stdout pipe closing
// this terminates: yes | head
// this hangs: node node-yes-simple.js | head
// per mhart, this is entirely expected
while(true) {
process.stdout.write('{"yes": "yes"}\n');
}
@garthk
garthk / bouncy-muxdemux-ouch.js
Created August 4, 2012 02:02
Using bouncy and mux-demux to make a proxy server
var http = require('http'),
net = require('net'),
bouncy = require('bouncy'),
MuxDemux = require('mux-demux');
var mux_server_port = 8192;
var trampoline_port = 8193;
var target_server_port = 8194;
var mux;
@garthk
garthk / init.pp
Created September 7, 2012 00:09
Could not evaluate: undefined method `alias' for #<Nagios::Base::Hostextinfo:0x7fe2d61693b8>
class nagios {
$targets = '/etc/nagios3/puppets.d'
}
@garthk
garthk / nsclient-try2.ini
Created September 7, 2012 07:10
NSClient++ configuration information for review
# Added logging detail in attempt to debug problem, to no avail.
; A list of modules.
[/modules]
CheckDisk=1
CheckSystem=1
CheckTaskSched=1
NSClientServer=0
NRPEServer=1
@garthk
garthk / puppetlabs.pp
Created September 15, 2012 03:51
Use Puppet to ensure Ubuntu can get the latest Puppet
class puppetlabs {
# Install Puppet repository and call apt-get update
case $operatingsystem {
ubuntu: {
$key = "4BD6EC30"
exec { 'apt-key puppetlabs':
path => "/bin:/usr/bin",
unless => "apt-key list | grep '${key}' | grep -v expired",
command => "apt-key adv --keyserver keyserver.ubuntu.com --recv-keys ${key}",
}