Skip to content

Instantly share code, notes, and snippets.

View yangl's full-sized avatar
🎯
Focusing

YANGLiiN yangl

🎯
Focusing
View GitHub Profile
@yangl
yangl / maven-shade-plugin.pom.xml
Last active July 27, 2022 08:38
maven-shade-plugin把强依赖的jar包更改包名并一起打包到自己的jar中,防止依赖冲突,中件间团队必会淫技!http://maven.apache.org/plugins/maven-shade-plugin/index.html
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.3.0</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
@yangl
yangl / RandomStringUtils.txt
Created June 23, 2016 06:35
用16位数字字母随机生成字符串,直接使用org.apache.commons.lang3.RandomStringUtils即可
RandomStringUtils.random(16, "1234567890qwertyuioplkjhgfdsazxcvbnm")
@yangl
yangl / Apns.java
Last active July 3, 2016 03:30
公司apns接口私有协议java实现。Base64算法apache下的commons-codec实现有少许问题,最好使用JDK8原生的实现!
private static final String apns(long uid, int type, String alert, long sn) {
String playload = APNS.newPayload().alertBody(alert).customField("type", type).build();
int length = 13 + 9 + playload.getBytes(CharsetUtil.UTF_8).length;
ByteBuf bf = Unpooled.buffer(length);
bf.writeInt(length)
.writeByte(1)
.writeLong(sn)
.writeLong(uid)
@yangl
yangl / sharding-jdbc.xml
Last active January 14, 2019 06:20
sharding-jdbc配置例子,注意:1.groovy整除是"intdiv()"不是"/";2.groovy三元表达式支持可能不太好,暂时先使用if else;3.ddl语句sjdbc不支持,可使用JdbcTemplate
<!-- bc0 bc1分库分表策略 -->
<!-- 按uid分库:最后两位0-49在bc_0库,50-99在bc_1库 -->
<rdb:strategy id="balanceDatabaseStrategy" sharding-columns="uid"
algorithm-expression="bc_${if(uid.longValue()%100>49){1}else{0}}"/>
<!--algorithm-expression="bc_${uid.longValue()%100>49?1:0}"/>-->
<!-- 按uid%100分表 -->
<rdb:strategy id="balanceTableStrategy" sharding-columns="uid"
algorithm-expression="balance_${uid.longValue() % 100}"/>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.5.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
@yangl
yangl / RSA密钥生成方法.txt
Created July 20, 2016 09:48
RSA密钥生成方法
生成 rsa 私钥
openssl genrsa -out rsaprivatekey.pem 1024
生成对应的公钥
openssl rsa -in rsaprivatekey.pem -pubout -out rsapublickey.pem
将 RSA 私钥转换成 PKCS8 格式
openssl pkcs8 -topk8 -inform PEM -in rsaprivatekey.pem -outform PEM -nocrypt -out rsaprivatepkcs8.pem
@yangl
yangl / zoo.cfg
Created September 17, 2016 13:29
CDH 5.8 zoo.cfg
tickTime=2000
initLimit=10
syncLimit=5
dataDir=/data/cloudera/zookeeper
dataLogDir=/data/cloudera/zookeeper
clientPort=2181
maxClientCnxns=60
minSessionTimeout=4000
maxSessionTimeout=60000
autopurge.purgeInterval=24
@yangl
yangl / Phones2.java
Last active January 12, 2017 03:39
根据ipip.net提供的手机号码归属地生成客户端本地数据文件,供通讯录快速匹配数据,原来数据14.2M压缩后436k
package com.uxin.feerate.util;
import com.google.common.base.Charsets;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
import com.google.common.io.Files;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
@yangl
yangl / 帐户系统密码方案.md
Last active October 17, 2016 03:30
帐户系统密码方案----推荐使用BCrypt或SCrypt来生成密码,不要再使用md5()+salt的方式了

1.引入依赖:

<dependency>
    <groupId>org.springframework.security</groupId>
    <artifactId>spring-security-core</artifactId>
    <version>4.1.3.RELEASE</version>
</dependency>

2.生成密码:

@yangl
yangl / apollo配置中心部署说明.md
Last active November 14, 2016 10:05
apollo配置中心部署说明

1.configservice服务开发环境绑定至公网(由于开发服务器与工作环境不在同一网段): application.yml中的spring结点下添加如下配置(忽略掉不要绑定的网卡)

   spring:
     cloud:
       inetutils:
         ignored-interfaces:
           - lo
 - eth0