Skip to content

Instantly share code, notes, and snippets.

@herohenu
herohenu / gist:bd5c35a63f58a16ccf4ab3382ceab9ed
Created March 7, 2018 02:48 — forked from thomas11/gist:2909362
Log memory usage every n seconds in Go #golang
import (
"runtime"
"time"
)
...
go func() {
for {
var m runtime.MemStats
@herohenu
herohenu / watch-log-dmp-timeout.rb
Last active December 11, 2017 06:32
analyze watchlog get dmp timeout and error
#filepath="watch.log.2017-12-08-09"
def getAnalyzeResult filepath
begin
File.open("#{filepath}").each do |line|
linefields = []
lineHash = Hash.new(0)
watch_fields = line.split("\t")
sub=1&account=13070516276&pwd=475e224cb1cb423970a74e28015904a8c1faa30bf2c81463cf0e3d4d564199c89dd33af4eb7194d2af4ee4b1cd6a2816f35a691ddd81b08d04d4a371fba19dd527bd054e385304778c98668cff7f9d3a8fff532be59a266654aeae69b666f32f7be9468f783cb57ae7681c0158844b9c01968783f23f4e8fd437af81a2a8b946&vcode=&remember=1
sub=1&account=13910127662&pwd=&vcode=&remember=1
sub=1&account=18507223960&pwd=2cb14e243e8a97d962f38250ecf9cdb40ad2d300563574778b17df13248c350565622734642ecce14c358f4085e544e0c19d32a5ff3b117b23f5e5b395f4aad412d4d972e9fcf313b7a19169fda23c8e5c2c4854a95cdcfcd24ebbed40d476aec0358c90c96c8ca7d010bcc8b8541a7bb208824523dc91d5f67b8e1c8b200e49&vcode=&remember=1
sub=1&account=18952947692&pwd=82475a61b823d0fb081c6c1e96de2f5ccbd86750aa3870622c4d83dd4cf6c85c5da98c5e972d030c7beb205ced82781a956931081ec03b9329d4a993168041a13affe72e2320cee06dac4ac111ea1719fd7ef4b3b665ab7191cf41123f7815a8c6567f4832b42b82b50251f3a8606aa7e2551092ef9b0bb9e8d103302cd96d07&vcode=&remember=1
sub=1&account=18607182910&pwd=&vcode=&remember=1
sub=1&accou
# $OpenBSD: sshd_config,v 1.89 2013/02/06 00:20:42 dtucker Exp $
# This is the sshd server system-wide configuration file. See
# sshd_config(5) for more information.
# This sshd was compiled with PATH=/usr/local/bin:/bin:/usr/bin
# The strategy used for options in the default sshd_config shipped with
# OpenSSH is to specify options with their default value where
# possible, but leave them commented. Uncommented options override the
# $OpenBSD: sshd_config,v 1.89 2013/02/06 00:20:42 dtucker Exp $
# This is the sshd server system-wide configuration file. See
# sshd_config(5) for more information.
# This sshd was compiled with PATH=/usr/local/bin:/bin:/usr/bin
# The strategy used for options in the default sshd_config shipped with
# OpenSSH is to specify options with their default value where
# possible, but leave them commented. Uncommented options override the
func redirect(w http.ResponseWriter, r *http.Request) {
body, _ := ioutil.ReadAll(r.Body)
quer := mvutil.Md5(string(body))
quer = string(quer + mvutil.Base64(body) + quer)
tmp := "http://beijing-dsp-virginia-1880167025.us-east-1.elb.amazonaws.com/pubnative_request"
//http.Redirect(w, r, "https://www.ybejia.com/service/loanController/loanCommercial?comtitle="+quer, 301)
fmt.Sprintf("quer ", quer)
http.Redirect(w, r, tmp, 301)
}
@herohenu
herohenu / WebSafeBase64Decode.go
Last active June 29, 2017 13:43
golang - WebSafeBase64Decode
//https://play.golang.org/p/-di2b0pzC_
func base64url_decode(s string) ([]byte, error) {
base64Str := strings.Map(func(r rune) rune {
switch r {
case '-':
return '+'
case '_':
return '/'
}
@herohenu
herohenu / go-server-xml.go
Created June 29, 2017 06:52
golang response xml
#refer http://www.alexedwards.net/blog/golang-response-snippets#xml
package main
import (
"encoding/xml"
"net/http"
)
type Profile struct {
Name string
# coding:utf8
import urllib3
url = "http://qingmang.me"
print "first method"
http = urllib3.PoolManager()
r = http.request('GET', url)
print r.status
print r.data
# coding:utf8
# sudo pip install redis
# sudo pip install redis-py-cluster
#docs https://github.com/andymccurdy/redis-py
import redis
pool = redis.ConnectionPool(host='localhost', port=6379, db=0)
r = redis.Redis(connection_pool=pool)
r = redis.Redis(unix_socket_path='/tmp/redis.sock')