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
.setParam('facet.pivot', 'one,two') | |
org.apache.solr.common.util.NamedList pivots = resp?.response?.facet_counts?.facet_pivot | |
def pivot = pivots.get('one,two') | |
def m = ['name':'root'] | |
m['children'] = [] | |
{ | |
def inner_l = [] | |
for (e2 in e.pivot) { | |
inner_l << ['name':"${e2.value}", 'size':e2.count] |
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.net.InetAddress | |
InetAddress ia = InetAddress.getByName("2001:0:4137:9e76:34b7:2e31:3f57:fd9a") | |
def bi = new BigInteger(ia.getAddress()) | |
println bi | |
println InetAddress.getByAddress(bi.toByteArray()) |
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 com.google.common.cache.* | |
import java.util.concurrent.TimeUnit | |
LoadingCache<String, String> mycache = CacheBuilder.newBuilder() | |
.maximumSize(1000) | |
.recordStats() | |
.expireAfterWrite(5, TimeUnit.SECONDS) | |
.build( | |
new CacheLoader<String, String>() { | |
public String load(String key) throws Exception { |
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
function process(result, val, temp_val) { | |
var inner_val = isNaN(val) ? val : [val, val]; | |
if (temp_val.length == 0) { //no temp | |
temp_val = inner_val; | |
} else if ( (inner_val[1] -1) > temp_val[1] ) { //flush temp | |
if (temp_val[0] == temp_val[1]) { | |
result.push(temp_val[0]); | |
} else { | |
result.push(temp_val[0] + '-' + temp_val[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
l = console.log | |
l("\n\nstart:") | |
function merge(left, right){ | |
l("merge: l: " + left + ", r: " + right); | |
var result = [], | |
il = 0, | |
ir = 0; | |
while (il < left.length && ir < right.length){ |
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
log = console.log | |
function node(name, parent, child) { | |
var new_node = { name:name, parent:parent } | |
if (!!child) { | |
new_node.parent[child] = new_node; | |
} | |
return new_node |
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
/* | |
//client | |
import java.io.* | |
import java.net.* | |
def sentence = 'i am testing this' | |
def clientSocket = new Socket("localhost", 6789) | |
try { | |
(new DataOutputStream( |
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
-A INPUT -p tcp -m tcp --dport 80 -m state --state NEW -m recent --set --name DEFAULT --rsource | |
-A INPUT -p tcp -m tcp --dport 80 -m state --state NEW -m recent --update --seconds 5 --hitcount 20 --name DEFAULT --rsource -j DROP |
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
class Counter { | |
int val | |
public Counter() { val = 0; } | |
public /* synchronized */ void increment() { | |
val++ | |
} | |
} | |
def c = new Counter() |
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
$(document).ready(function() { | |
async.waterfall([ | |
function(next){ | |
setTimeout(function() { | |
console.log('in this tImeout'); | |
next(null, 'one', 'two'); | |
}, | |
2000); |