Skip to content

Instantly share code, notes, and snippets.

View sdhjl2000's full-sized avatar
🎯
Focusing

jason hu sdhjl2000

🎯
Focusing
View GitHub Profile
@sdhjl2000
sdhjl2000 / .java
Created September 19, 2018 00:05
CompletableFuture
public class CompletableFutureParallel {
private static final int CORE_POOL_SIZE = 4;
private static final int MAX_POOL_SIZE = 12;
private static final long KEEP_ALIVE_TIME = 5 L;
private final static int QUEUE_SIZE = 1600;
protected final static ExecutorService THREAD_POOL = new ThreadPoolExecutor(CORE_POOL_SIZE, MAX_POOL_SIZE, KEEP_ALIVE_TIME, TimeUnit.SECONDS, new LinkedBlockingQueue < > (QUEUE_SIZE));
public static void main(String[] args) throws InterruptedException, ExecutionException, TimeoutException {
OrderInfo orderInfo = new OrderInfo(); //CompletableFuture 的List
List < CompletableFuture > futures = new ArrayList < > ();
futures.add(CompletableFuture.runAsync(() - > {
Cache<Integer,byte[]> cache= CacheBuilder.newBuilder().maximumSize(1000).build();
for (int i = 0; i < Integer.MAX_VALUE; i++) {
byte[] by=new byte[100000];
cache.put(i,by);
Thread.sleep(10);
}
int str= System.in.read();
System.out.print(str);
}
@sdhjl2000
sdhjl2000 / fetchAllProperties.java
Created November 9, 2017 00:44
fetchAllProperties
private Properties fetchAllProperties() {
final Properties properties = new Properties();
for (Iterator it = ((AbstractEnvironment) environment).getPropertySources().iterator(); it.hasNext(); ) {
PropertySource propertySource = (PropertySource) it.next();
if (propertySource instanceof EnumerablePropertySource) {
for (String key : ((EnumerablePropertySource) propertySource).getPropertyNames()) {
properties.put(key, propertySource.getProperty(key));
}
}
if (propertySource instanceof PropertiesPropertySource) {
@sdhjl2000
sdhjl2000 / ExtClasspathLoader.java
Created November 9, 2017 00:42
ExtClasspathLoader
package cn.com.duibaboot.ext.autoconfigure.perftest;
/**
* Created by hujinliang on 2017/11/6.
*/
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
@sdhjl2000
sdhjl2000 / redis
Created November 1, 2017 03:50
redis method
return named("zcount").or(named("sunionstore")).or(named("zunionstore"))
.or(named("del")).or(named("zinterstore")).or(named("echo"))
.or(named("hscan")).or(named("psubscribe")).or(named("type"))
.or(named("sinterstore")).or(named("setex")).or(named("zlexcount"))
.or(named("brpoplpush")).or(named("bitcount")).or(named("llen"))
.or(named("zscan")).or(named("lpushx")).or(named("bitpos"))
.or(named("setnx")).or(named("hvals")).or(named("evalsha"))
.or(named("substr")).or(named("geodist")).or(named("zrangeByLex"))
.or(named("geoadd")).or(named("expire")).or(named("bitop"))
.or(named("zrangeByScore")).or(named("smove")).or(named("lset"))
/**
* 拦截redisclient,可以自动把压测流量导入影子库。
*/
@Configuration
@ConditionalOnResource(resources = "/autoconfig/perftest.properties")
@ConditionalOnClass({RedisClient.class, TransmittableThreadLocal.class})
public static class RedisClientConfigurer {
private volatile Class<?> lastJedisConnectionProxyClass;
private static final Logger logger = LoggerFactory.getLogger(RedisClientConfigurer.class);
@sdhjl2000
sdhjl2000 / mongodb_setting_up_a_replica_set.md
Last active September 11, 2015 10:16 — forked from leommoore/mongodb_setting_up_a_replica_set.md
MongoDB - Setting up a Replica Set

#MongoDB - Setting up a Replica Set

cd \mongodbdir\

mkdir db1
mkdir db2
mkdir db3

###Primary mongod --dbpath ./db1 --port 30000 --replSet "demo"

@sdhjl2000
sdhjl2000 / .go
Created August 19, 2015 10:11
golang new obj
package main
import (
"fmt"
"reflect"
)
type Config struct {
Name string
Meta struct {
@sdhjl2000
sdhjl2000 / centos安装shadowsocks.md
Last active August 29, 2015 14:25
centos安装shadowsocks
@sdhjl2000
sdhjl2000 / gist:1c6a43656037735fdc32
Last active August 29, 2015 14:25
centos 6.X 安装tesseract进行图像识别

这两天在使用pillow完成图像识别的一个小任务,mac上配置起来还算方便,但是再centos服务器配置的时候遇到一些麻烦,记录下来

方案1:http://pkgs.org/download/tesseract,安装后和训练数据(https://code.google.com/p/tesseract-ocr/downloads/list)无法正常使用,提示actual_tessdata_num_entries <= TESSDATA_NUM_ENTRIES:Error:Assert failed:in file ..\ccutil\tessdatamanager.cpp,官方说法是训练文件不对应,但是安装了三个版本的tesseract都不行

方案2:手动安装,请参考https://www.simpleservers.co.uk/clients/whmcs/knowledgebase/600/Install-Tesseract-OCR-libs-from-sources-in-Centos.html

方案3:使用PUIAS_6_computational源

$ vim /etc/yum.repos.d/puias-computational.repo 粘贴: