Skip to content

Instantly share code, notes, and snippets.

@danielnorberg
danielnorberg / remove-trailing-whitespace
Created December 30, 2010 21:23
A simple script to recursively remove trailing whitespace from Objective-C source code files in a directory.
#!/bin/bash
if [ $# -gt 0 ]; then
echo
echo Removing trailing whitespace in $1
echo
find $1 -type f -iname '*.[hm]' -exec gsed -i 's/[[:space:]]*$//' '{}' ';'
else
echo
echo Usage:
echo remove-trailing-whitespace [target-dir]
@danielnorberg
danielnorberg / bar.py
Created January 6, 2011 11:06
Cython 0.14 Bug
def bar(foo):
qux = foo
quux = foo[qux.baz]
#
# Error compiling Cython file:
# ------------------------------------------------------------
# ...
# def bar(foo):
@danielnorberg
danielnorberg / dvd_transcode.sh
Created February 10, 2011 15:00
dvd_transcode takes a list of video files and transcodes them into DVD compliant MPEG-2 (NTSC).
#! /usr/bin/env python
import argparse
import os
import subprocess
def main():
parser = argparse.ArgumentParser(description='Transcodes videos to DVD compatible MPEG-2 using mencoder')
parser.add_argument('file', help='Input file', nargs='+')
args = parser.parse_args()
import re
from datetime import timedelta
def parseTimeDelta(s):
"""Create timedelta object representing time delta
expressed in a string.
"""
if s is None:
return None
d = re.match(
@danielnorberg
danielnorberg / pssh-aliases.sh
Created May 24, 2011 09:06 — forked from dln/pssh-aliases.sh
Create aliases for working with remote clusters.
#
# Dependencies: pssh, pdsh, cssh
#
# Under ~/.pssh/ I keep lists of hosts, one cluster per file, one hostname per line.
#
alias mssh='f() { hosts=$1; shift; for h in $(cat ~/.pssh/$hosts); do ssh $h $@ ; done }; f'
# auto-generate aliases for common host groups
for hostlist in $(ls ~/.pssh/); do
@danielnorberg
danielnorberg / gist:1496730
Created December 19, 2011 11:20
zeromq 3 pub assert
#include <unistd.h>
#include <zmq.h>
int main (int argc, const char * argv[])
{
void *ctx = zmq_init (1);
void *pub = zmq_socket (ctx, ZMQ_PUB);
zmq_bind (pub, "tcp://*:4711");
@danielnorberg
danielnorberg / gist:1497216
Created December 19, 2011 13:24
zeromq 3 pub leak
#include <string.h>
#include <sys/time.h>
#include <unistd.h>
#include <zmq.h>
#define TOPIC "foobarfoobarfoobarfoobarfoobar"
int main (int argc, const char * argv[])
{
@danielnorberg
danielnorberg / NonBlockingHashMapTest.java
Created September 1, 2012 09:45
NonBlockingHashMap unbounded growth and slowdown
import org.cliffc.high_scale_lib.NonBlockingHashMap;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
public class NonBlockingHashMapTest {
static class Progress extends Thread {
public volatile long operations;
public void run() {
From b00ab1a369c87e2cdcc29f178a337a20bf7fb07b Mon Sep 17 00:00:00 2001
From: Daniel Norberg <[email protected]>
Date: Thu, 12 Jun 2014 19:55:42 -0400
Subject: [PATCH] fix building on macosx
---
pkg/libcontainer/namespaces/nsenter.go | 133 +--------------------------------
1 file changed, 2 insertions(+), 131 deletions(-)
diff --git a/pkg/libcontainer/namespaces/nsenter.go b/pkg/libcontainer/namespaces/nsenter.go
require "formula"
class Docker < Formula
homepage "http://docker.io"
url "https://github.com/dotcloud/docker.git", :tag => "v1.0.0"
option "without-completions", "Disable bash/zsh completions"
depends_on "go" => :build