This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
update t_tree set path = text2ltree(replace( ltree2text(path), 'us.va', 'us.fl') ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def data = new URL(s).text | |
json = slurper.parseText(data) | |
json.response.docs | |
json.highlighting | |
json.facet_counts | |
json.responseHeader.QTime | |
json.response.numFound | |
for (e in docs) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def toStringIp(long l) { | |
return ( (l >> 24) & 0xFF) + "." + ( (l >> 16) & 0xFF) + "." + | |
( (l >> 8) & 0xff) + "." + (l & 0xFF); | |
} | |
def long toLong(String ip) { | |
if (!ip) { | |
return -1 | |
} | |
def octets = ip.split("\\.") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//try | |
def blobFile = new File(fileName) | |
def outStream = new FileOutputStream(blobFile) | |
def blob = (oracle.sql.BLOB) result[0] | |
def inStream = blob.getBinaryStream() | |
int length = -1 | |
int size = blob.getBufferSize() | |
byte[] buffer = new byte[size] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
l = [] | |
l2 = [] | |
def push(def num) { | |
if (l) { | |
l2 << ( (l[l.size() - 1] < num) ? l[l.size() -1] : num ) | |
} else { | |
l2 << num | |
} | |
l << num |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def fibo(x) { | |
if (x < 2) { | |
return x | |
} else { | |
return fibo(x-1) + fibo(x-2) | |
} | |
} | |
println( (1..10).collect { fibo(it) }.join(",") ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
1 | |
1 1 | |
1 2 1 | |
1 3 3 1 | |
1 4 6 4 1 | |
*/ | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def getMax(List list, int max) { | |
/* TODO - error handling null values etc */ | |
if (list.size() == 1) { | |
return (list[0] > max) ? list[0] : max | |
} else if ( list[0] > max) { | |
getMax(list[1..-1], list[0]) | |
} else { | |
getMax(list[1..-1], max) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.concurrent.CountDownLatch | |
class MyRunnable implements Runnable { | |
def myParam, latch | |
public MyRunnable(String myParam, CountDownLatch latch){ | |
this.myParam = myParam; | |
this.latch = latch | |
} | |
public void run(){ | |
try { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
write out data to excel spreadsheet | |
*/ | |
static def writeExcel(ouputstream, headers, rows, cell_sizes) { | |
def workbook = Workbook.createWorkbook(outputstream) | |
WriteableSheet sheet = workbook.createSheet("R", 0) | |
for (e in cell_sizes) { | |
sheet.setColumnView(Integer.pareseInt(e.key), Integer.parseInt(e.value) ) | |
} |