Skip to content

Instantly share code, notes, and snippets.

@duggan
duggan / receive.js
Created Mar 8, 2012
Node.js script. Spits out the headers of a request - useful for basic remote request testing
View receive.js
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 Apr 2, 2012
Das Keyboard UK Keyboard Layout for OSX
View das-keyboard-uk-osx.xml
<?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">
View amzn-degraded-instances.py
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
Test a memcache connection
View test-memcache.php
<?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
Mash dictionary words into a selected word to create neologism candidates
View neologism.php
<?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 Jul 4, 2012
Basic distributed filesystem write performance test.
View dfs-test-write.py
#!/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="])
View index.php
<?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 Oct 24, 2012
shlint gemspec (example)
View shlint.gemspec
# -*- 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 Oct 30, 2012
Big Red Button - playing sounds on Windows
View button.py
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:
View exceptions.rb
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