Skip to content

Instantly share code, notes, and snippets.

View enjoylife's full-sized avatar
📖

Matthew Clemens enjoylife

📖
View GitHub Profile
@enjoylife
enjoylife / gist:1337872
Created November 3, 2011 21:42
testing of Flask and Neo4j
import os
import jpype
from neo4j import GraphDatabase
from flask import Flask, request, session, g, redirect, url_for, abort, render_template, flash
app = Flask(__name__)
app.config.from_object(__name__)
app.config['ADMIN'] ='Matthew'
app.config['DATABASE']='/tmp/graphtest'
@enjoylife
enjoylife / gist:1739351
Created February 4, 2012 18:29
xml extract
# Split a Wikipedia XML dump
# Evan Jones <evanj@mit.edu>
# April, 2008
# Released under a BSD licence.
# http://evanjones.ca/software/wikipedia2text.html
import sys
import xml.sax
def writeArticle(title, text):
@enjoylife
enjoylife / Scan.py
Created April 3, 2012 05:56
Python implementation of SCAN: A Structural Clustering Algorithm for Networks
# -*- coding: utf-8 -*-
"""
SCAN: A Structural Clustering Algorithm for Networks
As described in http://ualr.edu/nxyuruk/publications/kdd07.pdf
"""
from collections import deque
import numpy as np
from scipy.sparse import csr_matrix
@enjoylife
enjoylife / dbg.h
Created April 10, 2012 00:55
my first c debug header file
/* dbg.h
* Taken from Zed A Shaw's awesome debug macros.
* Added a bunch of crappy colors to it for my lazy eyes. */
#ifndef __dbg_h__
#define __dbg_h__
#include <stdio.h>
#include <errno.h>
#include <string.h>
#define RESET "\033[0m"
@enjoylife
enjoylife / unrollexample.c
Created May 18, 2012 07:40
loop unrolling technique
#include<stdio.h>
#define TOGETHER (8)
int main(void)
{
int i = 0;
int entries = 50; /* total number to process */
int repeat; /* number of times for while.. */
int left = 0; /* remainder (process later) */
@enjoylife
enjoylife / index.html
Created July 31, 2012 20:58
Trying to figure out why the endpoints of an axis based upon a time scale are not clean and at the end
<!DOCTYPE html>
<head>
<meta charset="utf-8">
<script type="text/javascript" src="http://d3js.org/d3.v2.min.js"></script>
<style>
svg {
font: 10px sans-serif;
shape-rendering: crispEdges;
}
@enjoylife
enjoylife / index.html
Created July 31, 2012 21:08
scale endpoint OCD
<!DOCTYPE html>
<head>
<meta charset="utf-8">
<script type="text/javascript" src="http://d3js.org/d3.v2.min.js"></script>
<style>
svg {
font: 10px sans-serif;
shape-rendering: crispEdges;
}
@enjoylife
enjoylife / memo.js
Created August 3, 2012 20:17
memoize snippet found
function memoizeConstantMethod(o, p) {
var f = o[p], mf;
var s = function(v) {return o[p]=v||mf};
((mf = function() {
(s(function(){return value})).reset = mf.reset;
return value = f.call(this);
}).reset = s)();
}
@enjoylife
enjoylife / install_node.sh
Created August 4, 2012 08:16
install script for node on debian
apt-get install python g++;
mkdir ~/nodejs && cd $_;
wget -N http://nodejs.org/dist/node-latest.tar.gz;
tar xzvf node-latest.tar.gz && cd `ls -rd node-v*`;
make install;
@enjoylife
enjoylife / poundswap.h
Created October 1, 2012 05:08
swap # define
#define SWAP(x, y) do { typeof(x) temp##x##y = x; x = y; y = temp##x##y; } while (0)