Skip to content

Instantly share code, notes, and snippets.

View sunxboy's full-sized avatar
🎯
Focusing

Sun Xianbing sunxboy

🎯
Focusing
View GitHub Profile

ctrl+shift+p

  • 安装 vscode-go 插件:
> ext install Go
  • 安装 go tools:
> Go Install/Update Tools
@sunxboy
sunxboy / java 8 stream filter remove
Created August 21, 2018 02:27
java8 collection filter
private void cleanDeadData(List<BcpResend> list) {
java.util.Set<String> grupingThanFilter =
list.stream().collect(Collectors.collectingAndThen(Collectors.groupingBy(BcpResend::getCid, Collectors.counting()), map -> {
map.values().removeIf(l -> l < 50);
return map.keySet();
}));
grupingThanFilter.forEach(cid -> {
repository.deleteByCid(cid);
});
}
@sunxboy
sunxboy / file read junit
Created August 11, 2018 09:38
java test file read all lines
private String readFirstLine(String filename) throws IOException {
return Files.readFirstLine(new File(Resources.getResource(filename).getFile()), StandardCharsets.UTF_8);
}
@sunxboy
sunxboy / gist:fd9622070b6ccbbd7ade69cac119a79d
Created August 11, 2018 07:54
bash shell get pid only
ps -ef | awk '/[a]zkaban.jobid=234719041867038727/{print $2}'
ImmutableMap.<String, String>builder()
.put("name", r.name())
.put("description", r.getDescription())
.build()
@sunxboy
sunxboy / gist:a783ceaaf82769d8205cfabee2770b19
Created August 10, 2018 06:37
java8 每100行读取文件
split(Paths.get("file"), 100).forEach(this::sendRequest);
void sendRequest(List<String> each) {
// then you must send the rest request in parallel here
}
Stream<List<String>> split(Path path, int limit) throws IOException {
// skip the remaining lines if its size < limit
return split(Files.lines(path), limit, true);
}
@sunxboy
sunxboy / mybatis
Created August 1, 2018 02:48
mybatis 分页
<plugins>
<!-- com.github.pagehelper为PageHelper类所在包名 -->
<plugin interceptor="com.github.pagehelper.PageInterceptor">
<!-- 使用下面的方式配置参数,后面会有所有的参数介绍 -->
<property name="supportMethodsArguments" value="true"/>
<property name="params" value="pageNum=pageNumKey;pageSize=pageSizeKey;"/>
</plugin>
</plugins>
List<Country> selectByPageNumSize(
@sunxboy
sunxboy / mytatis
Created July 26, 2018 10:26
mybatis junit test
# mybatis-config.xml
<configuration>
<mapper>
<mapper resource="mybatis-cfg/TaskMapper.xml"/>
</mapper>
</configuration>
#spring-config.xml
<context:annotation-config />
<tx:annotation-driven/>
@sunxboy
sunxboy / java
Created July 21, 2018 01:04
spring mvc upload file
@requestMapping(value="/upload",mmethod=requestMethod.post)
public ImportResult uploadCsv(@RequestParam("file") MultipartFile multipartFile) {
}
/**
* 百度坐标(BD09)、国测局坐标(火星坐标,GCJ02)、和WGS84坐标系之间的转换的工具
*
* 参考 https://github.com/wandergis/coordtransform 实现的Java版本
* @author geosmart
*/
public class CoordinateTransformUtil {
static double x_pi = 3.14159265358979324 * 3000.0 / 180.0;
// π
static double pi = 3.1415926535897932384626;