Skip to content

Instantly share code, notes, and snippets.

View mjg123's full-sized avatar
😅

Matthew Gilliard mjg123

😅
View GitHub Profile
@mjg123
mjg123 / timestamper.sh
Created May 9, 2014 13:45
tiny shell script for adding timestamps to lines piped in from stdin
while read f; do
date +"%H:%M:%S " | tr -d '\n';
echo $f;
done
@mjg123
mjg123 / main.go
Last active August 29, 2015 14:07
package main
import (
"github.com/elazarl/goproxy"
"io/ioutil"
"log"
"net/http"
)
func main() {
@mjg123
mjg123 / mc.py
Created December 1, 2014 22:36
classes using a decorator to store methods will be dependent on decorator ordering
import pprint
import six
captured_methods = {}
class MjgClass(object):
@classmethod
def decorated(cls):
global captured_methods
def decorator(f):
@mjg123
mjg123 / gist:cb544f2f6853df8d866c
Last active August 29, 2015 14:22
Diagnosing a gate failure using logstash.openstack.org

Recently we noticed that the "check-tempest-dsvm-multinode-full" job, which is non-voting in nova's check jobs, was failing in a new way.

Some notes about how the failure was diagnosed:

  1. Job is failing
  2. why? find a signature for the failure, eg
File "tempest/api/compute/admin/test_live_migration.py", line 116, in test_live_block_migration"
@mjg123
mjg123 / gist:956051
Created May 4, 2011 21:14
my 13 LOC chat server for node.js
var http = require('http');
var url = require('url');
var messages = ["welcome to nodeChat"];
http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
var query = url.parse(req.url, true).query;
if ( query.message ){
messages.push( query.message );
res.end("thanks");
} else {
@mjg123
mjg123 / SortedRespectDue.java
Created July 10, 2011 19:43
Testing the behaviour of mergesort in Java's core implementation
import java.util.Arrays;
import java.util.Random;
/**
* Created by Matthew Gilliard
* Date: 10/07/11
* Time: 18:22
*/
public class SortedRespectDue {
@mjg123
mjg123 / MergeSort.java
Created July 10, 2011 20:10
Source of mergesort from Java 6
/**
* Src is the source array that starts at index 0
* Dest is the (possibly larger) array destination with a possible offset
* low is the index in dest to start sorting
* high is the end index in dest to end sorting
* off is the offset to generate corresponding low, high in src
*/
private static void mergeSort(Object[] src,
Object[] dest,
@mjg123
mjg123 / SortedRespectDue.java
Created July 10, 2011 19:45
Testing the behaviour of mergesort in Java's core implementation
import java.util.Arrays;
import java.util.Random;
/**
* Created by Matthew Gilliard
* Date: 10/07/11
* Time: 18:22
*/
public class SortedRespectDue {
@mjg123
mjg123 / hello.cljs
Created July 21, 2011 19:43
Hello World in ClojureScript
(ns hello)
(defn ^:export greet [n]
(str "Hello " n))
@mjg123
mjg123 / hello.js
Created July 21, 2011 19:50
hello.cljs compiled
function b(c){throw c;}var f=null;function aa(){return function(c){return c}}function i(c){return function(){return this[c]}}function j(c){return function(){return c}}var k;
function n(c){var a=typeof c;if(a=="object")if(c){if(c instanceof Array)return"array";else if(c instanceof Object)return a;var d=Object.prototype.toString.call(c);if(d=="[object Window]")return"object";if(d=="[object Array]"||typeof c.length=="number"&&typeof c.splice!="undefined"&&typeof c.propertyIsEnumerable!="undefined"&&!c.propertyIsEnumerable("splice"))return"array";if(d=="[object Function]"||typeof c.call!="undefined"&&typeof c.propertyIsEnumerable!="undefined"&&!c.propertyIsEnumerable("call"))return"function"}else return"null";
else if(a=="function"&&typeof c.call=="undefined")return"object";return a}function ba(c){return typeof c=="string"}Math.floor(Math.random()*2147483648).toString(36);var ca={"\000":"\\0","\u0008":"\\b","\u000c":"\\f","\n":"\\n","\r":"\\r","\t":"\\t","\u000b":"\\x0B",'"':'\\"',"\\":"\\\\"},da={"'":"\\'"};
fun