Skip to content

Instantly share code, notes, and snippets.

View xingoxu's full-sized avatar

xingo xu xingoxu

View GitHub Profile
const Zone = {
_currentZone: {},
get current() {
return {
...this._currentZone,
fork: (zone) => {
this._currentZone = {
...this._currentZone,
...zone,
};
@xingoxu
xingoxu / cls.js
Created June 27, 2020 10:38
A simple implementation of CLS under Node.js
const {
executionAsyncId,
createHook,
} = require("async_hooks");
const { writeSync: fsWrite } = require("fs");
const log = (...args) => fsWrite(1, `${args.join(" ")}\n`);
const Storage = {};
Storage[executionAsyncId()] = {};
@xingoxu
xingoxu / privatter-no-password.js
Created May 4, 2019 22:45
See Privatter post with password
// ==UserScript==
// @name Privatter Nopassword
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author You
// @match https://privatter.net/*
// @grant none
// ==/UserScript==
@xingoxu
xingoxu / gist:2cd507bb1b3f6101e2e230afe47c27ea
Last active August 16, 2018 03:59
u2 完成种子显示做种人数
// ==UserScript==
// @name 完成种子显示做种人数
// @namespace com.xingoxu
// @version 0.1
// @author xingo
// @include /^https:\/\/u2.dmhy.org\/userdetails.php/
// @grant none
// ==/UserScript==
ajax.update = function (url, elm) {
@xingoxu
xingoxu / array.shuffle.js
Last active March 24, 2019 05:50
use CLRS RANDOMIZE-IN-PLACE
Array.prototype.shuffle = function shuffle() {
for (let i = 0; i < this.length; i++){
let randomI = Math.floor(Math.random() * (this.length - i)) + i;
let temp = this[i];
this[i] = this[randomI];
this[randomI] = temp;
}
return this;
}
#!/bin/sh
# cross & static compile shadowsocks-libev
PCRE_VER=8.40
PCRE_FILE="http://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-$PCRE_VER.tar.gz"
MBEDTLS_VER=2.4.2
MBEDTLS_FILE="https://tls.mbed.org/download/mbedtls-$MBEDTLS_VER-gpl.tgz"
@xingoxu
xingoxu / bangumi-activities.js
Last active March 7, 2017 11:43
Get bangumi activities with request & serve with express
/**
* Created by xingo on 2017/03/06.
*/
let httpClient = require('request');
let domEnv = require('jsdom').env,
jQInit = require('jquery');
function fetchTimeline(username, page) {
return new Promise((resolve, reject) => {
httpClient.get({
@xingoxu
xingoxu / github-contribution.js
Last active March 7, 2017 11:43
Get github contribution with request & serve with express
/**
* Created by xingo on 2017/03/06.
*/
let httpClient = require('request');
function fetchPage(username) {
return new Promise((resolve, reject) => {
httpClient.get({
url: `https://github.com/${username}`,
@xingoxu
xingoxu / build.js
Created January 22, 2017 11:59
simplist webpack buildjs
var webpack = require('webpack');
const webpackConfig = {
entry: './app.js',
output: {
filename: 'bundle.js',
path: './'
},
module: {
rules: [