Skip to content

Instantly share code, notes, and snippets.

View dexterous's full-sized avatar

Saager Mhatre dexterous

View GitHub Profile
@dexterous
dexterous / build.sh
Created May 17, 2014 19:01
Quick script to build build VBox VM from latest SmartOS build
#!/bin/sh
#set -o xtrace
#set -o verbose
#set -o errexit
#set -o errtrace
latest_url="https://us-east.manta.joyent.com/Joyent_Dev/public/SmartOS/latest"
latest=$(curl -s "$latest_url")
echo "Latest build is $latest"
@dexterous
dexterous / Greeter.java
Last active August 29, 2015 14:04
A quick usage sample of the JSR-223 Script interface API
package foo;
public interface Greeter {
String greet();
String greet(String name);
String defaultGreeting();
}
@dexterous
dexterous / .gitignore
Last active August 29, 2015 14:06
A quick US Land usage point map I whipped up using Google Maps JS API, currently hosted at http://us-land-usage-by-state.divshot.io/ .
/.divshot-cache
@dexterous
dexterous / grails-blog
Created February 28, 2011 08:02
minimum steps to create a Grails blog using simple-blog plugin (ignoring SCM commands)
$ grails create-app grails-blog
$ cd grails-blog
$ grails install-plugin simple-blog
$ cat >> grails-app/conf/Config.groovy
> grails.blog.author.evaluator = { request.remoteAddr }
> ^D
$ mkdir -p grails-app/domain/demo/blog/
$ cat > grails-app/domain/demo/blog/Commenter.groovy
> package demo.blog
>
@dexterous
dexterous / proc_expectations.rb
Created February 28, 2011 09:12
various use cases for ruby blocks
require 'rubygems'
require 'expectations'
Expectations do
expect(1){ proc{ |a| a }.call(1) }
expect([1, 2]){ proc{ |a| a }.call(1, 2) }
expect(1){ proc{ |a, b| a }.call(1, 2) }
expect(1){ Proc.new{ |a| a }.call(1) }
@dexterous
dexterous / check_svn_mirror.sh
Created March 3, 2011 05:23
That is one long-ass nagios plugin!
#!/bin/bash
/export/groups/nagios/libexec/check_http -f follow -H $1 -u /trainline -a tlsvn:\!4321abcd -r `/usr/bin/curl -u tlsvn:\!4321abcd -L http://bngsvn01.thoughtworks.co/trainline 2> /dev/null | /bin/sed -ne "/title.*Revision/ { s/.*trainline -Revision \([0-9]\+\):.*/\1/ ; p}"`
@dexterous
dexterous / CategoryGotcha.groovy
Created March 3, 2011 05:28
scoping gotcha with Groovy Categories
def f = new Foo('hello')
assert f.bar() == 'original hello'
use(FooCategory) { assert f.bar() == 'categorical hello' }
class Baz {
def quux(boo) { new Foo(boo).bar() }
}
@dexterous
dexterous / proc_indexer.rb
Created March 3, 2011 14:16
Ohh... my head hurts!
foo = lambda { |x| puts x }
foo.call('Hello, World!')
foo['You can index me too!']
@dexterous
dexterous / anon_blocks.groovy
Created March 3, 2011 14:29
sometimes Groovy just cracks me up!
({ it('ABCD') }) { "${it} and some more" } //=> 'ABCD and some more'
@dexterous
dexterous / BooleanCategory.groovy
Created March 3, 2011 15:04
No more if's; SmallTalk style conditionals in Groovy
class BooleanCategory {
public static Boolean then(Boolean self, Closure c) {
if(self) c()
return self
}
public static Boolean otherwise(Boolean self, Closure c) {
if(!self) c()
return self