Skip to content

Instantly share code, notes, and snippets.

View charlescui's full-sized avatar

CharlesCui charlescui

  • TvTaobao 电视淘宝 杭州智屏电子商务
  • China ZheJiang HangZhou
View GitHub Profile
require "aliyun_sls"
module Fluent
class SlsOutput < Output
Plugin.register_output('sls', self)
def initialize
super
@sls_con = AliyunSls::Connection.new(ENV["PROJECT"], ENV["REGION"], ENV["SECRET"], ENV["KEY"])
@topic = `hostname`.strip
@charlescui
charlescui / qrcode
Created October 7, 2013 03:02
This is a generate qrcode tool, resolve between pc and smart phone or pad translate tiny information.
#! /usr/bin/env ruby
require "rqrcode"
require "uuid"
require "erb"
@qr = RQRCode::QRCode.new(ARGV[0])
file = File.expand_path($0)
@charlescui
charlescui / gist:4407327
Last active December 10, 2015 08:28
screen的配置文件
#termcapinfo rxvt* 'hs:ts=\E]2;:fs=\007:ds=\E]2;\007'
#hardstatus string "screen (%n: %t)"
source /etc/screenrc
altscreen off
hardstatus none
# hardstatus string '%{= kg}[ %H ][%{= kw}%= %?%-Lw%?%{R}(%{W}%n*%f%t%?(%u)%?%{r})%{w}%?%+Lw%?%?%= %{g}][%{W} %c %{g}]'
# hardstatus string '%{= kG}[ %{G}%H %{g}][%= %{= kw}%?%-Lw%?%{r}(%{W}%n*%f%t%?(%u)%?%{r})%{w}%?%+Lw%?%?%= %{g}][%{B} %d/%m %{W}%c %{g}]'
# hardstatus string "%{= bk} %{= wk} %-Lw%{bw}%n+%f %t%{wk}%{wk}%+Lw %=%{kw}%{= R}%{-}"
# hardstatus string "%{= kw} %H %{wk} [%= %-Lw%{r}%n+%f %t%{k}%+Lw %= ] %{kw} %c %{kw}%{= R}%{-}"
# hardstatus string "%{= rw} %H %{wk} %-Lw%{r}%n+%f %t%{wk}%+Lw %= %c%{kw}%{= R}%{-}"
@charlescui
charlescui / wr703n-openwrt.md
Created September 5, 2012 23:21 — forked from ninehills/wr703n-openwrt.md
WR703N OpenWrt 配置流程

WR703N OpenWrt 配置流程

下载安装

访问WR703N在OpenWrt的[Wiki页][wr703n-openwrt],然后在Flashing一节中找到下载链接:[squashfs-factory.bin][flash.bin],下载后别忘了[比对md5][md5sum]。[1]

进入路由器管理界面,出厂配置为http://192.168.1.1,用户名和密码均为admin,然后进入固件更新,选择下载的文件,然后更新。

@charlescui
charlescui / upstream_response_time log
Created August 29, 2012 03:03
分析http请求从网关机到反向代理开始处理的响应时间
查看方法:
tail -fn100 /var/log/nginx/access.log
例子:
58.16.228.134 - - [29/Aug/2012:10:47:20 +0800] "200" POST /api/v1/users/update_device_token?user_credentials=Z2caLs3BuAfZ0LKPe0 HTTP/1.1 "微电视 2.05 (iPhone; iPhone OS 5.1.1; zh_CN)" upstream_response_time 0.341 msec 1346208440.833 request_time 0.431
日志格式:
'$remote_addr - $remote_user [$time_local] "$status" $request "$http_user_agent" '
'upstream_response_time $upstream_response_time '
'msec $msec request_time $request_time';
@charlescui
charlescui / bijective.rb
Created July 14, 2012 15:07 — forked from zumbojo/bijective.rb
Simple bijective function (base(n) encode/decode)
# Simple bijective function
# Basically encodes any integer into a base(n) string,
# where n is ALPHABET.length.
# Based on pseudocode from http://stackoverflow.com/questions/742013/how-to-code-a-url-shortener/742047#742047
ALPHABET =
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789".split(//)
# make your own alphabet using:
# (('a'..'z').to_a + ('A'..'Z').to_a + (0..9).to_a).shuffle.join
@charlescui
charlescui / runtime_callback.rb
Created April 9, 2012 08:55 — forked from outoftime/runtime_callback.rb
Add support for OmniAuth callbacks defined at runtime
#
# Including this module in an OmniAuth strategy implementation allows it to have
# a runtime-defined callback path extension. The callback path always begins
# with the predefined callback path, but may extend it. Specify a callback path
# extension at runtime by passing the 'callback' parameter to the request-phase
# auth URL. For example, the below URL:
#
# http://your.host/auth/facebook?callback=users/create
#
# Will issue a callback to:
@charlescui
charlescui / connection_fix.rb
Created March 24, 2012 04:05 — forked from taras-yorku/connection_fix.rb
MySQL server has gone away fix - Ensure it only affects mysql2 adapter
# If your workers are inactive for a long period of time, they'll lose
# their MySQL connection.
#
# This hack ensures we re-connect whenever a connection is
# lost. Because, really. why not?
#
# Stick this in RAILS_ROOT/config/initializers/connection_fix.rb (or somewhere similar)
#
# From:
# http://coderrr.wordpress.com/2009/01/08/activerecord-threading-issues-and-resolutions/
@charlescui
charlescui / gist:1172826
Created August 26, 2011 06:22 — forked from liwh/gist:1022751
install coreseek on mac os
# 按照coreseek网站上的安装步骤没装上,所以采用了下面的安装方式,安装成功!
sudo port install autoconf263 libtool-devel m4 autoconf automake libtool
cd mmseg-3.2.14
aclocal && glibtoolize --copy --force --ltdl && autoreconf -i -f && automake --a && ./configure --prefix=/usr/local/mmseg3 && make && sudo make install
cd ../csft-3.2.14
./configure --prefix=/usr/local/coreseek --without-unixodbc --with-mmseg --with-mmseg-includes=/usr/local/mmseg3/include/mmseg/ --with-mmseg-libs=/usr/local/mmseg3/lib/ --with-pgsql
sphinx: &using
address: sphinx-server-host-ip
bin_path: /usr/local/bin
searchd_binary_name: searchd
indexer_binary_name: indexer
enable_star: 1
min_prefix_len: 3
prefix_fields: name
mem_limit: 1024M
morphology: 'none'