Skip to content

Instantly share code, notes, and snippets.

View fredrik's full-sized avatar
🚀

Fredrik Möllerstrand fredrik

🚀
View GitHub Profile
@fredrik
fredrik / Makefile.diff
Created July 24, 2012 10:37
librabbitmq 0.9.9 install fails
diff --git a/Makefile b/Makefile
index 7c5ccf8..527c238 100644
--- a/Makefile
+++ b/Makefile
@@ -57,7 +57,7 @@ $(RABBIT_TARGET):
dist: rabbitmq-c $(RABBIT_TARGET)
-
+ (cd clib; test -f clib/config.h || ./configure)
@fredrik
fredrik / list.c
Created October 18, 2011 14:21
List files in directory. Works on directories with many millions of files.
/*
* based on example code in the getdents(2) man page.
* informed by http://www.olark.com/spw/2011/08/you-can-list-a-directory-with-8-million-files-but-not-with-ls/
*/
#define _GNU_SOURCE
#include <dirent.h> /* Defines DT_* constants */
#include <fcntl.h>
#include <stdio.h>
Index: SConstruct
===================================================================
--- SConstruct (revision 3521)
+++ SConstruct (working copy)
@@ -47,7 +47,7 @@
# on linux we need these compiler flags to avoid crashes in the v8 test suite
# and avoid dtoa.c strict aliasing issues
if os.environ.get('GCC_VERSION') == '44':
- GCC_EXTRA_CCFLAGS = ['-fno-tree-vrp']
+ GCC_EXTRA_CCFLAGS = ['-fno-tree-vrp', '-fno-strict-aliasing']
#!/usr/bin/python
"""Copyright 2008 Orbitz WorldWide
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
@fredrik
fredrik / graphite-web-0.9.7.fix.pyparsing.patch
Created March 15, 2011 14:09
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND.
diff --git a/cli/parser.py b/cli/parser.py
index ec1a435..7d7d48d 100644
--- a/cli/parser.py
+++ b/cli/parser.py
@@ -12,7 +12,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License."""
-from graphite.thirdparty.pyparsing import *
+from pyparsing import *
@fredrik
fredrik / centrality.py
Created October 19, 2010 09:27
calculate centrality measures for a network using networkx
#!/usr/bin/env python
import networkx as nx
# for each node:
# + degree centrality
# + closeness centrality
# + betweenness centrality
# + eigenvector centrality
# + page rank
# run like so:
# $> ruby normalize.rb --run=local --input data/sizes --output data/normalized_sizes
module Normalize
class Mapper < Wukong::Streamer::LineStreamer
def process(line)
fields = line.strip.split("\t")
country = fields.reverse!.pop
data = fields.map(&:to_i)
#!/bin/bash -xe
# from http://gist.github.com/249915 by fairchild
if [ -z $1 ]; then
echo "usage: $0 INSTANCE_ID"
exit
fi
EBS_DEVICE='/dev/sdh'
INSTANCE_ID=$1
#!/usr/bin/env python
# these here programming codes are licensed under the gnu fearsome dude license.
# writes 500k rows to a table, where each row represents a track in an artist's
# library for a single day. the play count is stored in the cfq 'unit:scrobbles'.
# 1: hbase(main):001:0> create '500k-test', 'unit:'
# 2: $> hbase thrift start
# 3: $> python testdata-500k.py (~500 seconds on my hackintosh)
import time
# decorator that measures execution time of a function.
def timing(func):
def wrapper(*arg):
t0 = time.time()
r = func(*arg)
elapsed = time.time() - t0
print '%s => %0.3f ms' % (func.func_name, elapsed*1000.00)
return r