Skip to content

Instantly share code, notes, and snippets.

View codeb2cc's full-sized avatar
🎯
Focusing

Codeb Fan codeb2cc

🎯
Focusing
View GitHub Profile
@codeb2cc
codeb2cc / Dockerfile
Created July 16, 2019 08:22
OpenResty Dockerfile with "Opentracing Nginx" module
# Dockerfile - Ubuntu Bionic
# https://github.com/openresty/docker-openresty
ARG RESTY_IMAGE_BASE="ubuntu"
ARG RESTY_IMAGE_TAG="bionic"
FROM ${RESTY_IMAGE_BASE}:${RESTY_IMAGE_TAG}
# Docker Build Arguments
ARG RESTY_VERSION="1.13.6.2"

Keybase proof

I hereby claim:

  • I am codeb2cc on github.
  • I am codeb2cc (https://keybase.io/codeb2cc) on keybase.
  • I have a public key ASAl-Wl69PMTaFJMnnBgerCnZuQmNYsLxmy1rtayDiRKxQo

To claim this, I am signing this object:

@codeb2cc
codeb2cc / gist:149e70cb845cc364004c7f2ed085eabf
Last active June 29, 2017 10:02
Kubernetes log pattern for Logstash
DNS_LABEL [a-z0-9]([-a-z0-9]*[a-z0-9])?
DNS_SUBDOMAIN %{DNS_LABEL}(\.%{DNS_LABEL})*
POD_NAME %{DNS_SUBDOMAIN}
NAMESPACE %{DNS_SUBDOMAIN}
CONTAINER_NAME %{DNS_LABEL}
DOCKER_ID [a-z0-9]{64}
DEPLOYMENT_NAME %{DNS_SUBDOMAIN}
TEMPLATE_HASH [0-9]{1,10}
@codeb2cc
codeb2cc / gist:5199a5e2fa87316ee2c2
Created October 10, 2014 04:57
Fiddler costomize rules
import System;
import System.Windows.Forms;
import Fiddler;
// INTRODUCTION
// This is the FiddlerScript Rules file, which creates some of the menu commands and
// other features of Fiddler. You can edit this file to modify or add new commands.
//
// The original version of this file is named SampleRules.js and it is in the
@codeb2cc
codeb2cc / pypy_on_hadoop.md
Created July 4, 2014 19:45
在Hadoop Streaming中使用PyPy

在Hadoop Streaming中使用PyPy

[PyPy][1]作为CPython的高性能替代方案,目前已经十分成熟,得益于JIT等技术的应用,多数场景下PyPy都具有更好的性能。以通过正则对Nginx日志进行解析为例,对300G数据进行处理,PyPy对比原生Python能得到2.5倍以上的性能提升:

Slot time(mins) Read(%) Write(%) User(%) MB/s Record/s
Python 2.6 2412.76 3.17% 32.21% 64.61% 2.07 1741.74
PyPy 2.3 869.37 9.01% 87.13% 3.85% 5.69 4809.06
@codeb2cc
codeb2cc / gst.go
Created June 26, 2014 18:56
Generalized suffix tree implemented in suffix array
package main
import (
"fmt"
"index/suffixarray"
"regexp"
"strings"
)
func main() {
#!/bin/sh
# Bump project version
PY_INIT=__init__.py
PACKAGE_JSON=public/package.json
BOWER_JSON=public/bower.json
VERSION=(`grep -Eo "[0-9]+\.[0-9]+\.[0-9]" $PY_INIT`)
echo "Project current version: [$VERSION] "
@codeb2cc
codeb2cc / .gitconfig
Created September 30, 2013 07:49
Git config file
[user]
name = Codeb Fan
email = codeb2cc@gmail.com
[push]
default = simple
[core]
editor = vim
[diff]
tool = vimdiff
ignoreSubmodules = dirty
@codeb2cc
codeb2cc / gist:6280031
Created August 20, 2013 10:58
Nginx log format and GoAccess configuration.
# Nginx log format
log_format main '$remote_addr\t$remote_user\t$time_local\t$request_time\t$request\t'
'$status\t$body_bytes_sent\t$http_referer\t'
'$http_user_agent\t$http_x_forwarded_for';
# GoAccess configuration
# IMPORTANT: Replace all `\t` below with real tabs
date_format %d/%b/%Y:%T
log_format %h\t%^\t%d %^\t%T\t%r\t%s\t%b\t%R\t%u\t%^
@codeb2cc
codeb2cc / header_size.c
Created August 17, 2013 16:58
Calculate header size(requested memory) of a item stored in memcached.
#include <stdio.h>
#include <stdint.h>
/** Time relative to server start. Smaller than time_t on 64-bit systems. */
typedef unsigned int rel_time_t;
typedef struct _stritem {
struct _stritem *next;
struct _stritem *prev;
struct _stritem *h_next; /* hash chain next */