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 *.**>
"""
WSGI config for wechat_backend project.
It exposes the WSGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/1.9/howto/deployment/wsgi/
"""
import os
@hqingyi
hqingyi / django.conf
Created February 2, 2016 09:08
nginx config
server {
listen 80;
server_name example.me;
access_log /var/log/example/nginx-access.log;
error_log /var/log/example/nginx-error.log;
location /static/ {
alias /home/django/gaokao/static/;
@hqingyi
hqingyi / sync_forked_repo.md
Created December 9, 2015 14:24
How to sync a github forked repository

How to sync a github forked repository

In your local clone of your forked repository, you can add the original GitHub repository as a "remote". ("Remotes" are like nicknames for the URLs of repositories - origin is one, for example.) Then you can fetch all the branches from that upstream repository, and rebase your work to continue working on the upstream version.

Sample

@hqingyi
hqingyi / bc3_git_config.md
Last active December 9, 2015 06:59
BeyondCompare as git mergetool/difftool

Use Beyond Compare as git mergetool/difftool

准备BeyondCompare

打开BeyondCompare安装好Command Line Utils

  • /usr/local/bin/bcomp
  • /usr/local/bin/bcompare

Git版本>2.3,直接配置bc3即可

git config --global diff.tool bc3
@hqingyi
hqingyi / ngrok-selfhosting-setup.md
Created December 9, 2015 01:22 — forked from lyoshenka/ngrok-selfhosting-setup.md
How to setup Ngrok with a self-signed SSL cert

Intro

The plan is to create a pair of executables (ngrok and ngrokd) that are connected with a self-signed SSL cert. Since the client and server executables are paired, you won't be able to use any other ngrok to connect to this ngrokd, and vice versa.

DNS

Add two DNS records: one for the base domain and one for the wildcard domain. For example, if your base domain is domain.com, you'll need a record for that and for *.domain.com.

Different Operating Systems

@hqingyi
hqingyi / python_infrastructure.md
Created December 3, 2015 12:40 — forked from onlytiancai/python_infrastructure.md
python 基础设施讨论贴

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

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

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

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

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

@hqingyi
hqingyi / yourservice.conf
Created November 23, 2015 07:05 — forked from c4milo/yourservice.conf
upstart example script
# Ubuntu upstart file at /etc/init/yourservice.conf
pre-start script
mkdir -p /var/log/yourcompany/
end script
respawn
respawn limit 15 5
start on runlevel [2345]
@hqingyi
hqingyi / shadowsocks
Created November 15, 2015 12:13
Shadowsocks init.d
#!/bin/sh
start(){
ssserver -c /etc/shadowsocks.json -d start
}
stop(){
ssserver -c /etc/shadowsocks.json -d stop
}
case "$1" in
start)
@hqingyi
hqingyi / tmux-cheatsheet.markdown
Created November 13, 2015 04:16 — forked from MohamedAlaa/tmux-cheatsheet.markdown
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname