Skip to content

Instantly share code, notes, and snippets.

View iamspark1e's full-sized avatar
🎶
The Real Folk Blues

Wenbo iamspark1e

🎶
The Real Folk Blues
View GitHub Profile

Shadowsocks-libev Docker Image

[shadowsocks-libev][1] is a lightweight secured socks5 proxy for embedded devices and low end boxes. It is a port of [shadowsocks][2] created by @clowwindy maintained by @madeye and @linusyang.

Docker images are built for quick deployment in various computing cloud providers. For more information on docker and containerization technologies, refer to [official document][9].

Prepare the host

const express = require('express'); // Adding Express
const app = express(); // Initializing Express
const puppeteer = require('puppeteer'); // Adding Puppeteer, Run `apt-get install chromium` first (on Debian)
// Wrapping the Puppeteer browser logic in a GET request
app.get('/', function (req, res) {
// Launching the Puppeteer controlled headless browser and navigate to the Digimon website
puppeteer.launch({
headless: true,
@iamspark1e
iamspark1e / cf-worker-utils.js
Last active August 2, 2021 09:15
Some useful functions which can be used in Cloudflare Worker.
export function getCountryCode(request) { return request.headers.get('CF-IPCountry'); }
/**
* Continent-Country code mapping
* "Attention: Source data from link below, under John Snow Labs Standard License"
* @link https://datahub.io/JohnSnowLabs/country-and-continent-codes-list
* @param {string} countryCode 2 unit Country Code
* @returns Continent Code
*/
export function CountryCode2Continent(countryCode) {
const mapping = {"AF":"AS","AL":"EU","AQ":"AN","DZ":"AF","AS":"OC","AD":"EU","AO":"AF","AG":"NA","AZ":"AS","AR":"SA","AU":"OC","AT":"EU","BS":"NA","BH":"AS","BD":"AS","AM":"AS","BB":"NA","BE":"EU","BM":"NA","BT":"AS","BO":"SA","BA":"EU","BW":"AF","BV":"AN","BR":"SA","BZ":"NA","IO":"AS","SB":"OC","VG":"NA","BN":"AS","BG":"EU","MM":"AS","BI":"AF","BY":"EU","KH":"AS","CM":"AF","CA":"NA","CV":"AF","KY":"NA","CF":"AF","LK":"AS","TD":"AF","CL":"SA","CN":"AS","TW":"AS","CX":"AS","CC":"AS","CO":"SA","KM":"AF","YT":"AF","CG":"AF","CD":"AF","CK":"OC","CR":"NA","HR":"EU","CU":"NA","CY":"AS","CZ":"EU","BJ"
function _serialize(form) {
var arr = {};
console.log(form.element)
for (var i = 0; i < form.elements.length; i++) {
var feled = form.elements[i];
switch (feled.type) {
case undefined:
case 'button':
case 'file':
case 'reset':
var arr = [{"name":"中国大陆","plus":"86"},{"name":"香港地区","plus":"852","afterLength":8,"prefix":"5,6,9"},{"name":"台湾地区","plus":"886","afterLength":9,"prefix":"9"},{"name":"澳门地区","plus":"853","afterLength":8,"prefix":"6"},{"name":"澳大利亚","plus":"61","afterLength":9,"prefix":"4"},{"name":"巴西","plus":"55","afterLength":{"max":11,"min":10}},{"name":"德国","plus":"49","afterLength":{"max":11,"min":10},"prefix":"15,16,17"},{"name":"俄罗斯","plus":"7","afterLength":10,"prefix":"901,902,903,904,905,906,908,909,91,92,93,950,951,952,953,96,98,99"},{"name":"法国","plus":"33","afterLength":9,"prefix":"6,73,74,75,76,77,78"},{"name":"菲律宾","plus":"63","afterLength":10,"prefix":"9"},{"name":"韩国","plus":"82","afterLength":10,"prefix":"1"},{"name":"美国","plus":"1","afterLength":10},{"name":"柬埔寨","plus":"855","afterLength":{"max":10,"min":8},"prefix":"1,38,6,7,8,9"},{"name":"老挝","plus":"856","afterLength":{"max":10,"min":9},"prefix":"20"},{"name":"马来西亚","plus":"60","afterLength":{"max":10,"min":9},"prefix":"1"},{"name":"缅甸","plus":"95","aft
const nodemailer = require("nodemailer");
module.exports.handle = async (event, context, callback) => {
console.log("Recieved Request started at " + new Date().getTime())
const transporter = nodemailer.createTransport({
host: "example.com",
port: 25,
secure: false, // true for 465, false for other ports
auth: {
docker inspect code-server | grep IPAddress
docker run -d --restart always --name devport -p 10081:1234 alpine/socat TCP-LISTEN:1234,fork TCP-CONNECT:172.17.0.3:10081
@iamspark1e
iamspark1e / daily-mkdir.js
Created January 7, 2021 02:50
Make a folder named by today, start your work by this!
const fs = require("fs");
function autoFillZero(str) {
return parseInt(str) < 10 ? "0" + str : str;
}
function generateFolderName() {
const today = new Date();
return `${today.getFullYear()}-${autoFillZero(today.getMonth() + 1)}-${autoFillZero(today.getDate())}`
}
@iamspark1e
iamspark1e / enable-gpedit.cmd
Created November 29, 2020 17:42
Enable gpedit.msc in Windows 10 Home Edition
@echo off
pushd "%~dp0"
dir /b C:\Windows\servicing\Packages\Microsoft-Windows-GroupPolicy-ClientExtensions-Package~3*.mum >List.txt
dir /b C:\Windows\servicing\Packages\Microsoft-Windows-GroupPolicy-ClientTools-Package~3*.mum >>List.txt
for /f %%i in ('findstr /i . List.txt 2^>nul') do dism /online /norestart /add-package:"C:\Windows\servicing\Packages\%%i"
const getAssetFromKV = async (event: FetchEvent, options?: Partial<Options>): Promise<Response> => {
// Assign any missing options passed in to the default
options = Object.assign(
{
ASSET_NAMESPACE: __STATIC_CONTENT,
ASSET_MANIFEST: __STATIC_CONTENT_MANIFEST,
mapRequestToAsset: mapRequestToAsset,
cacheControl: defaultCacheControl,
defaultMimeType: 'text/plain',
},