Skip to content

Instantly share code, notes, and snippets.

Avatar

Liu Wenyuan Dobby233Liu

View GitHub Profile
@Dobby233Liu
Dobby233Liu / gtimedToSRT.js
Last active Mar 8, 2021
Translates YouTube timed text to SRT. WTFPL. WIP.
View gtimedToSRT.js
// parse-ms
// MIT License, copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
// Modified by Dobby233Liu in slight cooperation with MIT License
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
// The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
@Dobby233Liu
Dobby233Liu / sortNumbers.js
Last active Mar 24, 2020
sort numbers to a category for them
View sortNumbers.js
function isPrime(num) // https://blog.csdn.net/huang_miao_xin/article/details/51331710
{
if(num == 2 || num == 3) return true;
if(num % 6 != 1 && num % 6 != 5) return false; // 不在6的倍数两侧的一定不是质数
var tmp = Math.sqrt(num);
for(var i = 5; i <= tmp; i += 6) if(num % i == 0 || num % (i + 2) == 0) return false; // 在6的倍数两侧的也可能不是质数
return true; // 排除所有,剩余的是质数
}
function sortNumbers(data = [27, 37, 41, 58, 61, 73, 83, 95, 11, 14, 33, 47, 57, 62, 87, 99]){
var output = {primes: [], composites: [], odds: [], evens: []};
@Dobby233Liu
Dobby233Liu / random.js
Last active Mar 8, 2020
random strangires for js [might update]
View random.js
// random strangires based on Math.random [1, inefficine, unstable and wastes time]
Math_random1_part1=()=>Math.sinh(Math.cos(Math.atan(Math.tan(Math.random()*0.124231332135)))*0.252346/Math.LOG2E)%(+(new Date)/Math.LN2%Math.SQRT1_2*Math.E)/(Math.random()*0.043446566)*(Math.random()*0.0011124514%Math.random()+0.0011222)
Math_random1=()=>{
var m = Number(Math_random1_part1()).toString().split("");
var m2 = m.slice(2);
for (let i = m2.length - 1; i > 0; i--) {
const j = Math.floor(Math_random1_part1() * (i + 1));
[m2[i], m2[j]] = [m2[j], m2[i]];
}
var r=parseFloat(m[0]+m[1]+m2.join(""));
@Dobby233Liu
Dobby233Liu / list.adp
Created Mar 2, 2020
my adblock plus block rules
View list.adp
fosshub.com##.ad-alt
msfn.org##.ipsMessage.ipsMessage_error.ipsfocus-globalMessage.displayGlobalMessage
imooc.com##.modal-backdrop.in
imooc.com###signin
imooc.com##.rl-modal.in
thememypc.net##.k*-container.k*-2.k*-hide
zhihu.com##.AdblockBanner
jsp.d2l.workers.dev##.jquery-modal.blocker.current
jsp.d2l.workers.dev###oyahpzunevwwuoc-overlay
2heng.xin##.ad-container
View a.js
index = [
{
obj: window.getListByCountryTypeService1,
data: {
creationDate: "createTime",
modifiedDate: "modifyTime",
op: "operator"
}
},
{
@Dobby233Liu
Dobby233Liu / apiDoc.js
Last active Feb 12, 2020
pcode api documentation for https://github.com/BlankerL/DXY-2019-nCoV-Crawler. UNMAINTAINED, DON'T USE!
View apiDoc.js
ResultLayoutObject = Object;
baseResultLayout
= {
"results": /**@Nullable**/[ResultLayoutObject, ...], /** could be empty when !success **/
"success": Boolean,
"msg": /**@Nullable**/String // this variable should exist if !success
};
JSTime13n = Number;
URLString = String;
overallResultLayout
@Dobby233Liu
Dobby233Liu / px2cfw.js
Last active Jan 29, 2020
px2cfw but it's a special ncov api edition... demo: https://ncov-api-mirror.d2l.workers.dev/
View px2cfw.js
addEventListener('fetch', event => {
event.respondWith(handleRequest(event.request))
})
var BASE_URL = "https://lab.isaaclin.cn/nCoV";
var HOST_URL = "https://github.com/Dobby233Liu";
var HOST_NNM = "Dobby233Liu";
var CREDITS_HTML
= `
由<a href="${HOST_URL}">${HOST_NNM}</a>镜像。此镜像根目录直通原api目录,无需添加/nCoV在目录名前(虽然会自动处理)。原api:<a href="${BASE_URL}">${BASE_URL}</a>。<hr />`
var CREDITS_INSERT_AFTER_FIRST_ENTRY_OF = `body > div > p`;
@Dobby233Liu
Dobby233Liu / xiaoxiao_tts.py
Last active Jan 24, 2021 — forked from xjohjrdy/xiaoxiao_tts.py
superb edit of an old parameterless script
View xiaoxiao_tts.py
#!/usr/bin/env python
# -*- coding:utf-8 -*-
"""Edge Microsoft TTS for Python."""
import sys
from ws4py.client.threadedclient import WebSocketClient
import binascii
import argparse
import json
import requests
import re
@Dobby233Liu
Dobby233Liu / 42.js
Last active Nov 3, 2019
42.js - quickjs bytebeat isolated loader stub, named after the famous 42 melody
View 42.js
/**
* 42.js - quickjs bytebeat isolated loader stub, named after the famous 42 melody
* code: @Dobby233Liu
* WTFPL
* fill up the code(t) section, build using qjsc https://bellard.org/quickjs/ then pipe to anything eg. aplay
* i recommend use node.js more than quickjs, its better, and quickjs is in beta.
* example program using node.js: bytebeat.jsV2.0 https://pastebin.com/xwtRgcfV
* gist: https://gist.github.com/Dobby233Liu/157e2438dcfb7a31209616404b301759
**/
import * as std from 'std'
@Dobby233Liu
Dobby233Liu / main.js
Last active Oct 26, 2019
getIllustUrl. it's useless, maybe... you can also get nsfw illust image url using this.
View main.js
/**
* getIllustUrl - DevTools console script to get pixiv illust original image... in it's page
* Written by GitHub@Dobby233Liu
* Public Domain, take the below function is free too.
* note: this script will output to console. output may be:
* url and data (success), boolean and error message, including "GET xxx 4xx/5xx" (api error), or "uncaught error" (something gone wrong)
* offical version always at: https://gist.github.com/Dobby233Liu/1e61dccc9f67156157bcf15387319566
**/
getIllustUrl = (illustID, cb, httpErrorCB) => {
fetch("https://www.pixiv.net/ajax/illust/" + illustID)