Skip to content

Instantly share code, notes, and snippets.

View hengyunabc's full-sized avatar

hengyunabc hengyunabc

View GitHub Profile
@hengyunabc
hengyunabc / gist:c906aa26c213cc74c5dc
Last active November 30, 2015 02:13
可以在匿名类里用{}来进行一些初始化工作,这样子可以避免要写一个构造函数。
scheduleJobManager.addScheduleJob(new ScheduleJobSupport(){
{
this.setInterval(intervalx);
}
@Override
public boolean permitAdd() {
return false;
}
});
package io.github.xdiamond.web.filter;
import java.io.IOException;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
@hengyunabc
hengyunabc / AlertService.js
Created June 1, 2015 03:00
angularjs AlertService.
'use strict';
angular.module('xdiamondApp')
.factory('AlertService', ['$timeout', '$rootScope', function ($timeout, $rootScope) {
var service = {};
var alerts = [];
//all template can use alerts like follow:
//<alert ng-repeat="alert in alerts" type="{{alert.type}}" close="alert.close()">{{ alert.msg }}</alert>
import java.io.IOException;
import java.net.Inet4Address;
import java.net.Inet6Address;
import java.net.InetAddress;
import java.net.NetworkInterface;
import java.net.SocketException;
import java.net.URL;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Enumeration;
@hengyunabc
hengyunabc / zkEnv.sh
Last active August 29, 2015 14:09
Set zookeeper output log to logs. 设置zookeeper输出日志到logs目录的配置
#!/bin/sh
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
@hengyunabc
hengyunabc / gist:d48fbebdb9bddcdf05e9
Last active August 29, 2015 14:03
std::notify_all_at_thread_exit, llvm libc++ implements.
template <class _Fp>
void*
__thread_proxy(void* __vp)
{
__thread_local_data().reset(new __thread_struct);
std::unique_ptr<_Fp> __p(static_cast<_Fp*>(__vp));
(*__p)();
return nullptr;
}
@hengyunabc
hengyunabc / DataLoader.java
Last active August 9, 2019 08:57
Memcached自动刷新快要失效数据的封装,http://blog.csdn.net/hengyunabc/article/details/20735701
public interface DataLoader {
public <T> T load();
}
@hengyunabc
hengyunabc / gist:a4651e90db24cc5ed29a
Last active August 29, 2015 14:02
TrimAllWhitespace Test. Spring StringUtils.trimAllWhitespace() is slow.
public class Test {
static public String myTrimAllWhitespace(String str) {
if (str != null) {
int len = str.length();
if (len > 0) {
StringBuilder sb = new StringBuilder(len);
for (int i = 0; i < len; ++i) {
char c = str.charAt(i);
if (!Character.isWhitespace(c)) {
java -XX:+UseConcMarkSweepGC -XX:+PrintFlagsFinal Main | grep -P "CMSInitiatingOccupancyFraction|CMSTriggerRatio|MinHeapFreeRatio"
@hengyunabc
hengyunabc / TestIdGenenator.java
Created February 16, 2014 10:39
redis全局ID生成脚本的测试程序,注意要使用jedis2.4.0以上。
package com.test;
import java.util.List;
import java.util.Random;
import java.util.concurrent.CountDownLatch;
import org.springframework.util.StopWatch;
import redis.clients.jedis.Jedis;