Skip to content

Instantly share code, notes, and snippets.

@kkfnui
kkfnui / wechat.py
Last active July 15, 2018 10:24
企业微信报警 python 脚本
# coding = utf-8
import urllib2
import copy
import time
import json
import sys
import getopt
# 下面的 corpid 和 corpsecret 需要从企业微信中获取
ACCESS_TOKEN_URL = "https://qyapi.weixin.qq.com/cgi-bin/gettoken?corpid=TEST&corpsecret=TEST"
package com.huihui.stat;
import io.prometheus.client.CollectorRegistry;
import io.prometheus.client.Counter;
import io.prometheus.client.Histogram;
import io.prometheus.client.exporter.PushGateway;
import java.io.IOException;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
@kkfnui
kkfnui / HelloInterface.java
Created September 9, 2016 11:11
封装json请求接口,方便业务开发
package com.xunlei;
/**
* Created by lvfei on 16/9/9.
*/
@Path("/test")
public class HelloInterface {
@Name("id")
@kkfnui
kkfnui / ParseTest.java
Created August 1, 2016 09:35
ssdb 客户端性能测试
import redis.clients.jedis.exceptions.JedisConnectionException;
/**
* Created by lvfei on 16/8/1.
*/
public class ParseTest {
public static void main(String[] args) {
byte[] buf = {'2', '0', '0', '0'};
@kkfnui
kkfnui / randomTake.java
Created January 21, 2016 08:59
随机取数,越前的概率越高
public static void main(String[] args) {
int[] array = new int[100];
for (int j = 0; j < 20000; j++) {
int count = 0;
for (int i = 0; i < 100; i++) {
int index = (int) ((Math.random() * 10000) % 1000);
if (index < 400 - (count * 40) + i * 2) {
count++;
array[i]++;
if (count > 8){
<build>
<plugins>
<!-- The configuration of maven-jar-plugin -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.4</version>
<!-- The configuration of the plugin -->
<configuration>
<!-- Configuration of the archiver -->
private final static class Bucket
implements java.io.Serializable
{
private static final long serialVersionUID = 1L;
public final Bucket next;
public final String key;
public final SettableBeanProperty value;
/**
@kkfnui
kkfnui / adb_tcpdump.sh
Created November 2, 2014 15:01
Mac 上抓去android手机数据包
/data/local/tcpdump -s 0 -w - | busybox nc -l -p 11233
ls | grep build_x86.sh | rm -rf
@kkfnui
kkfnui / HandlerHeader
Created May 18, 2014 13:08
展示使用一个Operation HandleRecvHeader时复杂的细节处理
void HandleHeader(AsynIoOperation *pOperation)
{
if (SUCCESS == result)
{
if (!isContainBody)
{
Reset(pOperation)
if (!allDataRecved)
{
DoRecvData(pOperation);