Skip to content

Instantly share code, notes, and snippets.

View villadora's full-sized avatar

Wei Gao villadora

  • Ant,Tmall, DP, MS
  • Shanghai,China
View GitHub Profile
@villadora
villadora / Default.sublime-keymap
Created April 23, 2013 08:40
for subliemacspro
[
{ "keys": ["alt+q"], "command": "wrap_lines" },
{ "keys": ["ctrl+o"], "command": "sbp_open_line" },
// Emacs style go to indentation, alt+e can be complicated on Macs
{ "keys": ["alt+a"], "command": "move_to", "args": {"to": "bol", "extend": false} },
{ "keys": ["alt+e"], "command": "move_to", "args": {"to": "eol", "extend": false} },
{ "keys": ["alt+e"], "command": "move_to", "args": {"to": "eol", "extend": true}, "context":
[
{ "key": "sbp_emacs_has_mark", "operator": "equal", "operand": true }
#!/usr/bin/env ruby
# A quick and dirty implementation of an HTTP proxy server in Ruby
# because I did not want to install anything.
#
# Copyright (C) 2009 Torsten Becker <torsten.becker@gmail.com>
require 'socket'
require 'uri'
@villadora
villadora / jshintrc
Created August 26, 2013 03:24
jshintrc with comments
{
// Settings
"passfail" : false, // Stop on first error.
"maxerr" : 20, // Maximum errors before stopping.
// Predefined globals whom JSHint will ignore.
"browser" : true, // Standard browser globals e.g. `window`, `document`.
"node" : false,
@villadora
villadora / mysql-node-pool.js
Created September 4, 2013 03:06
usage for node-mysql-pool
var pool = mysql.createPool({
host: '127.0.0.1',
port: '3306',
user: 'root',
password: '123456',
database: 'test',
debug: process.env.NODE_ENV == 'debug'
});
  1. write config file make a config.admin.js, config couchAuth for couch login, and registryCouch to couchdb; update =npm= change the registry address;

  2. start redis install redis, run:

    redis-server dev/redis/redis.conf

  3. start elasticsearch install elasticsearch, run:

@villadora
villadora / 0_reuse_code.js
Created December 4, 2013 01:58
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console

compdef

complete

compctl

@villadora
villadora / latency.markdown
Created April 15, 2016 06:17 — forked from hellerbarde/latency.markdown
Latency numbers every programmer should know

Latency numbers every programmer should know

L1 cache reference ......................... 0.5 ns
Branch mispredict ............................ 5 ns
L2 cache reference ........................... 7 ns
Mutex lock/unlock ........................... 25 ns
Main memory reference ...................... 100 ns             
Compress 1K bytes with Zippy ............. 3,000 ns  =   3 µs
Send 2K bytes over 1 Gbps network ....... 20,000 ns  =  20 µs
SSD random read ........................ 150,000 ns  = 150 µs

Read 1 MB sequentially from memory ..... 250,000 ns = 250 µs

@villadora
villadora / siteminder.md
Created July 11, 2012 02:52
Siteminder Request Flow

Behind the request to a server protected by siteminder

2 modes for deploying siteminder

  1. proxy server
  2. agent configuration - install software on the web server

What happens when user raises a request

The following steps occur when a user tries to access a protected resource on a web server configured to use SiteMinder authentication:

@villadora
villadora / logstash.grok.pattern
Created August 21, 2017 12:18
logstash grok pattern
USERNAME [a-zA-Z0-9._-]+
USER %{USERNAME}
INT (?:[+-]?(?:[0-9]+))
BASE10NUM (?<![0-9.+-])(?>[+-]?(?:(?:[0-9]+(?:\.[0-9]+)?)|(?:\.[0-9]+)))
NUMBER (?:%{BASE10NUM})
BASE16NUM (?<![0-9A-Fa-f])(?:[+-]?(?:0x)?(?:[0-9A-Fa-f]+))
BASE16FLOAT \b(?<![0-9A-Fa-f.])(?:[+-]?(?:0x)?(?:(?:[0-9A-Fa-f]+(?:\.[0-9A-Fa-f]*)?)|(?:\.[0-9A-Fa-f]+)))\b
POSINT \b(?:[1-9][0-9]*)\b
NONNEGINT \b(?:[0-9]+)\b