Skip to content

Instantly share code, notes, and snippets.

View Lax's full-sized avatar

Liu Lantao Lax

View GitHub Profile
@Lax
Lax / redis-queue-transfer.py
Last active August 27, 2015 15:26
transfer item from one redis queue to another
#!/usr/bin/env python
import redis
POOL = redis.ConnectionPool(host='127.0.0.1', port=6379, db=0)
if __name__=="__main__":
while True:
my_server = redis.Redis(connection_pool=POOL)
kafka_message = my_server.lpop("src:queue")
if kafka_message:
/*
* Copyright (c) 2013 by Wil Tan <wil@cloudregistry.net>
*
* Based on dump_dns.c from the dnscap <https://www.dns-oarc.net/tools/dnscap>
* originally written by Paul Vixie.
*
* Copyright (c) 2007 by Internet Systems Consortium, Inc. ("ISC")
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@Lax
Lax / README.md
Last active August 29, 2015 14:01
IP-LOCATION-ISP

IP-LOCATION-ISP

# A quick and dirty plugin for Jekyll by Eli Naeher
#
# This plugin creates a site.years template variable which allow you to group archive links by year and month.
# The structure of site.years is:
# site.years = 2001=>[[post1, post2...], [...]], 2002=>[...]
#
# Usage should look something like this:
# {% for year in site.years %}
# <h2>Year {{ year.first.first.date | date: "%Y" }}</h2>
@Lax
Lax / rewrite_by_lua.conf
Created September 12, 2014 03:19
(nginx.conf) rewrite by lua, for SEO, etc.
rewrite_by_lua '
REDIR_R = {
["/r/1"] = "/d/1",
["/r/2"] = "/d/2",
}
if REDIR_R[ngx.var.uri] then
return ngx.redirect(REDIR_R[ngx.var.uri]);
end
';
@Lax
Lax / README.md
Last active August 29, 2015 14:07 — forked from nikcub/README.md
@Lax
Lax / .gitignore
Last active August 29, 2015 14:10
aliyun_cli
aliyun.yml
*.csv
require 'socket'
require 'pp'
require 'xdr'
# Inspiration
# https://github.com/fastly/ganglia/blob/master/lib/gm_protocol.x
# https://github.com/igrigorik/gmetric/blob/master/lib/gmetric.rb
# https://github.com/ganglia/monitor-core/blob/master/gmond/gmond.c#L1211
# https://github.com/ganglia/ganglia_contrib/blob/master/gmetric-python/gmetric.py#L107
@Lax
Lax / Gemfile
Last active August 29, 2015 14:16
Consume TSData from kafka, write to opentsdb
source 'http://ruby.taobao.org'
gem "poseidon" # kafka
gem "thrift"
gem "opentsdb"
@Lax
Lax / aliyun-cms-monitor.rb
Created July 22, 2015 13:21
Aliyun CMS(Cloud Monitor Service) Demo. https://github.com/Lax/aliyun
#!/usr/bin/env ruby
require 'rubygems'
require 'aliyun'
require 'time'
$DEBUG=true
options = {:access_key_id => "ALIYUN_KEY_ID",
:access_key_secret => "ALIYUN_KEY_SECRET",
:service => :cms}