Skip to content

Instantly share code, notes, and snippets.

Ben Christensen benjchristensen

Block or report user

Report or block benjchristensen

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View event.php
<?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 Aug 9, 2011
Simple Sparkline using SVG Path and d3.js
View index.html
<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 Aug 15, 2011
Animated Sparkline using SVG Path and d3.js
View index.html
<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 Aug 16, 2011
Animated Line Graphs / Sparklines using SVG Path and d3.js
View index.html
<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 Aug 18, 2011
DIV Popup with "Lightbox" Style
View index.html
<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%;
View JSONUtility.java
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 Oct 13, 2011
JUnit and Mockito with Reflection
View gist:1284824
/**
* 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 Oct 13, 2011
Shell script with command line arguments
View gist:1284836
#!/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')
View XMLUtility.java
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 Nov 30, 2011
Doclet for filtering public classes from Javadoc
View JavadocFilter.java
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;
You can’t perform that action at this time.