TODO: Fill in the problem statement
#!/bin/bash | |
# --------------------------------------------------------- | |
# Customizable Settings | |
# --------------------------------------------------------- | |
MOUNT_POINT="${CASE_SAFE_MOUNT_POINT:-${HOME}/casesafe}" | |
VOLUME_PATH="${CASE_SAFE_VOLUME_PATH:-${HOME}/.casesafe.dmg.sparseimage}" | |
VOLUME_NAME="${CASE_SAFE_VOLUME_NAME:-casesafe}" | |
VOLUME_SIZE="${CASE_SAFE_VOLUME_SIZE:-60g}" |
Object.metaClass.ensureClosed = { Closure c -> | |
try { | |
c( delegate ) | |
} | |
finally { | |
[ delegate ].flatten().each { | |
if( it.respondsTo( 'close' ) ) { | |
it.close() | |
} | |
} |
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 -> |
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 |
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 |
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 |
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() } }
First,
hg clone http://bitbucket.org/durin42/hg-git HGGIT_PATH
Second, in "mercurial.ini" add:
[extensions]
hggit=HGGIT_PATH\hggit
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