Skip to content

Instantly share code, notes, and snippets.

@hqingyi
hqingyi / fluentd_forwarder.conf
Created March 24, 2016 03:05
haproxy -> fluentd forwarder -> fluentd server -> elasticsearch -> kibana
<source>
type tail
path /var/log/haproxy.log
pos_file /var/log/td-agent/haproxy.log.pos
tag haproxy.http
format /^(?<syslog_time>.+) (?<source_ip>.+) (?<ps>\w+)\[(?<pid>\d+)\]: (?<c_ip>[\w\.]+):(?<c_port>\d+) \[(?<time>.+)\] (?<f_end>[\w\.-]+) (?<b_end>[\w\.-]+)\/(?<b_server>[^ ]+) (?<tq>[-]?\d+)\/(?<tw>[-]?\d+)\/(?<tc>[-]?\d+)\/(?<tr>[-]?\d+)\/(?<tt>\d+) (?<status_code>\d+) (?<bytes_read>\d+) (?<captured_request_cookie>.+) (?<captured_response_cookie>.+) (?<termination_state>.+) (?<actconn>\d+)\/(?<feconn>\d+)\/(?<beconn>\d+)\/(?<srv_conn>\d+)\/(?<retries>\d+) (?<srv_queue>\d+)\/(?<backend_queue>\d+) \"(?<http_request>.+)\"$/
time_format %d/%b/%Y:%H:%M:%S.%L
</source>
<match *.**>
@bangedorrunt
bangedorrunt / .spacemacs
Last active December 6, 2015 13:42
Spacemacs dotfile
;; -*- mode: emacs-lisp -*-
;; This file is loaded by Spacemacs at startup.
;; It must be stored in your home directory.
(defun dotspacemacs/layers ()
"Configuration Layers declaration.
You should not put any user code in this function besides modifying the variable
values."
(setq-default
;; Base distribution to use. This is a layer contained in the directory
@owainlewis
owainlewis / proxy.el
Last active October 18, 2024 05:44
Using Emacs ERC behind a HTTP proxy
;; Connect to ERC using a HTTP proxy : (
;; *******************************************
(defvar http-proxy-host
"www-cache.reith.bbc.co.uk")
(defvar http-proxy-port 80)
;; Proxy handler
;; *******************************************
@hjhart
hjhart / Gemfile
Last active March 15, 2023 15:04
Trial Fluentd configuration for parsing HAProxy logs from Syslog
source 'https://rubygems.org'
gem 'fluentd'
gem 'fluent-plugin-td'
gem 'fluent-plugin-elasticsearch'
@awinder
awinder / controller.js
Last active June 16, 2016 13:49
Mocking the Express.js response object
module.exports = {
test : function(req, res) {
setTimeout(function() {
res.send({ testing : true }, 200);
}, 5000);
},
}
@zhenyi2697
zhenyi2697 / Python 代码优化常见技巧.md
Created March 29, 2013 10:35
Python: 代码优化技巧

##Python 代码优化常见技巧

###改进算法,选择合适的数据结构

  • 使用dict的查找要比list快很多

  • 当要求list的交集时,转化成set来计算比较快。set的常见操作:

    union: set(list1) | set(list2)
    intersection: set(list1) & set(list2)
    difference: set(list1) - set(list2)

@onlytiancai
onlytiancai / python_infrastructure.md
Created October 12, 2012 08:55
python 基础设施讨论贴

python项目通用组件和基础服务

很多公司都大量使用了python,其中有一些开发规范,code guidline, 通用组件,基础框架是可以共用的。

每个公司都自己搞一套, 太浪费人力,我想开一帖和大家讨论一下这些python基础设施的搭建。

原则是我们尽量不重新发明轮子,但开源组件这么多,也要有个挑选的过程和组合使用的过程,在这里讨论一下。

另一方面,有些开源组件虽然强大,但我们不能完全的驾驭它,或只使用其中很少的一部分,我们就可以考虑用python实现一个简单的轮子,可控性更强,最好不要超过300行代码。

@lotem
lotem / default.custom.yaml
Last active October 18, 2024 00:42
在Rime輸入方案選單中添加五筆、雙拼、粵拼、注音,保留你需要的
# default.custom.yaml
# save it to:
# ~/.config/ibus/rime (linux)
# ~/Library/Rime (macos)
# %APPDATA%\Rime (windows)
patch:
schema_list:
- schema: luna_pinyin # 朙月拼音
- schema: luna_pinyin_simp # 朙月拼音 简化字模式
@almost
almost / models.coffee
Created November 26, 2011 20:02
The beginnings of a declarative model syntax for CoffeeScript.
# The beginnings of a declarative model syntax for CoffeeScript.
# SEE: http://almostobsolete.net/declarative-models-in-coffeescript.html
# Thomas Parslow
# Email: [email protected]
# Twitter: @almostobsolete
# The top part is the setup, see below that for the demo
# To see this run right away try copy pasting it into the 'Try
# CoffeeScript' box at http://jashkenas.github.com/coffee-script/