This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//var http = require('http') | |
var express = require("express") | |
var ts = new Date().getTime() | |
var redis = require("redis") | |
var app = express() | |
var async = require('async') | |
client = redis.createClient('6379','xxx.xxx.xxx.xxx'); | |
var act1 = function(callback){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--package.path = package.path .. ';/opt/openresty/lualib/?.lua' | |
local redis = require "resty.redis" | |
local cjson = require "cjson" | |
local red_host = 'xxx.xxx.xxx.xxx' | |
local ts = os.time() | |
local red = redis:new() | |
--local tb_resp = {} | |
--local req_args = ngx.req.get_uri_args() | |
red:set_timeout(10000) -- 10 sec |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// DEL redis keys by pattern with redis lua support | |
redis 127.0.0.1:6379> eval "for _,k in ipairs(redis.call('keys','kr:feed:9:*')) do redis.call('del',k) end" 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
MAILTO='your@gmail.com' | |
# my cronjob | |
MP_UPD_LOCK='/tmp/.your_lock_file.lock' | |
* * * * * pahud /usr/bin/flock -w1 ${MP_UPD_LOCK} /usr/bin/python -c "from xxxx import foo as f; f.FooBar().update()" > /dev/null || SUBJ="[ERROR] flock on ${MP_UPD_LOCK} failed"; mail -s "${SUBJ}" "${MAILTO}" > /dev/null |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
連續寫入30次,運行在google compute engine上,每次寫入時間大約0.3秒。 | |
$ for i in `seq 30`; do curl -sH "Content-Type: application/json" -H "Authorization: Bearer xxxxxxxx" https://www.googleapis.com/datastore/v1beta2/datasets/project-id/commit -d @addbody -o /dev/null -w "total:%{time_total}\n"; done | |
total:0.364 | |
total:0.353 | |
total:0.362 | |
total:0.352 | |
total:0.354 | |
total:0.357 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
#-*- coding:utf8 -*- | |
''' | |
Usage: ./d2r.py RESOURCE_URL | |
''' | |
import base64, sys, requests |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var FindProxyForURL = function(init, profiles) { | |
return function(url, host) { | |
"use strict"; | |
var result = init, scheme = url.substr(0, url.indexOf(":")); | |
do { | |
result = profiles[result]; | |
if (typeof result === "function") result = result(url, host, scheme); | |
} while (typeof result !== "string" || result.charCodeAt(0) === 43); | |
return result; | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
#set -x | |
dockercmd='/usr/bin/docker' | |
s=$( $dockercmd inspect --format='{{.State.Running }}' ss 2>&1) | |
if [ $? -ne 0 ]; then | |
echo "not 0" | |
/root/shadowsocks-python/start.sh | |
elif [ "${s}X" == "falseX" ]; then |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM debian:jessie | |
MAINTAINER Pahud Hsieh <pahudnet@gmail.com> | |
RUN apt-get update | |
RUN apt-get -y install python-pip python-m2crypto | |
RUN pip install shadowsocks | |
ADD config.json /etc/shadowsocks/ | |
ENTRYPOINT ["/usr/local/bin/ssserver", "-c", "/etc/shadowsocks/config.json"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# | |
# chkconfig: 2345 55 25 | |
# Description: Nginx init.d script, put in /etc/init.d, chmod +x /etc/init.d/nginx | |
# For Debian, run: update-rc.d -f nginx defaults | |
# For CentOS, run: chkconfig --add nginx | |
# | |
### BEGIN INIT INFO | |
# Provides: nginx | |
# Required-Start: $all |
OlderNewer