Skip to content

Instantly share code, notes, and snippets.

View metafeather's full-sized avatar

Liam Clancy metafeather

View GitHub Profile
@metafeather
metafeather / map.py
Created July 22, 2014 11:46
MapReduce in Python from JSON via stdin
#!/usr/bin/python
# MAPPER
# ref: http://open.blogs.nytimes.com/2014/07/10/emr-streaming-in-go/
import sys
import simplejson as json
def main():
@metafeather
metafeather / execute_notebook.py
Last active August 29, 2015 14:03
IPython - executing other notebooks
import io
from IPython.nbformat import current
def execute_notebook(nbfile):
with io.open(nbfile) as f:
nb = current.read(f, 'json')
ip = get_ipython()
for cell in nb.worksheets[0].cells:
if cell.cell_type != 'code':
continue
@metafeather
metafeather / node-express-jsonstream.js
Last active August 29, 2015 13:57
Get, Parse and Transform JSONStreams on the fly before delivering to the browser
// Get, Parse and Transform JSONStreams on the fly before delivering to the browser
// ref: http://nodestreams.com/
var express = require('express'),
server = express();
var fs = require("fs"),
JSONStream = require("JSONStream"),
es = require('event-stream');
@metafeather
metafeather / gist:6211148
Created August 12, 2013 14:12
Cross browser version of Date.now()
// 1*new Date() is a cross browser version of Date.now()
var d = 1*new Date()
@metafeather
metafeather / gist:6145895
Last active December 20, 2015 14:19
Selenium direct calls to page JS
Examples:
JSCover report, ref: http://tntim96.github.io/JSCover/manual/manual.xml
String json = selenium.getEval("selenium.browserbot.getUserWindow().jscoverage_serializeCoverageToJSON();");
Via SeleniumJQuery, ref: https://github.com/Nthalk/SeleniumJQuery/blob/master/example/com/anteambulo/SeleniumJQuery/example/Example.java
jq.query("[name=q]").val("SeleniumJQuery").parents("form:first").submit();
String results = jq.queryUntil("#resultStats:contains(results)").text();
@metafeather
metafeather / POJOToJSON.mv
Created November 7, 2012 15:26 — forked from narenranjit/VelToJSON
Macros to convert Plain Old Java Objects in Velocity templates to JSON
#macro(POJOListToJSON $list )
#set($myList = $list )
{
#foreach($key in $myList.keySet())
#set($x = $myList.get($key))
"$key": #POJOToJSON($x) ##
#if($velocityCount != $myList.keySet().size())
,
#end
#end
@metafeather
metafeather / pretty git log
Created June 20, 2012 09:08
pretty git log
# pretty git log
# ref: http://coderwall.com/p/euwpig?i=3&p=1&t=git
git log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --
@metafeather
metafeather / Git Shortlog format
Created July 20, 2010 14:28
Git Shortlog format for nice lists of different files between SVN branches retaining git-svn-id's
# Git Shortlog format for nice lists of different files between SVN branches retaining git-svn-id's
git shortlog --format="%h %b %s" <branch>..master
@metafeather
metafeather / ant.xml
Last active February 5, 2022 18:16
Compile JS files to Java byte code in Ant
<!-- compile JS files to Java byte code in Ant -->
<java classname="org.mozilla.javascript.tools.jsc.Main" classpathref="rhino.class.path" fork="yes">
<arg value="-debug"/>
<arg value="${basedir}/file/1.js"/>
<arg value="${basedir}/file/2.js"/>
</java>
# Relax NG compact schema for Ant created JUnit XML files
start = testsuite | testsuites
property = element property {
attribute name {text},
attribute value {text}
}
properties = element properties {