Skip to content

Instantly share code, notes, and snippets.

View mnutt's full-sized avatar

Michael Nutt mnutt

View GitHub Profile
<html>
<body>
<h1>0</h1>
<script>
var element = document.getElementsByTagName("h1")[0];
var counter = 0;
function manualAdvance() {
counter += 1;
element.innerHTML = counter;
var http = require('http');
// Unresponsive server
http.createServer(function(req, res) {
// don't respond
}).listen(5933);
// Client that times out
@mnutt
mnutt / qimage_benchmark.cpp
Created October 30, 2011 20:40
benchmark QImage save
#include <QtGui>
#include <QTimer>
int
main(int argc, char *argv[]) {
int times = 1000;
QString format("png");
QByteArray ba;
@mnutt
mnutt / index.html
Created August 27, 2011 00:26 — forked from mbostock/.block
Mobile Patent Suits
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
<title>Mobile Patent Suits</title>
<script type="text/javascript" src="http://mbostock.github.com/d3/d3.js?1.29.1"></script>
<script type="text/javascript" src="http://mbostock.github.com/d3/d3.geom.js?1.29.1"></script>
<script type="text/javascript" src="http://mbostock.github.com/d3/d3.layout.js?1.29.1"></script>
<style type="text/css">
set $test "";
if ($http_x_forwarded_proto != https) { set $test "x"; }
if ($scheme != https) { set $test "${test}s"; }
if ($uri ~ ^/(login|account)) { set $test "${test}u"; }
if ($test = xsu) {
rewrite ^ https://example.com$request_uri? break;
}
sub vcl_error {
set obj.http.Content-Type = "image/gif";
set obj.http.Content-Length = "42";
C{
const unsigned char pixel[] = {
0x47, 0x49, 0x46, 0x38, 0x39, 0x61, 0x01, 0x00, 0x01, 0x00, 0x80, 0x00, 0x00,
0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0x21, 0xf9, 0x04, 0x01, 0x00, 0x00, 0x00,
0x00, 0x2c, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x02, 0x01,
This file has been truncated, but you can view the full file.
(function () {
var b = true,
g = null,
i = false,
l = window.gbar;
var m = m || {};
m.global = this;
m.M = b;
m.jc = "en";
m.H = g;
/* Olark + GetSatisfaction CSS */
/* This CSS overrides Olark's default theme to make a tab similar in style to */
/* GetSatisfaction's default tab. It's on the right by default. It's an ugly */
/* hack, so don't blame me if it totally breaks when Olark decides to update */
/* something. */
.habla_window_div_position_floating {
top:25% !important;
position: fixed !important;
@mnutt
mnutt / gist:738805
Created December 13, 2010 08:46
Build error for qtbindings
michael:~/code/qtbindings (master) $ make
mkdir ext/build
mkdir: ext/build: File exists
make: [makedirs] Error 1 (ignored)
mkdir bin/1.8
mkdir: bin/1.8: File exists
make: [makedirs] Error 1 (ignored)
mkdir bin/1.9
mkdir: bin/1.9: File exists
make: [makedirs] Error 1 (ignored)
@mnutt
mnutt / Instrument Anything in Rails 3.md
Created September 6, 2010 06:50
How to use Rails 3.0's new notification system to inject custom log events

Instrument Anything in Rails 3

With Rails 3.0 released a few weeks ago I've migrated a few apps and I'm constantly finding useful new improvements. One such improvement is the ability to log anything in the same way that Rails internally logs ActiveRecord and ActionView. By default Rails 3 logs look slightly spiffier than those produced by Rails 2.3: (notice the second line has been cleaned up)

Started GET "/" for 127.0.0.1 at Mon Sep 06 01:07:11 -0400 2010
  Processing by HomeController#index as HTML
  User Load (0.2ms)  SELECT `users`.* FROM `users` WHERE (`users`.`id` = 3) LIMIT 1
  CACHE (0.0ms)  SELECT `users`.* FROM `users` WHERE (`users`.`id` = 3) LIMIT 1

Rendered layouts/_nav.html.erb (363.4ms)