Skip to content

Instantly share code, notes, and snippets.

@bryanchug
bryanchug / steps.sh
Created July 26, 2013 22:37
A script that I use to go through each commit in the branch since the initial commit. I use this when I present a technical talk with code examples or walkthroughs.
#!/bin/bash
for commit in $(git rev-list origin/master | tail -r)
do
git reset --hard $commit
read -p "Press enter to continue..."
done
@bryanchug
bryanchug / gist:7313238
Created November 5, 2013 03:10
Passing in default timezone to MySQL connection via JDBC URL
@Grab(group='mysql', module='mysql-connector-java', version='5.1.6')
@GrabConfig(systemClassLoader = true)
import groovy.sql.Sql
def sql = Sql.newInstance("jdbc:mysql://localhost:3306/noonu?sessionVariables=time_zone='-8:00'", 'root', '', 'com.mysql.jdbc.Driver')
println sql.firstRow("select now()")
def sql2 = Sql.newInstance("jdbc:mysql://localhost:3306/noonu?sessionVariables=time_zone='%2B8:00'", 'root', '', 'com.mysql.jdbc.Driver')
println sql2.firstRow("select now()")
@bryanchug
bryanchug / gist:8432406
Created January 15, 2014 07:55
Grails Migration Script using Groovy SQL to update using named parameters
changeSet(author: "bryanchug", id: "1383792606533-1") {
grailsChange {
change {
sql.executeUpdate('UPDATE user SET name = :name', [name: 'Bryan Chug'])
}
}
}