Skip to content

Instantly share code, notes, and snippets.

View w1ndy's full-sized avatar

Di Weng w1ndy

View GitHub Profile
@w1ndy
w1ndy / BlobInflator.js
Last active June 9, 2021 17:29
Inflate gzipped JSON blobs in JavaScript with pako and WebWorker (worker-loader via Webpack)
import { randomString } from './Helpers'
import BlobInflatorWorker from './BlobInflator.worker'
const worker = new BlobInflatorWorker()
const handlers = {}
worker.onmessage = function (e) {
if (!e.data.error) {
handlers[e.data.key].resolve(e.data.json)
} else {
@w1ndy
w1ndy / dst_chat_log_analyzer.py
Last active March 29, 2021 23:24
Analyzing chat log 'server_chat_log.txt' produced by Don't Starve Together
#!/usr/bin/python3
import sys
import re
import operator
import json
from enum import Enum
class EventType(Enum):
@w1ndy
w1ndy / socks5.acl
Created December 19, 2016 08:00
Simple SOCKS5 proxy based on systemctl, iptables and ssh with access control
# Put under /etc/
# SOCKS5 proxy access control
# One IPv4 address per line
127.0.0.1
@w1ndy
w1ndy / cell_station_search.py
Created November 16, 2016 06:17
Query base station information by LAC and cell ID from cellocation.com
#!/usr/bin/python3
import requests
import time
import json
INPUT_FILE = 'diff.csv'
OUTPUT_FILE = 'diff.out.csv'
THRESHOLD = 290 #times
THRESHOLD_TIME = 300.0 #sec
@w1ndy
w1ndy / rdd.sh
Created November 13, 2016 15:07
Delaying for random seconds and executing a command
#!/bin/bash
# random_delay_and_do
# DELAY={{seconds}} ./rdd.sh {{COMMAND}} will force delay setting to {{seconds}}
hours=3
maxdelay=$(($hours*60*60))
rand=$(($RANDOM*1234%maxdelay))
delay=${DELAY:-$rand}
echo "sleeping $delay"
@w1ndy
w1ndy / remove_csv_space.py
Created November 13, 2016 15:01
Remove spaces padded to columns in CSV with progress indicator
#!/usr/bin/python3
import sys
from tqdm import tqdm
from os.path import splitext, basename, dirname, abspath, join, getsize
def main():
if len(sys.argv) < 2:
print('Usage: %s ...csv_files' % sys.argv[0])
exit()
@w1ndy
w1ndy / getvoucher.py
Created November 13, 2016 14:46
Get voucher from Tencent Cloud
#!/usr/bin/python3
import requests
import json
requests.packages.urllib3.disable_warnings()
# Fill in {{variables}} below
COOKIE = '{{PASTE YOUR OWN COOKIE HERE}}'
REQUEST_URL = '/act/campus/ajax/index?uin={{QQ NUMBER}}&csrfCode={{CSRF CODE}}' # Get URL from Chrome inspector
@w1ndy
w1ndy / seccomp.json
Created September 20, 2016 15:27
Allowing numactl in docker container
{
"defaultAction": "SCMP_ACT_ERRNO",
"architectures": [
"SCMP_ARCH_X86_64",
"SCMP_ARCH_X86",
"SCMP_ARCH_X32"
],
"syscalls": [
{
"name": "accept",
@w1ndy
w1ndy / cspline.js
Created August 6, 2016 13:46
Evaluating cardinal splines
/*global sampler, drawPoints, pointString, lastOf */
function CSpline(points, variance) {
this.tension = 0.2;
this.points = points;
this.variance = variance || points.map(function () { return 0; });
this.interval = this.points[this._nextpi(0)].x - this.points[0].x;
this.tangent = points.map(function (d, i) {
var previ = this._prevpi(i),
nexti = this._nextpi(i);

Keybase proof

I hereby claim:

  • I am w1ndy on github.
  • I am skies457 (https://keybase.io/skies457) on keybase.
  • I have a public key whose fingerprint is E57E F50F 6B90 47AF CA6B 2FA6 743D C317 CCB3 9680

To claim this, I am signing this object: