Skip to content

Instantly share code, notes, and snippets.

View jt-wang's full-sized avatar

Jingtao Wang jt-wang

View GitHub Profile
@jt-wang
jt-wang / type-guard.js
Last active February 25, 2024 08:56 — forked from cyyyu/type-guard.js
// ==UserScript==
// @name Type Guard
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author Chuang Yu
// @match *://*/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=google.com
// @grant none
// ==/UserScript==
@jt-wang
jt-wang / delete_douban_traces.js
Last active December 24, 2016 15:35
删除豆瓣相关
javascript: void(function() {
/*删除书影音*/
/*you can replace this with "movie" or "music"*/
var douban_type = "book";
var send_delete = function(sid) {
$.post_withck("https://" + douban_type+ ".douban.com/j/mine/j_cat_ui",
{sid: sid})
};
if ($("a.d_link").length > 0) {
# Surge for Mac 配置文件
# 显示 Finder 隐藏文件,将 .surge.conf 文件复制到 ~/ 也就是「个人」目录下。
[General]
# warning, notify, info, verbose
loglevel = notify
skip-proxy = 192.168.0.0/16, 10.0.0.0/8, 172.16.0.0/12, 100.64.0.0/10, localhost, *.local, e.crashlytics.com, apple.cn
bypass-tun = 0.0.0.0/8, 1.0.0.0/9, 1.160.0.0/11, 1.192.0.0/11, 10.0.0.0/8, 14.0.0.0/11, 14.96.0.0/11, 14.128.0.0/11, 14.192.0.0/11, 27.0.0.0/10, 27.96.0.0/11, 27.128.0.0/9, 36.0.0.0/10, 36.96.0.0/11, 36.128.0.0/9, 39.0.0.0/11, 39.64.0.0/10, 39.128.0.0/10, 42.0.0.0/8, 43.224.0.0/11, 45.64.0.0/10, 47.64.0.0/10, 49.0.0.0/9, 49.128.0.0/11, 49.192.0.0/10, 54.192.0.0/11, 58.0.0.0/9, 58.128.0.0/11, 58.192.0.0/10, 59.32.0.0/11, 59.64.0.0/10, 59.128.0.0/9, 60.0.0.0/10, 60.160.0.0/11, 60.192.0.0/10, 61.0.0.0/10, 61.64.0.0/11, 61.128.0.0/10, 61.224.0.0/11, 100.64.0.0/10, 101.0.0.0/9, 101.128.0.0/11, 101.192.0.0/10, 103.0.0.0/10, 103.192.0.0/10, 106.0.0.0/9, 106.224.0.0/11, 110.0.0.0/7, 112.0.0.0/9, 112.128.0.0/11, 112.192.0.0/10, 113.0.0.0/9, 113.128.0.0/11, 113.192.0.0/
class User(flask_login.UserMixin):
    def __init__(self, username):
        self.username = username
        self.id = username
        
    @staticmethod
    def get(username):
        return User(username)

写在内部没有出错,登录之后再 去 /login 页面 会返回一个 json。

    @app.route('/login', methods=['GET', 'POST'])
    def login():
        if request.method == 'GET':
            if flask_login.current_user is not None and flask_login.current_user.is_authenticated:
                return jsonify({'status': False, 'cause': 'already logged in'})

如果用装饰器,则flask_login失效:登录请求发送后,不返回login()里写的返回值,却会立刻返回装饰器里的json,当然,此时 flask_login.current_user.is_authenticated == True ,但是奇怪的是并没有登录成功。再进入/login 也不会被 before_login_only 拦截下来。

@jt-wang
jt-wang / Surge.md
Created October 26, 2015 12:15 — forked from soffchen/Surge.md
Surge

Feature

  • 替代 PAC,实现根据规则区分选择代理线路
  • 支持 SOCKS5 和 Shadowsocks 协议
  • 完整支持所有的 Shadowsocks 加密方式 (table, rc4-md5, salsa20, chacha20, aes-256-cfb, aes-192-cfb, aes-128-cfb, bf-cfb, cast5-cfb, des-cfb, rc2-cfb, rc4, seed-cfb)
  • 全面支持双向 HTTP Keep-Alvie
  • 快,各种黑科技加速
  • 直接临时修改某个域名的访问规则 (暂时仅 Mac 版本)
  • 支持使用 GeoIP 规则决定线路

Usage

#try gist It is my first time to use gist as a blog. I'd like to share with the world ideas and methods.