Skip to content

Instantly share code, notes, and snippets.

View Lax's full-sized avatar

Liu Lantao Lax

View GitHub Profile
@Lax
Lax / logstash-accounting.conf
Created August 3, 2015 07:27
logstash.conf for ngx_http_accounting_module
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"
@Lax
Lax / preprocessor_fun.h
Last active August 29, 2015 14:27 — forked from aras-p/preprocessor_fun.h
Things to commit just before leaving your job
// 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,
@Lax
Lax / ajaxify-html5.js
Created April 8, 2012 15:49
Ajaxify a Website with the HTML5 History API using History.js, jQuery and ScrollTo
// https://gist.github.com/854622
(function(window,undefined){
// Prepare our Variables
var
History = window.History,
$ = window.jQuery,
document = window.document;
// Check to see if History.js is enabled for our Browser
@Lax
Lax / README.md
Created December 27, 2013 01:58
nginx_variables_quickref

About this list

This is a quick-ref for various nginx variables.

Conventions

### Module name

* $variable_name

defination/usage

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();
"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
@Lax
Lax / rails-ujs-demo.rb
Created August 14, 2017 04:43
Demo code for `rails-ujs`
#
# Usage:
# rails new -m=ujs.rb ujs_demo
#
gem 'rails'
gem 'jquery-rails'
generate :controller, :ujs
@Lax
Lax / ipaddr_demo.rb
Created January 13, 2014 08:25
Ruby IPAddr class, inet_aton and inet_ntoa equivalence.
require 'ipaddr'
IPAddr.new("192.168.0.1").to_i
=> 3232235521
IPAddr.new(3232235521, Socket::AF_INET).to_s
=> "192.168.0.1"
@Lax
Lax / Setup-Steps.md
Last active January 8, 2018 08:32
Confluent - Kafka setup

Environments

Docker host name: localhost
Docker host ip: 192.168.0.98 - (macOS: `ifconfig en0 inet`; Linux: `/sbin/ifconfig  eth0`)
Zookeeper address: 192.168.0.98:2181
Kafka address: 192.168.0.98:9092
@Lax
Lax / video-20180526.rst
Created May 26, 2018 11:47
about video setup
public Desc Membership
 |
 |