Skip to content

Instantly share code, notes, and snippets.

@jugglinmike
jugglinmike / nanoc-filter-concat.rb
Last active January 3, 2016 02:09
Concat filter for nanoc
module Nanoc::Filters
require 'pathname'
class Concat < Nanoc::Filter
identifier :concat
def item_pathname(item)
Pathname.new(File.join("content", item[:content_filename]))
@jugglinmike
jugglinmike / wait-dont-reap.py
Last active December 30, 2015 10:09
A factory function for safely waiting for (and interacting with) zombie processes.
from contextlib import contextmanager
@contextmanager
def zombie(process):
proc_file_name = '/proc/' + str(process.pid) + '/stat'
while True:
with open(proc_file_name, 'r') as proc_file:
if proc_file.readline().split(' ')[2] == 'Z':
yield process
break
@jugglinmike
jugglinmike / log-factory.js
Last active December 28, 2015 20:09
Factory for Logging Functions
var LogFactory = console.log.bind(console).bind.bind(console.log, console);
var log8 = LogFactory(8);
log8(); // 8
@jugglinmike
jugglinmike / bad-feature.patch
Created November 3, 2013 19:07
A bad Mocha feature :/
diff --git a/test/lib/mocha.js b/test/lib/mocha.js
index dee24d6..2b718bd 100644
--- a/test/lib/mocha.js
+++ b/test/lib/mocha.js
@@ -4251,6 +4251,28 @@ Runner.prototype.fail = function(test, err){
};
/**
+ * Fail the given `suite`.
+ *
@jugglinmike
jugglinmike / logfail.sh
Created November 2, 2013 17:36
Continuously re-run a process, logging failures (troubleshooting flaky integration tests)
#!/usr/bin/env bash
# Continuously re-run a process, logging failures
RUNCOUNT=0
FAILCOUNT=0
COMMAND=$1
while [ 1 ]
do
@jugglinmike
jugglinmike / Readme.md
Created October 30, 2013 00:47
File hashing research

File Hashing Research

Tests in Mozilla-Central

$ time ./hash.sh `find ~/projects/mozilla/mozilla-central/dom/ -type f -path */test/*.js`
real  0m0.059s
user  0m0.032s
sys 0m0.020s

$ time ./hash.py find ~/projects/mozilla/mozilla-central/dom/ -type f -path */test/*.js

@jugglinmike
jugglinmike / checkt440s.sh
Last active December 21, 2015 12:39 — forked from alunny/checkmc.sh
#!/bin/bash
while true
do
curl -s http://shop.lenovo.com/us/en/laptops/thinkpad/t-series/ | grep -i "t440s"
if [ $? -ne 0 ]
then
echo "not found at `date`"
sleep 1800
else
@jugglinmike
jugglinmike / some-qs.md
Created August 22, 2013 13:17
Some questions I had after listening to Andrew Sliwinski discuss stress testing diy.org on the NodeUp podcast.

Hey Andrew! Thanks for offering to discuss your setup further. I fumbled around with stress testing late last year, but the method you described on NodeUp seemed so much simpler.

I haven't had a chance to use restify--is your logging as simple as a single handler that logs with node-bunyen, passed to server.use?

Does diy.org use WebSockets? Do you have a way to stress test that code? Does Load Impact support simulating WebSocket traffic?

I'm having a little trouble understanding Load Impact's pricing/credit structure. Could you give me an idea of the shape of the traffic you simulate, and what that translates into for credits?

Do you stress test your production system ([like Netflix](http://techblog.netflix.co

@jugglinmike
jugglinmike / line.js
Created August 16, 2013 23:19
Experimenting with d3.svg.line support in d3.chart
var LineChart = d3.chart("Line", {
initialize: function() {
var path = this.base.append("path")
.classed("line", true);
var x = this.x = d3.time.scale()
.range([0, width]);
var y = this.y = d3.scale.linear()
.range([height, 0]);
var line = d3.svg.line()
.x(function(d) { return x(d.date); })
@jugglinmike
jugglinmike / index.html
Last active February 16, 2021 04:51
Stock chart with d3.chart
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<style>
body {
font: 10px sans-serif;
}
.axis path,