Skip to content

Instantly share code, notes, and snippets.

@jinuljt
jinuljt / report_export.user.js
Last active August 13, 2021 07:06
report_export.user.js
// ==UserScript==
// @name report export
// @namespace https://gist.github.com/jinuljt/b8c3a2ee5a61bc81cc20b163fd7d30de/
// @version 0.1
// @description 导出坎弓骑会战报表
// @author gugu
// @match https://www.bigfun.cn/tools/gt/t_report
// @icon https://www.google.com/s2/favicons?domain=bigfun.cn
// @grant GM_setClipboard
// ==/UserScript==
@jinuljt
jinuljt / water_sort_puzzle_solver.py
Last active April 15, 2021 09:45
水排序拼图 python soulver
"""
version 1 穷举
# 一个瓶子有4段水
# 瓶子初始化,每一段水可以为不同颜色
# 每次倒出一种颜色(多段水一次倒出)
# 倒入颜色必须与瓶子最上层颜色相同
#
# 数字表示水的颜色
## filter 坑
已知有field {"host": "<ip>"}
想要转换为:
{"host": {"ip": "<ip>", "name": "<hostname>"}
以下方法都失败了,改用 {"new_host": {"ip": "<ip>", "name": "<hostname>"} 可以成功。应该是重用field会继承之前的类型导致的。目前没找到方案。
- mutate rename/add_field
- ruby
@jinuljt
jinuljt / nginx.md
Last active January 27, 2021 09:41

HTTP自定义Header (HTTP user-defined header)

明道云私有化部署遇到的坑。它使用了一个自定义http header md_pss_id

根据nginx文档说明,自定义header默认不会传递给upstream。

By default, nginx does not pass the header fields “Date”, “Server”, “X-Pad”, and “X-Accel-...” from the response of a proxied server to a client. The proxy_hide_header directive sets additional fields that will not be passed. If, on the contrary, the passing of fields needs to be permitted, the proxy_pass_header directive can be used.

需要如下配置:

version: '3'
services:
server:
image: parseplatform/parse-server:latest
restart: always
ports:
- '10020:1337'
environment:
PARSE_SERVER_DATABASE_URI: mongodb://mongo/parse-server
@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.

#!/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 / 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: jinuljt@gmail.com
# descritpion:
import json
import logging
import threading
@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 / 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