This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# Usage: | |
# rails new -m=ujs.rb ujs_demo | |
# | |
gem 'rails' | |
gem 'jquery-rails' | |
generate :controller, :ujs |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"use strict"; | |
function waitFor(testFx, onReady, timeOutMillis) { | |
var maxtimeOutMillis = timeOutMillis ? timeOutMillis : 3000, //< Default Max Timout is 3s | |
start = new Date().getTime(), | |
condition = false, | |
interval = setInterval(function() { | |
if ( (new Date().getTime() - start < maxtimeOutMillis) && !condition ) { | |
// If not time-out yet and condition not yet fulfilled | |
condition = (typeof(testFx) === "string" ? eval(testFx) : testFx()); //< defensive code |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var page = require('webpage').create(), | |
system = require('system'), | |
t, address; | |
if (system.args.length === 1) { | |
console.log('Usage: loadspeed.js <some URL>'); | |
phantom.exit(); | |
} | |
t = Date.now(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Just before switching jobs: | |
// Add one of these. | |
// Preferably into the same commit where you do a large merge. | |
// | |
// This started as a tweet with a joke of "C++ pro-tip: #define private public", | |
// and then it quickly escalated into more and more evil suggestions. | |
// I've tried to capture interesting suggestions here. | |
// | |
// Contributors: @r2d2rigo, @joeldevahl, @msinilo, @_Humus_, | |
// @YuriyODonnell, @rygorous, @cmuratori, @mike_acton, @grumpygiant, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
input { | |
stdin {} | |
} | |
filter { | |
grok { | |
match => [ "message", "^%{SYSLOGTIMESTAMP:timestamp}\|\| pid:\d+\|from:\d{10}\|to:\d{10}\|accounting_id:%{WORD:accounting}\|requests:%{NUMBER:req:int}\|bytes_out:%{NUMBER:size:int}\|%{DATA:status}"] | |
} | |
kv { | |
target => "code" | |
source => "status" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
source 'http://ruby.taobao.org' | |
gem "poseidon" # kafka | |
gem "thrift" | |
gem "opentsdb" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
aliyun.yml | |
*.csv |