Friday, September 14, 2012

IPTools

All IP tools (ping, traceroute, reverse dna lookup, IP routing, resolve host etc.) at a single place
http://www.iptools.com/

Monday, September 10, 2012

Groovy Tip: append list

Groovy provides plus method to append a new list to an existing list at a specified index

public List plus(int index, List additions)
e.g.
def items = [1, 2, 3]
def newItems = items.plus(2, 'a'..'c')
will result in [1, 2, 'a', 'b', 'c', 3]

Tuesday, September 4, 2012

Tip: Dynamically execute a groovy script



You can execute a dynamically generated groovy script or a script stored in a text file or variable using GroovyShell. See example below


def script = ''' def x = 'my dynamically' def y = ' executed script' return x << y ''' def shell = new GroovyShell() def result = shell.evaluate(script) println result
The above script would print "my dynamically executed script" If you want to pass variable to your script, you can make use of binding variables. See below

def script = ''' def code1 = """${crypto.code1}""" def code2 = """${crypto.code2}""" return code1 << ' ' << code2 ''' def crypto = [code1:'my dynamically',code2:'executed script'] def shell = new GroovyShell( new Binding(crypto:crypto) ) def result = shell.evaluate(script) println result
For those who are new to groovy operator << is for creating StringBuffer