Skip to content

Instantly share code, notes, and snippets.

View jackiect's full-sized avatar
💭
I may be slow to respond.

Jack jackiect

💭
I may be slow to respond.
View GitHub Profile
#!/usr/bin/python
# -*- coding: utf-8 -*-
from flask import request, url_for
from flask.ext.api import FlaskAPI, status, exceptions
app = FlaskAPI(__name__)
notes = {
@jackiect
jackiect / A.md
Last active May 13, 2016 03:10
Docker搭建开发环境

Docker搭建开发环境

@jackiect
jackiect / jninja模版与编码.md
Last active May 5, 2016 08:04
python flask/jinja...

jinja渲染模版时,参数中的非ASCII内容必须是unicode类型

所以以下写法均会抛出UnicodeDecodeError

  • template.render(name="校长")
  • template.render(re={"name": "校长"})

结论二

  • jinja模版中,字符串字面量如{{ }},local变量等中显示给出字符串数据可以是str或unicode,即{{ "校长" }}{{ u"校长" }}都是正确的,{% set a, b = '校长', u'校长' %}
  • 传给jinja模版中的python变量中的字符串数据必须是unicode,这些变量包括global变量、context变量和filters函数返回的值
@jackiect
jackiect / A.md
Last active November 5, 2016 07:37
典型web安全问题
@jackiect
jackiect / qps-from-access-log.md
Last active January 7, 2020 14:27
qps from access log

command

cat access_log |cut -d " " -f4|sort |uniq -c |sort -n -r

PS: cut -d " " -f4 equals to awk -F " " '{print $4}'

#!/usr/bin/env bash
SESSION="vs@`pwd |rev |cut -f1 -d/ |rev| cut -f2 -d.`#`pwd |md5sum |cut -c1-7`"
tmux attach -d -t $SESSION || tmux new -s $SESSION
@jackiect
jackiect / rongyun-api.md
Last active March 26, 2020 09:28
rongyun

https://docs.rongcloud.cn/im/server/signature/#_2

curl -X POST -H "App-Key: uwd1c0sxdlx2" -H "Nonce: 14314" -H "Timestamp: 1408710653000" -H "Signature: `echo -n Y1W2MeFwwwRxa0143141408710653000|sha1sum |awk '{printf $1}'`" -d 'userId=jlk456j5&name=Ironman&portraitUri=http%3A%2F%2Fabc.com%2Fmyportrait.jpg' "https://api-cn.ronghub.com/user/getToken.json"
curl -X POST -H "App-Key: 0vnjpoad0i1uz" -H "Nonce: $(date '+%s'|tail -c 6)" -H "Timestamp: $(date '+%s')" -H "Signature: `echo -n FZ****Pwbs$(date '+%s'|tail -c 6)$(date '+%s')|sha1sum |awk '{printf $1}'`" -d 'userId=jlk456j5&name=Ironman&portraitUri=http%3A%2F%2Fabc.com%2Fmyportrait.jpg' "https://api-cn.ronghub.com/user/getToken.json"

{"code":200,"userId":"jlk456j5","token":"Vk9O2dRLPlRYXDOv4zGBEXcjTUnCGVETk65A/2iMccLZF2uk0LUN6TJLNRHJ1NzsLVRliU5BLcgGWb3oTd3OXQ=="}
#!/usr/bin/env bash
result='\n'
for m in $(docker-machine ls -f '{{.Name}}')
do
result=$result"Host docker-machine-$(docker-machine inspect -f '{{.Driver.MachineName}}' $m)"'\n'
result=$result" HostName $(docker-machine inspect -f '{{.Driver.IPAddress}}' $m)"'\n'
result=$result" User $(docker-machine inspect -f '{{.Driver.SSHUser}}' $m)"'\n'
result=$result" IdentityFile $(docker-machine inspect -f '{{.Driver.SSHKeyPath}}' $m)"'\n'
@jackiect
jackiect / Makefile
Created July 7, 2020 03:57
makefile google oauth2 requests
GOOGLE_AUTH_PAGE=https://accounts.google.com/o/oauth2/auth
# GOOGLE_AUTH_PAGE_V2=https://accounts.google.com/o/oauth2/v2/auth
GOOGLE_TOKEN_API=https://oauth2.googleapis.com/token
GOOGLE_TOKEN_INFO_API=https://oauth2.googleapis.com/tokeninfo
# GOOGLE_TOKEN_INFO_API_V3=https://www.googleapis.com/oauth2/v3/tokeninfo
GOOGLE_REVOKE_API=https://oauth2.googleapis.com/revoke
GOOGLE_USERINFO_API_V3=https://www.googleapis.com/oauth2/v3/userinfo
GOOGLE_USER_PROFILE_API=https://www.googleapis.com/auth/userinfo.profile