Skip to content

Instantly share code, notes, and snippets.

import fcntl
import time
import sys
lock = file('singleapp.lock', "w+")
try:
fcntl.lockf(lock, fcntl.LOCK_EX|fcntl.LOCK_NB)
except Exception, e:
print "kill me before start again"
@jinuljt
jinuljt / securepost.go
Last active December 3, 2020 03:28
微信退款接口使用商户证书请求golang实现
import (
"bytes"
"crypto/tls"
"crypto/x509"
"io/ioutil"
"net/http"
)
wechatCertPath = "/path/to/wechat/cert.pem"
wechatKeyPath = "/path/to/wechat/key.pem"
@jinuljt
jinuljt / devtools.md
Last active December 7, 2015 16:47
技术/工具栈
@jinuljt
jinuljt / forms.go
Last active August 29, 2015 14:25
go form validate
package forms
import "github.com/gorilla/schema"
import "github.com/go-validator/validator"
var decoder = schema.NewDecoder()
func Validate(
dst interface{},
values map[string][]string) (bool, map[string][]error) {
@jinuljt
jinuljt / gofloat2int.go
Last active August 29, 2015 14:25
go float 转换 int
/*
由于float精度的问题。在现实世界中遇到下面的问题。
```
f := 4.02
i := int(f * 100.0)
fmt.Println("i = ", i)
```
> i = 401
*/
@jinuljt
jinuljt / docker_service_discovery_architecture.md
Last active August 29, 2015 14:25
docker 服务自动发现 架构实现

架构图

底层使用 shipyard这类docker cluster。

Docker container 到etcd上注册自己的地址。

HAProxy 转发请求到Docker Container。

Confd 监控 etcd,动态更新HAProxy配置,并重启。

@jinuljt
jinuljt / 各种坑.md
Last active February 5, 2018 11:41
各种坑

redis

redis 命令参数数量不能超过 1024*1024 个,包含命令哦。 比如:

SADD key 1 2 3 4...n (n <= 1024*1024 - 2)

source

emacs

#!/usr/bin/env python
#-*- coding:utf-8 -*-
# created: Mon Sep 15 13:27:15 2014
# filename: mkpasswd.py
# author: juntao liu
# email: [email protected]
# descritpion:
import datetime
import random
@jinuljt
jinuljt / golang-tls.md
Created February 22, 2017 09:30 — forked from denji/golang-tls.md
Simple Golang HTTPS/TLS Examples
Generate private key (.key)
# Key considerations for algorithm "RSA" ≥ 2048-bit
openssl genrsa -out server.key 2048

# Key considerations for algorithm "ECDSA" ≥ secp384r1
# List ECDSA the supported curves (openssl ecparam -list_curves)
openssl ecparam -genkey -name secp384r1 -out server.key