X-Forwarded-For 是由 Squid 引入的, 被引入 RFC7239 标准中,X-Forwarded-For 格式
X-Forwarded-For: client, proxy1, proxy2
值代表 离服务端最远的设备 IP + 每一级代理设备的 IP
上面的 XFF 代表访问由 client 发起,经过了 proxy1,proxy2 两台代理,此外还有终端代理 proxy3, 它的 IP 在 Remote Address
| /* | |
| * 将 Mongo 生成的 ObjectId 转为 datetime/timestamp | |
| * 考虑时区因素 | |
| */ | |
| DROP FUNCTION f_oid_2_gen_time(oid varchar); | |
| CREATE FUNCTION f_oid_2_gen_time | |
| (oid varchar(30)) | |
| RETURNS timestamp | |
| IMMUTABLE |
| #!/usr/bin/python | |
| from multiprocessing import Pool | |
| msg_list = [ | |
| 'add|(1,2,3)', | |
| 'sqrt|(3,)', | |
| 'sqrt|(5,)', | |
| 'add|(4,5,6)', | |
| ] |
| // Use Gists to store code you would like to remember later on | |
| console.log(window); // log the "window" object to the console |
X-Forwarded-For 是由 Squid 引入的, 被引入 RFC7239 标准中,X-Forwarded-For 格式
X-Forwarded-For: client, proxy1, proxy2
值代表 离服务端最远的设备 IP + 每一级代理设备的 IP
上面的 XFF 代表访问由 client 发起,经过了 proxy1,proxy2 两台代理,此外还有终端代理 proxy3, 它的 IP 在 Remote Address
| #/usr/bin/python3 | |
| """ | |
| pip install git+git://github.com/CooperLuan/pubnub.git | |
| """ | |
| import os | |
| import json | |
| import threading | |
| import inspect | |
| import ctypes | |
| import time |
| # IllegalCharacterError in pandas.DataFrame.to_excel(encoding='GB18030') | |
| """ | |
| 具体的报错信息显示错误是在 openpyxl.cell.cell.py 抛出的 | |
| 原因是不匹配 re.compile(r'[\000-\010]|[\013-\014]|[\016-\037]') | |
| 所以用这个正则处理 pandas 中的字符结果即 | |
| """ | |
| df.apply(lambda x: re.sub(rr'[\000-\010]|[\013-\014]|[\016-\037]', r' ', x['field'], re.S)) |
| from collections import defaultdict | |
| # Using default dictionaries to represent simple trees | |
| # Link http://sahandsaba.com/thirty-python-language-features-and-tricks-you-may-not-know.html#using-default-dictionaries-to-represent-simple-trees | |
| tree = lambda :defaultdict(tree) | |
| root = tree() | |
| root['id'] = 'File' | |
| root['value'] = 'File' | |
| root['items'][0] = 'Open' | |
| root['items'][1] = 'Close' |
| """ | |
| pip install schema | |
| check if people can retire(age 65 for male, 60 for female) | |
| """ | |
| from schema import Schema, And, Use, Optional | |
| schema = Schema([{ | |
| 'name': And(str, len), |
| # encoding: utf8 | |
| import logging | |
| logging.basicConfig(level=logging.INFO) | |
| from flask import make_response, jsonify | |
| from flask import abort, redirect | |
| from flask import Flask, request | |
| app = Flask('info-center') |