Skip to content

Instantly share code, notes, and snippets.

@mojodna
mojodna / caveatPatchor.js
Created October 14, 2011 23:14
caveatPatchor.js with html5 audio support
var HTML5Audio = true;
if (HTML5Audio) {
Campfire.HTML5Audio = Class.create({
initialize: function(chat) {
this.chat = chat;
var messages = this.chat.transcript.messages;
for(var i = 0; i < messages.length; i++) {
this.detectAudio(messages[i], false);
}
@mojodna
mojodna / gist:1634116
Created January 18, 2012 17:09
Implementation of pending for nodeunit
var pending = function(test, fn) {
var assert = require('assert');
assert.done = function() {
test.done();
};
var failed = false;
try {
fn(assert);
} catch (e) {
/*
* Copyright (c) 2011 Justin Tulloss
* Copyright (c) 2010 Justin Tulloss
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
@mojodna
mojodna / gist:2473893
Created April 23, 2012 21:10
Backup GitHub issues
"use strict";
var fs = require("fs"),
https = require("https"),
url = require("url"),
zlib = require("zlib");
/**
* Process HTTP responses. Handle compressed streams and convert to objects as
* appropriate.
@mojodna
mojodna / index.html
Created June 25, 2012 22:23
D3 + ModestMaps
<!DOCTYPE html>
<html>
<head>
<style type="text/css">
#map {
width: 1000px;
height: 600px;
}
path {
@mojodna
mojodna / index.html
Created September 7, 2012 01:59
USGS Sparklines
<!DOCTYPE html>
<html>
<head>
<title>Water</title>
<style type="text/css">
.sparkline path.line {
fill: none;
stroke: #999;
}
@mojodna
mojodna / CBR.json
Created September 12, 2012 06:48
South Fork American @ Chili Bar Dam
7640,PST,'FLOW, RIVER DISCHARGE (cfs)'
20111231,2300,624
20111231,2315,646
20111231,2330,708
20111231,2345,668
20120101,0000,547
20120101,0015,479
20120101,0030,391
20120101,0045,304
20120101,0100,291
@mojodna
mojodna / workers.js
Created March 8, 2013 22:11
Concurrent workers.
"use strict";
var d3 = require("d3");
var WORKERS = 5;
var worker = function(complete) {
var doWork = function() {
return done();
};
@mojodna
mojodna / NOTES.md
Last active May 20, 2019 09:23
libvirt LXC container w/ bridged networking (and 2GB RAM)

https://wiki.ubuntu.com/SergeHallyn_libvirtlxc

apt-get install -y libvirt-bin lxc
lxc-create -t ubuntu -n o1
wget http://people.canonical.com/~serge/o1.xml
virsh -c lxc:// define o1.xml
virsh -c lxc:// start o1
virsh -c lxc:// console o1
@mojodna
mojodna / gist:5282595
Last active December 15, 2015 15:29
EC2 metadata
# Get the EC2 region from an instance, because ec2metadata only includes the availability zone (which is close, but not close enough).
REGION=$(curl http://169.254.169.254/latest/dynamic/instance-identity/document|grep region|awk -F\" '{print $4}')
# extended ec2metadata, including tags (requires an IAM role with ec2:DescribeTags)
list_instances -r $REGION -H T:Name,ID,Hostname,State -f "instance-id=$(ec2metadata --instance-id)"
export HOST=$(list_instances -r $REGION -H T:Name,ID,Hostname,State -f "instance-id=$(ec2metadata --instance-id)" | grep running | awk '{print $1}')