Skip to content

Instantly share code, notes, and snippets.

View arganzheng's full-sized avatar

arganzheng arganzheng

View GitHub Profile
@arganzheng
arganzheng / PoolingHttpClient
Created June 18, 2015 02:35
An HttpClient with PoolingHttpClientConnectionManager
package org.opentsdb.client;
import static com.google.common.base.Preconditions.checkArgument;
import java.io.IOException;
import java.util.concurrent.TimeUnit;
import org.apache.commons.lang.StringUtils;
import org.apache.http.HeaderElement;
import org.apache.http.HeaderElementIterator;

如何提高消息系统吞吐量

  1. should not block while processing a message
  2. prefer immutable message
  3. batch and piggy(捎带)
  4. avoid polling, try callback notify
  5. cache,但是要注意数据同步更新问题
@arganzheng
arganzheng / index.html
Last active October 15, 2018 03:05
使用bootstrap进行复杂页面布局
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>My Blog</title>
<link rel="stylesheet" type="text/css" href="bootstrap/css/bootstrap.css">
</head>
<body>
<div class="container">
@arganzheng
arganzheng / 开放平台鉴权学习.md
Last active November 28, 2017 16:07
开放平台点滴积累

鉴权学习

对于一个API请求,开发平台一般需要知道下面几件事情:

  1. 哪个应用发起这个请求(Which application is making the request)
  2. 这个请求是为哪个用户发起的(Which user the request is posting on behalf of)
  3. 用户是否对这个请求进行授权(Whether the user has granted the application authorization to post on the user's behalf)
  4. 请求是否在传输过程中被篡改(Whether the request has been tampered by a third party while in transit)
title layout
protocal-buffers学习笔记
post

产生背景(Why Google Invent PB)

在官方文档上 A bit of history 介绍了PB的产生原因。

鹏城放生组2013年12月1号(星期日)放生公告

放生时间: 2013年12月1号(星期日)上午9点30分举行放生。 集合地点:当天9点正在深圳市大鹏新区大鹏银滩大道金水湾渡假村大门口标有“金水湾”字样的指示牌处集合。 开车前往的师兄导航大鹏银滩大道金水湾渡假村;乘坐公交车的师兄可选择:一是坐E11.H92或833.818到大鹏站下车后转乘b756到鹏城挢站下车,反方向步行至红绿灯左拐入银滩大道再走10分钟到金水湾度假村;二是坐E11.H92或833.818到大鹏站下车后,再在大鹏二站坐928到金水湾度假村站下车(928公交相隔20分钟一班,上车时请吩咐驾驶员到站让下。 欢迎随喜参加,功德无量。 放生随喜帐号: 中国银行,账号6216612000005457219,户名:欧阳权

@arganzheng
arganzheng / JavaNioStudy.java
Created November 22, 2013 06:51
Java NIO study Selector Channel select
import java.io.IOException;
import java.net.InetSocketAddress;
import java.nio.channels.ClosedChannelException;
import java.nio.channels.SelectableChannel;
import java.nio.channels.SelectionKey;
import java.nio.channels.Selector;
import java.nio.channels.SocketChannel;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;

优雅的builder模式

public class NetworkUpdatesService{

	public void getNetworkUpdatesSummary(){
		UpdateQueryCriteria query = UpdateQueryCriteria.createDefaultCriteria()
				.setMemberID(2)
				.setRequestdTypes(NetworkUpdateType.CONNECTION)

.setCutoffDate(...)

import java.lang.Thread.UncaughtExceptionHandler; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.ThreadFactory;

/**

  • @ClassName: ExceptionThread
  • @Description: TODO(这里用一句话描述这个类的作用)
  • @date 2013-10-10 下午12:04:23 */