Skip to content

Instantly share code, notes, and snippets.

@duggan
duggan / receive.js
Created March 8, 2012 19:13
Node.js script. Spits out the headers of a request - useful for basic remote request testing
var http = require('http');
var qs = require('querystring');
/* Host / Port configuration.
Defaults to listening on all interfaces, port 80.
*/
var host = "0.0.0.0";
var port = 80;
http.createServer(function (req, res) {
@duggan
duggan / das-keyboard-uk-osx.xml
Created April 2, 2012 11:34
Das Keyboard UK Keyboard Layout for OSX
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE keyboard SYSTEM "file://localhost/System/Library/DTDs/KeyboardLayout.dtd">
<!-- This goes in /Users/<username>/Library/Keyboard Layouts/daskeyboard.keylayout -->
<!-- Select it by checking the Das Keyboard option in System Preferences -> Languages & Text -> Input Sources -->
<keyboard group="0" id="2" name="Das Keyboard - UK" maxout="1">
<layouts>
<layout first="0" last="0" modifiers="commonModifiers" mapSet="ANSI"/>
</layouts>
<modifierMap id="commonModifiers" defaultIndex="0">
<keyMapSelect mapIndex="0">
@duggan
duggan / amzn-degraded-instances.py
Created April 3, 2012 02:50
Print degraded instances
import sys
from boto.ec2.connection import EC2Connection
from boto.exception import BotoServerError
AMZN_ACCESS_KEY = ""
AMZN_SECRET_KEY = ""
maintenance_instances = []
""" Get EC2 connection """
@duggan
duggan / test-memcache.php
Created May 9, 2012 11:16
Test a memcache connection
<?php
/**
* Some basic connectivity tests for a memcache server.
*
* $host string Memcache server address to connect to
* $port int Memcache server port
* $key string A key for setting a test value
* $var string A test value to be set
*/
@duggan
duggan / neologism.php
Created May 14, 2012 14:23
Mash dictionary words into a selected word to create neologism candidates
<?php
/**
* Neologism
* Mash a selected word into dictionary words,
* sort into a list for perusal. Not terribly memory friendly.
*
* @arg string $word The word to be mashed.
* @arg string $end_part The end part of the word to start the mashing from.
*/
@duggan
duggan / dfs-test-write.py
Created July 4, 2012 16:08
Basic distributed filesystem write performance test.
#!/usr/env python
import uuid
import time
import sys
import getopt
def main():
try:
opts, args = getopt.getopt(sys.argv[1:], "fd:v", ["files=", "directory="])
@duggan
duggan / index.php
Created September 18, 2012 15:24
EC2 Info
<?php
$base = "http://169.254.169.254/latest/";
$metadata = array("instance-id", "hostname", "instance-type", "public-hostname", "security-groups",
"ami-id", "ami-launch-index", "ami-manifest-path", "kernel-id","mac","reservation-id"
);
echo "<style>td{white-space:nowrap;}</style>";
echo "<table>";
foreach ($metadata as $info) {
@duggan
duggan / shlint.gemspec
Created October 24, 2012 22:45
shlint gemspec (example)
# -*- encoding: utf-8 -*-
lib = File.expand_path('../lib/', __FILE__)
$:.unshift lib unless $:.include?(lib)
Gem::Specification.new do |s|
s.name = "shlint"
s.version = "0.1.1"
s.platform = Gem::Platform::RUBY
s.authors = ["Ross Duggan"]
s.email = ["rduggan@engineyard.com"]
@duggan
duggan / button.py
Created October 30, 2012 23:40
Big Red Button - playing sounds on Windows
import sys
import time
import usb
import winsound
"""
Using the MetricFire "Big Red Button" to play buzzer sounds.
Buzzer sounds should be WAV files.
Gonna need to follow the driver installation instructions here:
exceptions = []
tree = {}
ObjectSpace.each_object(Class) do |cls|
next unless cls.ancestors.include? Exception
next if exceptions.include? cls
exceptions << cls
cls.ancestors.delete_if {|e| [Object, Kernel].include? e }.reverse.inject(tree) {|memo,cls| memo[cls] ||= {}}
end
indent = 0