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
package com.lavector.concurrency; | |
import java.util.concurrent.*; | |
/** | |
* @author seveniu | |
* @date 2017-01-09 | |
* @Description | |
*/ | |
public class BoundedExecutor { |
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
public static void testRefresh() throws ExecutionException, InterruptedException { | |
LogTime logTime = new LogTime(); | |
AtomicInteger value = new AtomicInteger(); | |
LoadingCache<String, String> cb = CacheBuilder.newBuilder() | |
.maximumSize(1000) | |
.refreshAfterWrite(6, TimeUnit.SECONDS) | |
.removalListener((RemovalListener<String, String>) notification -> { | |
logTime.log("remove key : " + notification.getKey() + ", value : " + notification.getValue() + ", cause " + notification.getCause()); | |
}) | |
.build(new CacheLoader<String, String>() { |
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
# | |
# MongoDB Dockerfile | |
# | |
# https://github.com/dockerfile/mongodb | |
# | |
# Pull base image. | |
FROM ubuntu:14.04 | |
# Install MongoDB. |
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
InputStream in = getClass().getClassLoader().getResourceAsStream("ParseResult.groovy"); | |
BufferedReader reader = new BufferedReader(new InputStreamReader(in)); | |
StringBuilder builder = new StringBuilder(); | |
String aux = ""; | |
while ((aux = reader.readLine()) != null) { | |
builder.append(aux); | |
} | |
String text = builder.toString(); |
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
var fs = require('fs'); | |
var filePath = process.argv[2]; | |
fs.readFile(filePath, {encoding: 'utf-8'}, function(err,data){ | |
if (!err){ | |
console.log('received data: ' + data); | |
}else{ | |
console.log(err); |
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 ListToTree(data,deep,getChildren) { | |
this.stackListLength = deep -1-1; //不包含 root | |
this.stackList = []; | |
// 初始化 root | |
this.root = {id: 0}; | |
// 初始化 栈 |
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
#!/bin/bash | |
######## eg. | |
#./run.sh mysql-test password /home/java/conf-files/mysql 3306 official/mysql:5.7 /data/mysql/test/ | |
######## | |
name=$1 | |
password=$2 | |
confDir=$3 | |
port=$4 |
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
[ | |
{ | |
"id": 1, | |
"value": "AD", | |
"zh": "安道尔共和国", | |
"en": "Andorra", | |
"py": "andaoergongheguo", | |
"pyf": "adeghg" | |
}, | |
{ |
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
var util = { | |
getDomain:function (url) { | |
var a = document.createElement('a'); | |
a.href = url; | |
return a.hostname; | |
}, | |
isNumber:function (n) { | |
return !isNaN(parseFloat(n)) && isFinite(n); |
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
public static String xorString(String text,String key) { | |
byte[] textBytes = text.getBytes(); | |
byte[] keyBytes = key.getBytes(); | |
byte[] newCharArray = new byte[textBytes.length]; | |
for (int i = 0; i < textBytes.length; i++) { | |
byte c = textBytes[i]; | |
int strIndex = i%(keyBytes.length); | |
newCharArray[i] = (byte)(c ^ keyBytes[strIndex]); | |
} | |
return new String(newCharArray); |
NewerOlder