Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / 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 / logstash output when log_pusher lacks conf
Created April 13, 2012 04:48
Nutting out AMQP access control with logstash
I, [2012-04-13 00:42:21#21996] INFO -- received: #<Qrack::Transport::Method:0xde81d48 @channel=0, @payload=#<Qrack::Protocol::Connection::Start:0x36673c9f @mechanisms="PLAIN AMQPLAIN", @server_properties={:capabilities=>{}, :copyright=>"Copyright (C) 2007-2012 VMware, Inc.", :information=>"Licensed under the MPL. See http://www.rabbitmq.com/", :platform=>"Erlang/OTP", :product=>"RabbitMQ", :version=>"2.8.1"}, @version_minor=0, @locales="en_US", @version_major=8>>
I, [2012-04-13 00:42:21#21996] INFO -- send: #<Qrack::Transport::Method:0x3efe0ce
9 @channel=0, @payload=#<Qrack::Protocol::Connection::StartOk:0x1901b54e @client_properties={:platform=>"Ruby", :product=>"Bunny", :information=>"http://github.com/ruby-amqp/bunny", :version=>"0.7.8"}, @response={:LOGIN=>"log_pusher", :PASSWORD=>"5adffb33ed2807d12234a6c75be9d022"}, @locale="en_US", @mechanism="AMQPLAIN">>
I, [2012-04-13 00:42:21#21996] INFO -- received: #<Qrack::Transport::Method:0x2ed4a1d3 @channel=0, @payload=#<Qrack::Protocol::Connection::Tune:0x
@garthk
garthk / elasticsearch-init.pp
Created April 12, 2012 23:26
File source fallback style for Puppet modules
class elasticsearch {
# ...
file { "/etc/elasticsearch/elasticsearch.yml":
ensure => present,
source => ["puppet:///files/site-elasticsearch/${fqdn}/elasticsearch.yml",
"puppet:///files/site-elasticsearch/elasticsearch.yml",
"puppet:///modules/elasticsearch/elasticsearch.yml"],
owner => root,
group => root,
}
@garthk
garthk / ubuntu-lucid-node
Created March 30, 2012 04:52 — forked from niallo/ubuntu-lucid-node-zeromq
Puppet class recipe to install Node.JS on Ubuntu 10.04 LTS / Lucid
# Original recipe by niallo: https://gist.github.com/2003430
# Full Puppet module: https://github.com/garthk/puppet-chrislea
#
# Adjustments:
# * Fixed operation on Ubuntu with sources.list.d in /etc/apt
# * Fixed operation on Ubuntu with current add-apt-repository entry filenames
# * Broke out chrislea definition for repository creation
# * Set timeout=3600 for apt-get, which can be slow
# * Avoided apt-get update if it's been done once since add-apt-repository
# * Broke out zeromq
@garthk
garthk / bbb.pp
Created March 26, 2012 03:46
bigbluebutton recipe for Puppet (requires manual fixup: see comments)
class bbb($bbb_hostname = $fqdn, $salt = "d34db33fba5eba11f01dab1e5ca1ab1e") {
exec { "dist upgrade":
refreshonly => true,
command => "/usr/bin/apt-get dist-upgrade",
}
exec { "update and dist upgrade":
refreshonly => true,
command => "/usr/bin/apt-get update",
notify => Exec["dist upgrade"],
}
@garthk
garthk / gist:2202188
Created March 26, 2012 01:49
Error 500 joining BBB demo meeting (attempt #1)
java.lang.NullPointerException
at org.apache.jsp.demo1_jsp.getJoinURL(demo1_jsp.java:199)
at org.apache.jsp.demo1_jsp._jspService(demo1_jsp.java:889)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:377)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
@garthk
garthk / gist:2202097
Created March 26, 2012 01:29
Still can't install bbb-record-core
root@spike-112:/opt# apt-get install bbb-record-core
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following NEW packages will be installed:
bbb-record-core
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 0B/22.6kB of archives.
After this operation, 258kB of additional disk space will be used.
(Reading database ... 88342 files and directories currently installed.)
@garthk
garthk / gist:2202042
Created March 26, 2012 01:13
Can't install bbb-record-core
root@26797-2-1051166:/etc# apt-get -f install
Reading package lists... Done
Building dependency tree
Reading state information... Done
Correcting dependencies... Done
The following packages were automatically installed and are no longer required:
linux-headers-2.6.32-39-generic linux-headers-2.6.32-28 linux-headers-2.6.32-39
linux-headers-2.6.32-28-generic
Use 'apt-get autoremove' to remove them.
The following extra packages will be installed: