Skip to content

Instantly share code, notes, and snippets.

View dan's full-sized avatar
🕶️
Seeking restitution for my ruined rug.

Dan Benjamin dan

🕶️
Seeking restitution for my ruined rug.
View GitHub Profile
var http = require("http"),
url = require("url"),
path = require("path"),
fs = require("fs")
port = process.argv[2] || 8888;
http.createServer(function(request, response) {
var uri = url.parse(request.url).pathname
, filename = path.join(process.cwd(), uri);
@dan
dan / hack.sh
Created March 31, 2012 12:17 — forked from erikh/hack.sh
OSX For Hackers
#!/usr/bin/env sh
##
# This is script with usefull tips taken from:
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
#
# install it:
# curl -sL https://raw.github.com/gist/2108403/hack.sh | sh
#
@dan
dan / dantimer.rb
Created June 22, 2012 13:31 — forked from davetron5000/dantimer.rb
DanTimer
#!/usr/bin/ruby
require 'time'
def format_time(seconds)
hours = (seconds / 3600).to_i
minutes = ((seconds % 3600) / 60).to_i
seconds = (seconds % 60).to_i
minutes = "0#{minutes}" if minutes < 10
seconds = "0#{seconds}" if seconds < 10
@dan
dan / UITextView.c
Last active December 18, 2015 17:29 — forked from brentsimmons/gist:5810992
@implementation UITextView (RSExtras)
static BOOL stringCharacterIsAllowedAsPartOfLink(NSString *s) {
/*[s length] is assumed to be 0 or 1. s may be nil.
Totally not a strict check.*/
if (s == nil || [s length] < 1)
return NO;
require 'mp3info'
# some test data, replace it with your own data
title = "After Dark #388: After Back to Work"
subtitle = "Merlin & Dan talk after Back to Work episode 104."
artist = "Dan Benjamin on 5by5.tv"
album = "After Dark"
genre = "Podcast"
track = 338
year = 2013
@dan
dan / ffmpeg.sh
Last active August 29, 2015 14:07 — forked from ryanbillingsley/ffmpeg.sh
for i in "$@" ; do /Users/jsnell/ffmpeg -i "$i" -map 0:0 -acodec pcm_s161e -ac 1 -out_sample_rate 44100 "${i%.*}.wav" ;
done
sub vcl_hit {
if (obj.ttl >= 0s) {
# normal hit
return (deliver);
}
# We have no fresh fish. Lets look at the stale ones.
if (std.healthy(req.backend_hint)) {
# Backend is healthy. Limit age to 10s.
if (obj.ttl + 10s > 0s) {
set req.http.grace = "normal(limited)";