Skip to content

Instantly share code, notes, and snippets.

View timyates's full-sized avatar

Tim Yates timyates

  • Manchester, UK
View GitHub Profile
#!/usr/bin/env groovy
// Trying it in Groovy as a shell script (just for fun)
import java.util.regex.Pattern
// All folders on the path which have contents:
path = System.env[ 'PATH' ]
.tokenize( File.pathSeparator )
.collect( { new File( it ) } )
// When this script it run, try typing some text into the textfield with
// spaces in it. Then click the button (it will print out the value in
// the backing model -- which is right), but the textField has the wrong
// value in it
import java.beans.*
import java.awt.BorderLayout as BL
import groovy.beans.Vetoable
import groovy.beans.Bindable
import groovy.swing.SwingBuilder
// This in BootStrap.groovy
class BootStrap {
def dataService
def init = { servletContext ->
dataService.initBeans()
}
def destroy = {
}
; Amaturish Clojure version of uniprot mapping function by @sjcockell
; http://blog.fuzzierlogic.com/archives/339
; http://gist.github.com/329730
(ns uniprot
(:use clojure.contrib.duck-streams)
(:import java.net.URLEncoder))
(defn- url-encode
"Passes a String through java.net.URLEncoder.encode"
[ param ] (URLEncoder/encode param))
(ns user)
(defn- reverse-base [base]
(let [mapping { :A \T :T \A :G \C :C \G }
key (keyword (.toString base))]
(key mapping)))
(defn reverse-complement [sequence]
(let [rev-seq (reverse (.toUpperCase sequence))]
(map reverse-base rev-seq)))
; The "are you thinking of an animal" game from over 2 decades ago, but in clojure
; Tim Yates
; v0.1
; Not sure if storing the brain as a load of refs is the most ideomatic way of doing things
; Also, one of my first full bits of clojure, so might not be the most sensible way of doing
; any of it
(function( $ ) {
var defaults = {
image : 'water.png',
damping : 4,
dripSize : 9,
dripDepth : 250
};
var options ;
var canvas ;
var top = 0 ;
@timyates
timyates / hawtDispatch_customDispatchSource.groovy
Created January 24, 2011 10:59
Playing around with HawtDispatch examples in Groovy
@Grab( 'org.fusesource.hawtdispatch:hawtdispatch:1.1' )
import org.fusesource.hawtdispatch.*
import static org.fusesource.hawtdispatch.Dispatch.*
import java.util.concurrent.Semaphore
done = new Semaphore( 1 - ( 1000 * 1000 ) )
queue = createQueue()
source = createSource EventAggregators.INTEGER_ADD, queue
@timyates
timyates / phone.groovy
Created July 27, 2011 10:44
Phone Number coding problem in Groovy
// Numerics to chars they represent
def mnemonics = [
'2': 'ABC',
'3': 'DEF',
'4': 'GHI',
'5': 'JKL',
'6': 'MNO',
'7': 'PQRS',
'8': 'TUV',
'9': 'WXYZ'
@timyates
timyates / scanner.groovy
Created August 16, 2011 12:11
Run CodeNarc over the code blocks on the groovy user-guide webpages
@Grab(group='org.codenarc', module='CodeNarc', version='0.15')
@Grab(group='net.sourceforge.nekohtml', module='nekohtml', version='1.9.15')
import org.codenarc.AnalysisContext
import org.codenarc.CodeNarc
import org.codenarc.CodeNarcRunner
import org.codenarc.analyzer.SourceAnalyzer
import org.codenarc.analyzer.StringSourceAnalyzer
import org.codenarc.report.TextReportWriter
import org.codenarc.ruleset.PropertiesFileRuleSetConfigurer
import org.codenarc.results.Results