Skip to content

Instantly share code, notes, and snippets.

@haydenmuhl
haydenmuhl / gist:1078293
Created July 12, 2011 16:07
Grails testing, error when using mockFor
Code:
class RepoControllerTests extends ControllerUnitTestCase {
protected void setUp() {
super.setUp()
}
protected void tearDown() {
super.tearDown()
}
@haydenmuhl
haydenmuhl / gist:1079805
Created July 13, 2011 06:04
How to mock objects instantiated inside another class?
class CommandLine {
def ls() {
def cmd = "ls".execute()
if(cmd.waitFor() != 0) {
throw new Execution()
}
return cmd.text
}
}
@haydenmuhl
haydenmuhl / gist:1105825
Created July 26, 2011 02:42
Multi voice example
<<
{ <a a'>2 } \\
{ e'8. cis'16 d'4 }
>>
<<
{ <a d' a'>4 <a' d''>4 } \\
{ s4 e'8 d'8 }
>>
<<
{ a'4 a'4 } \\
// Class under test
class Repo {
static listRepos() {
def dir = new File("repos")
def repos = []
dir.listFiles().each {
def regex = /repos\/(.+)\.git/
def match = it =~ regex
if(match.size() > 0) {
commit 3f3dc05bada3b0aa782091215cd9f59b9b64928e
Merge: 01740c7 481708e
Author: Hayden Muhl <hmuhl@lyris.com>
Date: Mon Jul 18 15:17:33 2011 -0700
Merge branch 'feature'
diff --cc sandwich
index 919ef00,727d1bd..52ffab8
--- a/sandwich
<ul>
<g:each in="${list}" var="item">
<li><render template="itemTemplate" model="[item: item]"/></li>
</g:each>
</ul>
<!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
${item.name}
@haydenmuhl
haydenmuhl / nav.html
Created August 28, 2011 14:37
How do I use a generated text value as a key into a js object?
<html>
<head>
<title>asdf</title>
<script type="text/javascript" src="/giggity/js/jquery.js" ></script>
<script type="text/javascript">
$(document).ready(function () {
$("#branches option").click(
function() {
window.location.href = branchUrls[$(this).text()];
}
line 1
line 2
line 3
etc.
<project name="hNes" default="build" basedir=".">
<presetdef name="javac">
<javac includeantruntime="false" />
</presetdef>
<property name="src" location="src" />
<property name="build" location="build" />
<property name="test" location="test" />
<property name="src.classes" location="${build}/classes" />
<property name="test.classes" location="${build}/tests" />
@haydenmuhl
haydenmuhl / Main.java
Created May 22, 2017 21:21
Quick and dirty tool to find a new Minecraft spawn point
package amidst.me;
import java.io.File;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Random;
import java.util.Set;