Skip to content

Instantly share code, notes, and snippets.

View bherrmann7's full-sized avatar

Bob Herrmann bherrmann7

View GitHub Profile
@bherrmann7
bherrmann7 / gist:9002398
Created February 14, 2014 14:55
A user script (I use chrome's tamper monkey) for making hacker news cleanly more informational (ie. remove visual clutter... IMHO)
// ==UserScript==
// @name HackerNews Scrubbed
// @namespace http://jadn.com/bob
// @version 0.1
// @description enter something useful
// @match https://news.ycombinator.com/*
// @copyright 2014+, bherrmann
// ==/UserScript==
document.getElementsByTagName("table")[0].getElementsByTagName("tr")[0].style.display="none";
(defmacro spy [expr] `(let [a# ~expr] (println (str '~expr " => " a#)) a#))
// Groovy script to dump the browser's headers
ServerSocket ss = new ServerSocket();
ss.bind(null)
println "listening on "+ss.getLocalPort();
Socket s = ss.accept()
s.getInputStream().eachLine { line ->
println line
/*
* HumanTime.java
*
* Created on 06.10.2008
*
* Copyright (c) 2008 Johann Burkard (<mailto:jb@eaio.com>) <http://eaio.com>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
* documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
// Firebug script to set all checkboxs
ee = document.getElementsByTagName("input"); for(i=0;i<ee.length;i++){ ee[i].checked = true };
package jbum.pdf;
import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.FileOutputStream;
import java.io.OutputStream;
int numberOfColumns = row.getMetaData().getColumnCount();
print "Columns:"
(1..numberOfColumns).each {n ->
print " $n:${row.getMetaData().getColumnName(n)}"
}
println('')
@bherrmann7
bherrmann7 / gist:208598
Created October 12, 2009 18:21
how to record some of what a closure does when it runs
// CriteriaRecorder - this gist lets you wrap a closure so you can record and manipulate the list of things the closure attempts to invoke.. Good for unit testing closures which build up GORM requests
class Node {
String name
def args
String render(StringBuilder sb, int level){
sb.append ' '.multiply(level*4)
sb.append name+'('+args.join(',')+')\n'
// validate a schema using relagNG
// 1. download jing from http://code.google.com/p/jing-trang/
// 2. copy the jing.jar into $GROOVY_HOME/lib
// 3. now copy/paste this into the groovy console and have fun!!!
import com.thaiopensource.util.PropertyMapBuilder;
import com.thaiopensource.validate.*
import com.thaiopensource.validate.rng.CompactSchemaReader;
import com.thaiopensource.xml.sax.ErrorHandlerImpl;
import org.xml.sax.InputSource;
// input: someGroovyCodeToTakeCamelCaseAndMakeItNicer
// output: Some Groovy Code To Take Camel Case And Make It Nicer
def str = 'someGroovyCodeToTakeCamelCaseAndMakeItNicer'.collect {
(Character.isUpperCase(it as char)?' ':'') + it
}.join()
str = str[0].toUpperCase() + str[1..-1]