Skip to content

Instantly share code, notes, and snippets.

View benjchristensen's full-sized avatar

Ben Christensen benjchristensen

View GitHub Profile
<?php
header("Content-Type: text/event-stream\n\n");
echo 'data: ' . json_encode(
array(
0 => array(
'time' => time(),
'message' => 'Some kind of foo'
),
1 => array(
@benjchristensen
benjchristensen / index.html
Created August 9, 2011 05:38
Simple Sparkline using SVG Path and d3.js
<html>
<head>
<title>Simple Sparkline using SVG Path and d3.js</title>
<script src="http://mbostock.github.com/d3/d3.v2.js"></script>
<style>
/* tell the SVG path to be a thin blue line without any area fill */
path {
stroke: steelblue;
stroke-width: 1;
fill: none;
@benjchristensen
benjchristensen / index.html
Created August 15, 2011 23:59
Animated Sparkline using SVG Path and d3.js
<html>
<head>
<title>Animated Sparkline using SVG Path and d3.js</title>
<script src="http://mbostock.github.com/d3/d3.v2.js"></script>
<style>
/* tell the SVG path to be a thin blue line without any area fill */
path {
stroke: steelblue;
stroke-width: 1;
fill: none;
@benjchristensen
benjchristensen / index.html
Created August 16, 2011 03:21
Animated Line Graphs / Sparklines using SVG Path and d3.js
<html>
<head>
<title>Animated Sparkline using SVG Path and d3.js</title>
<script src="http://mbostock.github.com/d3/d3.v2.js"></script>
<style>
/* tell the SVG path to be a thin blue line without any area fill */
path {
stroke: steelblue;
stroke-width: 1;
fill: none;
@benjchristensen
benjchristensen / index.html
Created August 18, 2011 04:18
DIV Popup with "Lightbox" Style
<html>
<head>
<title>DIV Popup with "Lightbox" Style</title>
<script src="http://code.jquery.com/jquery-1.6.2.min.js"></script>
<style>
/* popup div contents */
DIV.lightbox-content {
position: absolute;
margin-right: auto;
margin-left: 5%;
import static org.junit.Assert.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.logging.Level;
@benjchristensen
benjchristensen / gist:1284824
Created October 13, 2011 17:09
JUnit and Mockito with Reflection
/**
* Use reflection to allow performing the same tests on all GETTER methods.
*
* @param cache
* @param m
* @param argArray
* @throws IllegalAccessException
* @throws InvocationTargetException
*/
private void testGetMethod(Method m, Object[] argArray) throws IllegalAccessException, InvocationTargetException {
@benjchristensen
benjchristensen / gist:1284836
Created October 13, 2011 17:14
Shell script with command line arguments
#!/usr/bin/env python
import subprocess
import argparse
import zipfile
import os
parser = argparse.ArgumentParser(description='Upload a file or files to a RESTful endpoint')
parser.add_argument('-e', '--environment', metavar='TEST/PROD',
help='The environment to upload to: TEST/PROD')
import java.util.ArrayList;
import java.util.Collection;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
import junit.framework.TestCase;
import org.junit.Test;
@benjchristensen
benjchristensen / JavadocFilter.java
Created November 30, 2011 20:29
Doclet for filtering public classes from Javadoc
import java.lang.reflect.Array;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import java.util.ArrayList;
import java.util.List;
import com.sun.javadoc.Doc;
import com.sun.javadoc.DocErrorReporter;