Skip to content

Instantly share code, notes, and snippets.

View tlberglund's full-sized avatar

Tim Berglund tlberglund

  • StarTree
  • Mountain View CA
View GitHub Profile
// code sample:
//
// multiply by 2 the row identifier
// output_row.id = input_row.id * 2;
//
// lowercase the name
// output_row.name = input_row.name.toLowerCase();
java.util.Calendar cal = java.util.Calendar.getInstance();
cal.setTime(input_row.ordered_at);
task('test-script', dependsOn: 'compileGroovy') << {
description = 'Runs a script in the context of the project'
ant.java(classname: 'com.augusttechgroup.somecode.script') {
classpath {
pathelement(path: sourceSets.main.classesDir)
sourceSets.main.runtimeClasspath.each { jarPath ->
pathelement(location: jarPath)
}
}
}
package com.augusttechgroup.somecode
println "This will run from Gradle,
and will have all the project's runtime
JARs and classes ripe for the picking"""
@tlberglund
tlberglund / gist:727496
Created December 3, 2010 20:21
Liquibase Workshop ChangeSet of Doom
<createTable tableName="contact">
<column name="id" type="bigint">
<constraints primaryKey="true"
nullable="false"
autoIncrement="true"/>
</column>
<column name="first_name" type="varchar(50)" />
<column name="middle_initial" type="varchar(5)" />
<column name="last_name" type="varchar(50)" />
<column name="gender" type="varchar(50)" />
<createTable tableName="contact">
<column name="id" type="bigint" autoIncrement="true">
<constraints primaryKey="true"
nullable="false" />
</column>
<column name="first_name" type="varchar(50)" />
<column name="middle_initial" type="varchar(5)" />
<column name="last_name" type="varchar(50)" />
<column name="gender" type="varchar(50)" />
<column name="email_address" type="varchar(100)" />
<createTable tableName="contact">
<column name="id" type="bigint" autoIncrement="true">
<constraints primaryKey="true"
nullable="false" />
</column>
<column name="first_name" type="varchar(50)" />
<column name="middle_initial" type="varchar(5)" />
<column name="last_name" type="varchar(50)" />
<column name="gender" type="varchar(50)" />
<column name="email_address" type="varchar(100)" />
@tlberglund
tlberglund / git-blob-list
Created January 29, 2011 22:00
A Git script to list all blobs by hash and size in an unpacked repo.
#!/usr/bin/env groovy
def objectDirs = []
new File('.git/objects').eachDir { dir ->
if(dir.name.split('/')[-1] ==~ /[0-9a-f]{2}/) {
objectDirs << dir.absolutePath
}
}
def hashes = []
@tlberglund
tlberglund / git-blob-list.rb
Created January 31, 2011 13:11
A Git script to list objects by size in an unpacked repo.
#!/usr/bin/env ruby
class GitObject
attr_reader :git_type, :hash, :size
def initialize(hash, git_type, size)
@hash = hash
@git_type = git_type
@size = size
end
task monkey(type: DefaultTask)
monkey.configure {
emotion = 'angry'
}
monkey.doLast {
println "The monkey is ${emotion}"
}
apply plugin: 'groovy'
import org.gradle.examples.liquibase.LiquibaseTask
import org.gradle.examples.liquibase.ChangeLogConverter
buildscript {
repositories {
mavenCentral()
}