Skip to content

Instantly share code, notes, and snippets.

@jinuljt
jinuljt / clear_wechat_website_data.md
Last active May 22, 2020 06:23
清除微信网页缓存(iOS)

清除safari缓存即可。  
原理是因为Apple限制,在iOS上微信只能使用webview。

1 image image image

@jinuljt
jinuljt / MacOS_Install_OpenCV.py
Created June 14, 2017 07:24 — forked from vishwanath79/MacOS_Install_OpenCV.py
Install OpenCV on Mac OS Sierra on Python 3.5
# 1. Download and install the latest Anaconda distribution from https://www.continuum.io/downloads#macos
# 2. Create a new Python environment. Make sure you choose python 3.5 as your python version for the virtual environment:
conda create -n myenv python=3.5
# 3. Activate the new environment using:
source activate myenv
@jinuljt
jinuljt / snippet.py
Created August 10, 2017 07:46
python snippet
import socket
def get_local_ip():
'''
获得本机可联网的IP
'''
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
sock.connect(("baidu.com", 80))
ip = sock.getsockname()[0]
sock.close()
@jinuljt
jinuljt / ksuid.py
Created August 14, 2017 02:57
python ksuid
import time
import uuid
def ksuid():
return hex(int(time.time()))[2:] + uuid.uuid4().hex
@jinuljt
jinuljt / streaming_template.md
Last active August 22, 2017 04:11
flask 使用模板 stream 每次返回一块数据
@jinuljt
jinuljt / python_web_server.md
Created August 24, 2017 05:11
set up a very basic web server serving files relative to the current directory.

Python3

python -m http.server

Python2

@jinuljt
jinuljt / transfer_redis.sh
Last active November 1, 2017 09:27
transfer redis database
#!/bin/bash
from="redis-cli -n 1"
to="redis-cli -n 5"
while read key;
do
$to del $key
$from --raw dump $key | head -c-1 | $to -x restore $key 0
done < <($from --scan)
@jinuljt
jinuljt / dingtalk_handler.py
Created January 2, 2018 10:53
钉钉 log handler
# -*- coding: utf-8 -*-
# created: Fri Dec 29 10:56:33 CST 2017
# filename: dingtalk_handler.py
# author: juntao liu
# email: [email protected]
# descritpion:
import json
import logging
import threading
#!/bin/bash
# require curl/wget/jq
TOKEN="<API key from https://tinypng.com/developers>"
if [ -z "$1" ]; then
echo "will create a shrink-<image_name> file"
echo ""
echo "usage:"
echo " tinypng <path/to/image.(png/jpg)>"
@jinuljt
jinuljt / tornado.md
Created May 30, 2019 17:52
tornado xheaders
app.listen(xheaders=True)

If xheaders is True, we support the X-Real-Ip/X-Forwarded-For and X-Scheme/X-Forwarded-Proto headers, which override the remote IP and URI scheme/protocol for all requests. These headers are useful when running Tornado behind a reverse proxy or load balancer. The protocol argument can also be set to https if Tornado is run behind an SSL-decoding proxy that does not set one of the supported xheaders.