Skip to content

Instantly share code, notes, and snippets.

View tonyseek's full-sized avatar

Jiangge Zhang tonyseek

View GitHub Profile
@tonyseek
tonyseek / android-captive.sh
Last active April 2, 2024 02:49
Overrides the captive portal settings of Android in the People's Republic China mainland
#!/usr/bin/env sh
## I don't have any devices running Android OS now. These settings may have been outdated but I cannot verify it.
adb shell settings put global captive_portal_fallback_url http://g.cn/generate_204
adb shell settings put global captive_portal_http_url http://www.google.cn/generate_204
adb shell settings put global captive_portal_https_url https://www.google.cn/generate_204
adb shell settings put global captive_portal_other_fallback_urls http://www.qualcomm.cn/generate_204
import operator
class Node(tuple):
path = property(operator.itemgetter(0))
data = property(operator.itemgetter(1))
stat = property(operator.itemgetter(2))
"""
ZooKeeper Monitor
=================
This is a simple script to monitor ZooKeeper node by "mntr" command. The
command response will be collected to the statsd server.
"""
import argparse
import logging
@tonyseek
tonyseek / logging-and-gevent.py
Last active September 8, 2016 06:39
The deadlock caused by inconsistent thread ident (RLock of logging handlers)
import logging
import itertools
import gevent.monkey
class SlowHandler(logging.Handler):
def emit(self, record):
gevent.sleep(1)
@tonyseek
tonyseek / surge_to_ssx.py
Created August 23, 2016 10:37
Migrate the Surge configuration to ShadowsocksX because the Surge Mac 2.0 restricts device numbers.
#!/usr/bin/env python3
"""ShadowsocksX Migration.
This script generates ShadowsocksX profiles from the Surge configuration.
"""
import os
import json
import time
@tonyseek
tonyseek / goaway-oracle-tracking.sh
Created July 31, 2016 16:49
Go away Oracle tracking.
#!/usr/bin/env sh
set -e
mkdir -p ~/.oracle_jre_usage
sudo chown root:admin ~/.oracle_jre_usage
sudo chmod o= ~/.oracle_jre_usage
ansible all --ask-become-pass -i production -m shell -a 'curl http://update.aegis.aliyun.com/download/quartz_uninstall.sh | bash'
ansible all --ask-become-pass -i production -m shell -a 'rm -rf /usr/local/aegis'
@tonyseek
tonyseek / brew-cask-upgrade
Last active November 1, 2017 02:49
Upgrade all casks
#!/usr/bin/env bash
set -e
STAGING_LOCATION="$(brew cask doctor \
| grep -A1 '==> Homebrew-cask Staging Location:' | tail -n1 \
| awk '{print $1}')"
echo "==> Upgrading casks"
for cask in $(ls ${STAGING_LOCATION})
@tonyseek
tonyseek / Usage.md
Created August 22, 2015 12:27
QRCode generator in Flask.

How to use

from flask import Flask, render_template
from myapp.views.qrcode import bp, make_qrcode_url


app = Flask(__name__)
app.config['SECRET_KEY'] = 'random-bytes'
app.register_blueprint(bp)