Skip to content

Instantly share code, notes, and snippets.

View j178's full-sized avatar
🕶️
Living

Jo j178

🕶️
Living
View GitHub Profile
@j178
j178 / strip.py
Last active September 1, 2017 03:36
Self implemented strip funciton compared to built-in
from string import whitespace
import timeit
def strip(string, chars=whitespace):
if not isinstance(string, (str, bytes)) \
or not isinstance(chars, type(string)):
raise ValueError
left = 0
for left, s in enumerate(string):
@j178
j178 / base64.py
Created August 31, 2017 12:19
Reinvent the wheel: implemente base64 encoding and decoing in Python.
CHARS = b'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
NUMS = [62, 0, 0, 0, 63,
*range(52, 62),
0, 0, 0, 0, 0, 0, 0,
*range(26),
0, 0, 0, 0, 0, 0,
*range(26, 52)]
def to_val(c):
#!/usr/bin/env python3
import re
import requests
import base64
sess = requests.Session()
target = 'http://localhost/discuzx/'
# login target site first, and copy the cookie here
#!/usr/bin/env python3
import base64
import random
import re
import string
import requests
sess = requests.Session()
randstr = lambda len=5: ''.join(random.choice(string.ascii_lowercase) for _ in range(len))

Keybase proof

I hereby claim:

  • I am j178 on github.
  • I am j178 (https://keybase.io/j178) on keybase.
  • I have a public key ASDwwkUUC1UvGUF2DjZudNwJTDU-SrydNVpaIk4AudKdrQo

To claim this, I am signing this object:

@j178
j178 / chrome_cookie.py
Last active August 22, 2018 03:28
Extract host cookies from Chrome cookie databse
@j178
j178 / Flask-SQLAlchemy Caching.md
Last active October 31, 2023 15:20 — forked from typehorror/Flask-SQLAlchemy Caching.md
Flask SQLAlchemy Caching

Flask-SQLAlchemy Caching

The following gist is an extract of the article Flask-SQLAlchemy Caching. It allows automated simple cache query and invalidation of cache relations through event among other features.

Usage

retrieve one object

# pulling one User object

user = User.query.get(1)

<?php
return sg_load('0A01FEFE4CDFE8DCAAQAAAAXAAAABGgAAACABAAAAAAAAAD/sFFonI5E/xv0Nvko1nt1cGvdcCQ4+0AB/9a1drcirnIeprf0fSXAGndgenGD2Ms2f8fi/9yfLRReY4diC1jorYd5LwPpUowSHZHD8Dd099AqqgbALH0AB3A3LUKyPQ7926nUlY7+bY5HAAAA0HoAACjRDNeVsiYzLV1PKBsL2t0MHQ775l6xpFj0FHgJGti7Iw/EPyzMdwTvZH4jkwKfkqg89CmZy1pmn//8qYDSUHJsAgJt4hP48dl8mUPcqEIZKFZ3qT0DNHr8wDPOuvgq0xq+RMBafv/K7ePfEbsf+C5W43npf+BRBN/0f7iZQZvtRUz4X6VjoX4as0lMV85HztwDEVhlPKV8QHfnjLJqcgr2G3/+60Dpl7Zak8JiGdz5VALT4/Vskguk8fnpJvA2Y/B1a9hA67mWeXg+/c1VM1liU14LdPcq6dziVQ8ty9bWWWLHCj3Yr5gVL6rf3E1HuFiO3muXRUsJdRojOh4iaZVthuLwiyykAQeRVDBcfAhvXRkhA8SNrIE+3D37xVXZiyPeyo1LF24v/nu4aJdT5i4lVIVH1Z744NTxG9DUaMd7b7cLqG1KAaIW29YbOUSmLD7+PTdmsXwV1QWWLcQqxX6ppad8XUkYA0OlV6LAtnxoG+UdJzhfeZEsHnkXctM2VcLx6DhMHl7ZTfxVB9nyEqmumufWJzyamcQc2Ch7u7MlYY44TD+H177xzaua+CQlSS53gEmK/bxktKFqJc0XMWDKiaK/ooaQpfFD9yKTZ96AZ6smnwNJu3AcvGEuQv3/MuYWzkAvgcRteukU4mRI9I4yL0D+IIgmZWs++VecXElOEgPZvbRMUfAYRpp2LHvyv1Q95R3dkg3KlBrHLNFhFeaQ/uOw7jAl4LeN6EWDFaiWSY53Qde4b8tzkHC4PMFpHlCy6f4zKRBtet92D8sUR+w2inoTdz2pTyxpi5
@j178
j178 / github_batch_block.py
Last active December 19, 2019 12:11
批量 block 用中文污染 issue 的人
# -*- coding: utf-8 -*-
# Created by johnj at 2019/12/19
"""
批量 block 用中文污染 issue 的人
需要设置 USERNAME 和 TOKEN 两个环境变量
USERNAME 为 GitHub 用户名
TOKEN 获取参考这里:# https://help.github.com/en/github/authenticating-to-github/creating-a-personal-access-token-for-the-command-line
"""
from threading import Event, Thread
event1 = Event()
event2 = Event()
event3 = Event()
i = 0
def f1():
global i