Skip to content

Instantly share code, notes, and snippets.

View ChinaXing's full-sized avatar
🤣
I may be slow to respond.

chinaxing ChinaXing

🤣
I may be slow to respond.
View GitHub Profile
@ChinaXing
ChinaXing / kill-connection.pl
Created January 4, 2016 09:53
kill tcp connection
use Net::RawIP;
$n = Net::RawIP->new({
ip => {
saddr => '10.200.183.2',
daddr => '10.200.180.30'
},
tcp => {
source => 3317,
dest => $ARGV[0],
@ChinaXing
ChinaXing / parallel.sh
Last active August 29, 2015 14:26
parallel run command on cluster
parallel -j 4 --nonall -S1/svr_portal_web{1..4} \
tail /home/admin/portalweb-deploy/logs/web_access.log.2015-08-04
@ChinaXing
ChinaXing / SpecifyHttpConnectionLocalAddress.java
Last active August 29, 2015 14:24
创建http请求的时候指定客户端IP
import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.util.EntityUtils;
import org.testng.annotations.Test;
import java.net.*;
@ChinaXing
ChinaXing / graph-fibonacci.hs
Last active August 29, 2015 14:22
make fibonacci graphviz dot file
import Debug.Trace
import System.Environment
import System.IO
newtype S a = S (Int, a) deriving (Show)
fib' :: S Int -> Int
fib' (S (s, 0)) = trace (show s ++ " [ label = " ++ show 0 ++ "]") 1
fib' (S (s, 1)) = trace (show s ++ " [ label = " ++ show 1 ++ "]") 1
fib' (S (s, n)) = trace (show s ++ " [label = " ++ show n ++ "]") f1 + f2
where
-------------------------------------------------------------------------------------
-- Internal function
-------------------------------------------------------------------------------------
function delete_by_wild (red, wild)
local result, err = red:keys(wild)
if not result then
ngx.say("failed to get keys : " .. wild .. ", reason :", err)
return nil
end
for i, k in ipairs(result) do
@ChinaXing
ChinaXing / TestCSP.java
Created April 3, 2015 16:52
message passing like channel use object monitor
package com.witown.probe.stream.storm;
import org.junit.Test;
import sun.awt.windows.ThemeReader;
/**
* Created by LambdaCat on 15/4/4.
*/
public class TestCSP {
private static Integer x = 0;
@ChinaXing
ChinaXing / mvn-pkg-dependency.sh
Created April 3, 2015 03:44
maven show package's backwards dependencies
mvn dependency:tree -Dverbose -Dincludes=commons-collections
@ChinaXing
ChinaXing / md5-hex-string.erl
Created March 27, 2015 07:12
erlang-md5-hex-string
get_md5_hex_str(Str) ->
X = erlang:md5(Str),
[begin if N < 10 -> 48 + N; true -> 87 + N end end || <<N:4>> <= X].
@ChinaXing
ChinaXing / rt.sh
Created March 20, 2015 06:27
calculator the RT from netty log, use bash
!/bin/bash
# ******************************************
#
# A function which calculator the Rt of log
#
# ******************************************
function getEpochMillionSecond
{
ret=$(date +%s%N -d "$1" | cut -b -13)