Skip to content

Instantly share code, notes, and snippets.

View tierney's full-sized avatar

Matt Tierney tierney

View GitHub Profile
@tierney
tierney / thrift.c++11.patch
Created May 17, 2013 00:46
Patch for thrift-0.9.0 that compiles the library for Clang's C++11 (or, rather, gnu++11) with the following flags: make CXXFLAGS="-std=gnu++11 -stdlib=libc++" CXX=clang++
diff --git a/compiler/cpp/src/generate/t_cpp_generator.cc b/compiler/cpp/src/generate/t_cpp_generator.cc
index 9b960bf..a4ce754 100644
--- a/compiler/cpp/src/generate/t_cpp_generator.cc
+++ b/compiler/cpp/src/generate/t_cpp_generator.cc
@@ -1586,7 +1586,7 @@ void t_cpp_generator::generate_service(t_service* tservice) {
if (gen_cob_style_) {
f_header_ <<
"#include <thrift/transport/TBufferTransports.h>" << endl << // TMemoryBuffer
- "#include <tr1/functional>" << endl <<
+ "#include <functional>" << endl <<
#!/usr/bin/env bash
dir=$(dirname $0)
gconfdir=/apps/gnome-terminal/profiles
echo # This makes the prompts easier to follow (as do other random echos below)
########################
### Select a profile ###
########################
from sqlalchemy import create_engine, MetaData, Table
from sqlalchemy.orm import sessionmaker, scoped_session, create_session, mapper
from sqlalchemy.sql import exists
db_engine = create_engine(DATABASE_CONNECTION_INFO, echo=False)
metadata = MetaData(db_engine)
DBSession = scoped_session(
sessionmaker(
autoflush=True,
@tierney
tierney / queue.h
Created November 1, 2012 22:01
Queue template C++ class that emulates the API and behavior of Python's thread-safe Queue collection.
// Copyright 2012. Matt Tierney. BSD Style License.
// Author: [email protected] (Matt Tierney)
#ifndef _QUEUE_H_
#define _QUEUE_H_
#include <ctime>
#include <deque>
#include <pthread.h>
#include <sys/time.h>
@tierney
tierney / cryptogram.m
Created May 27, 2012 18:13
Core Image Manipulation and SJCL Code
NSString *image_path = [[NSBundle mainBundle] pathForResource:@"koi" ofType:@"jpg"];
NSFileHandle *image_fh = [NSFileHandle fileHandleForReadingAtPath:image_path];
NSData *buffer = [image_fh readDataToEndOfFile];
NSString *base64_image = [QSStrings encodeBase64WithData:buffer];
NSLog(@"image %@.", [base64_image substringToIndex:25]);
NSString *password = @"cryptogram";
NSString *sjcl_command = [NSString
stringWithFormat:@"sjcl.encrypt(\"%@\", \"%@\");",
password, base64_image];
@tierney
tierney / mac-homebrew-pyexiv2.sh
Created May 8, 2012 20:23 — forked from jpwatts/mac-homebrew-pyexiv2.sh
In which I finally get pyexiv2 working on my Mac using Homebrew and a series of disgusting hacks
#!/bin/sh
brew install python boost exiv2
curl -O http://launchpadlibrarian.net/61465005/pyexiv2-0.3.0.tar.bz2
tar xjvf pyexiv2-0.3.0.tar.bz2
cd pyexiv2-0.3.0
# https://answers.launchpad.net/pyexiv2/+question/140742
echo "env['FRAMEWORKS'] += ['Python']" >> src/SConscript
@tierney
tierney / neo4j-hacking.py
Created May 1, 2012 21:38
neo4j hacking
#!/usr/bin/env python
import time
from random import randint
from neo4j import GraphDatabase
path = '/home/tierney/Downloads/neo4j-community-1.7/data/graph.db'
_NUM_NODES = 1000000
db = GraphDatabase(path)
def load():
@tierney
tierney / setup.py.diff
Created April 25, 2012 02:45
PyV8 Statically Compile/Link boost.python and v8
Index: setup.py
===================================================================
--- setup.py (revision 435)
+++ setup.py (working copy)
@@ -16,7 +16,7 @@
PYV8_HOME = os.path.abspath(os.path.dirname(__file__))
BOOST_HOME = None
BOOST_PYTHON_MT = False
-BOOST_STATIC_LINK = False
+BOOST_STATIC_LINK = True
@tierney
tierney / closest-match-binary-search.js
Created April 23, 2012 22:49
Javascript Binary Search with Closest Match
Array.prototype.binarySearch = function(find, comparator) {
var low = 0, high = this.length - 1, i, comparison, prev_comparison;
while (low <= high) {
i = Math.floor((low + high) / 2);
comparison = comparator(this[i], find);
prev_comparison = comparison
if (comparison < 0) { low = i + 1; continue; };
if (comparison > 0) { high = i - 1; continue; };
return i;
}
@tierney
tierney / post-process-pyjsbuild-html.py
Created April 19, 2012 02:41
Separate HTML+Javascript generated by pyjamas into distinct HTML and Javascript files.
#!/usr/bin/env python
# Converts pyjamas-generated html code into more cleanly separated html and
# javascript.
import os
import sys
import re
filename = sys.argv[1]