Skip to content

Instantly share code, notes, and snippets.

View joshareed's full-sized avatar

Josh Reed joshareed

View GitHub Profile
@joshareed
joshareed / gist:1107973
Created July 26, 2011 20:48
Log output
2011-07-26 16:47:50,809 [TP-Processor25] DEBUG facebook.FacebookController - params: [id:660, action:challenge, controller:facebook]
2011-07-26 16:47:50,812 [TP-Processor25] ERROR util.FacebookHelperService - Couldn't tokenize signedRequest: null
2011-07-26 16:47:50,813 [TP-Processor25] DEBUG facebook.FacebookController - signed request: [:]
2011-07-26 16:47:50,814 [TP-Processor25] DEBUG facebook.FacebookController - person: null person.id: null uid: null pid: null isPageAdmin: null
List.metaClass.safeFirst = { -> delegate[0] }
List.metaClass.safeLast = { -> delegate.size() > 0 ? delegate[-1] : null }
def a = []
assert null == a.safeFirst()
assert null == a.safeLast()
a += [1,2]
assert 1 == a.safeFirst()
assert 2 == a.safeLast()
def dir = new File(args.length > 0 ? args[0] : "/Users/josh/Desktop/image")
def fps = args.length > 1 ? args[1] as int : 10
def parser = new java.text.SimpleDateFormat(args.length > 2 ? args[2] : "yyyy_MM_dd_-_hh_mm_ss.SSS")
def formatter = new java.text.SimpleDateFormat("hh:mm:ss")
// find all image files and sort them by the date encoded in the filename
def files = [:] as TreeMap
dir.eachFileMatch(~/.*\.jpg/) { file ->
def date = parser.parse(file.name - "_UTF.jpg")
files[date.time] = file
if (condition)
statement
else {
statement
statement
}
class Person {
String firstName
String lastName
transient getFullName() { "${firstName} ${lastName}" }
}