Skip to content

Instantly share code, notes, and snippets.

View ctoestreich's full-sized avatar

Christian Oestreich ctoestreich

View GitHub Profile
@ctoestreich
ctoestreich / gist:1337648
Created November 3, 2011 20:08
Testing storage of millions of keys in Redis using Custom Number Encoder
@Grapes([
@Grab('redis.clients:jedis:1.5.1'),
@GrabConfig(systemClassLoader=true)
])
import redis.clients.jedis.*
performTest("unencoded", null) {n, e->
n.toString()
}
@ctoestreich
ctoestreich / gist:1337772
Created November 3, 2011 21:02
Custom Number Encoder Memory Storage Size Test
def r = new Random()
def num = r.nextInt(12000000).toString()
println num
println num.bytes.length
println encodeNumber(num, getEncoder())
println encodeNumber(num, getEncoder()).bytes.length
def getEncoder(){
['1','2','3','4','5','6','7','8','9','0','-','=','!','@','#','$','%','^','&','*','(',')','_',
'+','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z',
@ctoestreich
ctoestreich / gist:1337848
Created November 3, 2011 21:36
Custom Number Encoder Speed Test
def tests = 5000
def enm = {n, e-> encodeNumberMap(n, e).toString() }
def dnm = {n, e-> decodeNumberMap(n, e).toString() }
performTest("map", tests, getEncoderMap(), getDecoderMap(), enm, dnm)
def en = {n, e-> encodeNumber(n, e).toString() }
def dn = {n, e-> decodeNumber(n, e).toString() }
performTest("list", tests, getEncoder(), getEncoder(), en, dn)
@ctoestreich
ctoestreich / gist:1383020
Created November 21, 2011 15:50
GrailsDomainHasToStringAstVisitor
/*
* Copyright 2011 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@ctoestreich
ctoestreich / gist:1383023
Created November 21, 2011 15:50
GrailsDomainHasEqualsAstVisitor
/*
* Copyright 2011 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
def serviceSoapTest = {
String addBusinessPartner = "", helloWorld = ""
Boolean isConnected = false, isAlive = false, addBP = false
GetDataTableResult getDataTableResult = null
Exception soapServiceException = null
Address address = new Address(address1: "22575 Highway 6 South", address2: "Navasota, Texas", postalCode: "77868")
BusinessPartner businessPartner = new BusinessPartner(cardCode: "C00570",
cardName: "Select Sires",
groupCode: 1,
<g:if test="${isAlive && isConnected}">
<BR><BR>
<span style="font-weight: bold;">Is Alive:</span><span class="name">${isAlive}</span><BR>
<span style="font-weight: bold;">Connected B1:</span> <span class="name">${isConnected}</span><BR>
<span style="font-weight: bold;">Hello World:</span><span class="name">${helloWorld}</span><BR>
<span style="font-weight: bold;">GetDataTableResult:</span><span class="name">${getDataTableResult}</span><BR>
%{--<span style="font-weight: bold;">Add BP1:</span><span class="name">${addBP1?.getProperties().values()}</span><BR>--}%
<span style="font-weight: bold;">Soap Service Exception</span><span class="name">${soapServiceException}</span><BR>
</g:if>
@ctoestreich
ctoestreich / gist:1430847
Created December 4, 2011 18:03
Redis Json Cache
@Grapes([
@Grab('redis.clients:jedis:1.5.1'),
@GrabConfig(systemClassLoader = true)
])
import redis.clients.jedis.*
import groovy.json.JsonBuilder
import groovy.json.JsonSlurper
import groovy.transform.EqualsAndHashCode
@ctoestreich
ctoestreich / GenerateDocs.groovy
Created February 24, 2012 18:29
Grails Docs Helper Script
includeTargets << grailsScript("_GrailsDocs")
target(main: "Copy controllers, services, domain and views from svn excluded grails-app dirs to the answers dir and create gdoc from them in ref sidebar") {
//make sure they all compile
depends(compile)
//closure to include or exclude certain file types
def filesetToInclude = {directory ->
fileset(dir: directory) {
include(name: '**/*.groovy')
@ctoestreich
ctoestreich / Gruntfile.coffee
Last active December 16, 2015 09:29
Gruntfile coffeescript
gruntFunction = (grunt) ->
gruntConfig =
coffee:
app:
src: ["js/**/*.coffee"]
options:
bare: true
preserve_dirs: true
testjs: