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
-- 2014-03-28 @yunxing.cyx@
local nodegroup = nil
local siteList = {}
local tmsConfigureFile="/home/admin/confsvn/tms_update/tmsupdate.cfg"
ngx.req.read_body()
local args, err = ngx.req.get_post_args()
if not args then
ngx.say("error|failed to get post args: ", err)
@ChinaXing
ChinaXing / epoch-format.mkdown
Last active August 29, 2015 13:57
convert Epoch to date fromat

SHELL :

date -d @Epoch

MYSQL :

select DATE_FORMAT(DATE_ADD(FROM_UNIXTIME(0), interval 1396240017 second),"%Y-%m-%d %H:%m:%s");

PHP date(output format, epoch); Output format example: 'r' = RFC 2822 date more ... Python import time first, then time.strftime("%a, %d %b %Y %H:%M:%S +0000", time.localtime(epoch)) Replace time.localtime with time.gmtime for GMT time. More info

@ChinaXing
ChinaXing / nginx-forwarding.lua
Created May 16, 2014 08:58
nginx-domain-forwarding
-- yunxing.cyx @ 2014-04-09
-- yunxing.cyx @ 2014-05-16 fix bug , use ngx.var.host to fetch domain name
-- load from pesystem
local host_header = ngx.var.host
local resp = ngx.location.capture("/forwarding/domain/host/" .. host_header)
if resp.status ~= 200 then
ngx.header.content_type = 'text/plain'
ngx.say("forwarding target for " .. host_header .. " can not be found !")
ngx.exit(ngx.HTTP_OK)
end
@ChinaXing
ChinaXing / proxyer.pyw
Last active August 29, 2015 14:02
proxyer for connect to any backend host throw Http-proxy use CONNECT method
#!/usr/bin/python
# -*- coding: UTF-8 -*-
# Author : yunxing.cyx@taobao.com
# Date : 2014-06-09
import sys,socket,select
import Tkinter
from threading import Thread
proxy_server = "11.11.22.33"
@ChinaXing
ChinaXing / jdb-windows-remote.sh
Created June 9, 2014 06:53
jdb windows remote debug
jdb -connect com.sun.jdi.SocketAttach:hostname=1.2.3.4,port=8888
@ChinaXing
ChinaXing / mvn-pkg-source.sh
Created June 25, 2014 04:40
Maven get source for special package
mvn dependency:sources -DincludeGroupIds=org.springframework -DincludeArtifactIds=spring-tx
@ChinaXing
ChinaXing / for-loop-concurrence.java
Created August 12, 2014 05:10
for 循环迭代对并发修改是否会抛出异常
Map<String,Object> map = new HashMap<String, Object>();
// Thread 1
for(Entry<String,Object> entry : map.entrySet()){
// print entry content;
}
// Thread 2
@ChinaXing
ChinaXing / private-overriden-hidden.java
Created August 12, 2014 05:16
private field and function override/hidden
public class a {
private int a = 20;
private int getA(){
return a;
}
private void setA(int a){
this.a = a;
}
@ChinaXing
ChinaXing / cr.mkd
Last active August 29, 2015 14:05
concurrency related

Concurrency Control

  • RCU
  • Lock-Free / wait-Free
  • Sequence Lock
  • Multiversion Concurrent control
  • TimeStamp Based Concurrent control
  • No-Blocking Algorithm
  • Memery Barrier
  • Software Memory Transaction
@ChinaXing
ChinaXing / common-ctl.sh
Last active August 29, 2015 14:06
reusable app control shell scripts - start/stop app
#!/bin/bash
function getWorkDir
{
dir=$(dirname $0)
cd $dir || {
echo "$dir not eixt."
exit 1
}