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
@iamspark1e
iamspark1e / hot-reload-extension.js
Created September 16, 2020 08:07
Enable hot reload for Chrome Extension in Dev Mode.
const filesInDirectory = dir => new Promise(resolve =>
dir.createReader().readEntries(entries =>
Promise.all(entries.filter(e => e.name[0] !== '.').map(e =>
e.isDirectory ?
filesInDirectory(e) :
new Promise(resolve => e.file(resolve))
))
.then(files => [].concat(...files))
.then(resolve)
)
const customKey = require("../vars").customKey
const XORCipher = {
encode: function (data) {
data = xorStrings(customKey, data);
return btoa(data);
},
decode: function (data) {
data = atob(data);
return xorStrings(customKey, data);
var wCodeMap = {
"0": "sunny", // "晴",
"1": "cloudy", // "多云",
"2": "overcast", // "阴",
"3": "shower", // "阵雨",
"4": "thundery-shower", // "雷阵雨",
"5": "hail", // "冰雹",
"6": "sleet", // "雨夹雪",
"7": "drizzle", // "小雨",
"8": "rain", // "中雨",
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',
},
@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"
@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())}`
}
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
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: {
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
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':