Skip to content

Instantly share code, notes, and snippets.

View cdeszaq's full-sized avatar
💭
Doing a little wiring...

Rick Jensen cdeszaq

💭
Doing a little wiring...
View GitHub Profile
package com.github.robfletcher.grails.validation
import org.codehaus.groovy.grails.validation.AbstractConstraint
import org.springframework.validation.Errors
class AcyclicConstraint extends AbstractConstraint {
static final String DEFAULT_MESSAGE_CODE = "default.acyclic.violation.message"
static final String NAME = "acyclic"
@artero
artero / launch_sublime_from_terminal.markdown
Last active May 15, 2024 03:38 — forked from olivierlacan/launch_sublime_from_terminal.markdown
Launch Sublime Text 2 from the Mac OS X Terminal

Launch Sublime Text 2 from the Mac OS X Terminal

Sublime Text 2 ships with a CLI called subl (why not "sublime", go figure). This utility is hidden in the following folder (assuming you installed Sublime in /Applications like normal folk. If this following line opens Sublime Text for you, then bingo, you're ready.

open /Applications/Sublime\ Text\ 2.app/Contents/SharedSupport/bin/subl

You can find more (official) details about subl here: http://www.sublimetext.com/docs/2/osx_command_line.html

Installation

@akavel
akavel / HOWTO TortoiseHg and Github .markdown
Created January 6, 2012 02:35
TortoiseHg and GitHub.com

Read-only access, in short

First,

hg clone http://bitbucket.org/durin42/hg-git HGGIT_PATH

Second, in "mercurial.ini" add:

[extensions]
hggit=HGGIT_PATH\hggit
@kiy0taka
kiy0taka / tree.md
Created April 24, 2012 09:56 — forked from timyates/tree.md
A one-line tree in Groovy

One line Tree in Groovy

The other day, I saw Harold Cooper's One-line tree in Python via autovivication, and wondered if the same thing was possible in Groovy.

The answer is yes! But you need to define the variable tree before you can assign it to the self-referential withDefault closure, hence with Groovy, it's a two-line solution ;-)

Anyway, given:

def tree = { [:].withDefault{ owner.call() } }
@pledbrook
pledbrook / BootStrap.groovy
Created May 10, 2012 12:52
Embed Vert.x in Grails
import org.vertx.groovy.core.Vertx
class BootStrap {
def init = { servletContext ->
def vertx = Vertx.newVertx()
def httpServer = vertx.createHttpServer()
vertx.createSockJSServer(httpServer).installApp(prefix: '/events') { sock ->
sock.dataHandler { buff ->
sock << buff
@jboner
jboner / latency.txt
Last active July 27, 2024 12:32
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers (~2012)
----------------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD
@Isammoc
Isammoc / .travis.yml
Created July 12, 2012 22:29 — forked from berngp/.travis.yml
Grails Travis YML file
language: java
jdk:
- openjdk7
- oraclejdk7
before_install:
- sudo add-apt-repository -y ppa:groovy-dev/grails
- sudo apt-get update
- sudo apt-get -y install grails-ppa # not sure if necessary
@timyates
timyates / sort.groovy
Created August 10, 2012 14:02
Sort with multiple comparators
List list = [
[id:0, firstName: 'Sachin', lastName: 'Tendulkar', age: 40 ],
[id:1, firstName: 'Sachin', lastName: 'Tendulkar', age: 103 ],
[id:2, firstName: 'Ajay', lastName: 'Tendulkar', age: 48 ],
[id:3, firstName: 'Virendra', lastName: 'Sehwag', age: 5 ],
[id:4, firstName: 'Virendra', lastName: 'Sehwag', age: 50 ],
[id:5, firstName: 'Sachin', lastName: 'Nayyar', age: 15 ]
]
Collection.metaClass.sort = { boolean mutate, Closure... closures ->
@timyates
timyates / ensureClosed.groovy
Created September 11, 2012 12:43
Add an ensureClosed method to Object in Groovy
Object.metaClass.ensureClosed = { Closure c ->
try {
c( delegate )
}
finally {
[ delegate ].flatten().each {
if( it.respondsTo( 'close' ) ) {
it.close()
}
}
@cdeszaq
cdeszaq / Problem.md
Last active December 19, 2015 01:59

TODO: Fill in the problem statement