Skip to content

Instantly share code, notes, and snippets.

View ncwhale's full-sized avatar
🎯
Focusing on Game!

Whale Mo ncwhale

🎯
Focusing on Game!
  • Tokyo, Japan
  • 04:28 (UTC +09:00)
View GitHub Profile
function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
async function removeduplicates() {
let titles = document.querySelectorAll('#primary #video-title')
let href_pattern = RegExp('https?://www\\.youtube\\.com/watch\\?v=[^&]*&list=[^&]*&index=')
titles = Array.from(titles).filter(t => href_pattern.test(t.href))
let exists = {}
@ncwhale
ncwhale / wordle_gusser.py
Last active January 29, 2022 07:19
A simple tool for wordle game.
# interactive word guesser
from functools import lru_cache
import re
import string
@lru_cache
def load_dictionary(filename) -> list:
words = []
file = open(filename, "r", encoding="utf-8")
@dp.message_handler(chat_ctx_filter, commands={'count'})
async def count_handler(event: types.Message, chat_ctx: Chat):
'+1s for every call'
with db.transaction_manager as trans:
trans.note(u"Count")
chat_count = chat_ctx.addCount()
delay_task = asyncio.create_task(asyncio.sleep(5))
await event.chat.do('typing')
await event.delete()
@ncwhale
ncwhale / ZODBstorage.py
Created October 18, 2020 10:02
A simple aiogram storage impl on ZODBstorage.
import copy
import typing
import transaction
from aiogram.dispatcher.storage import BaseStorage
from BTrees.LOBTree import BTree
from ZODB import DB
class ZODBStorage(BaseStorage):
{
"compilerOptions": {
"lib": [
"ES2020"
],
"target": "ES2020",
"module": "ES2020",
"moduleResolution": "node",
"allowSyntheticDefaultImports": true,
"outDir": "./build",
@ncwhale
ncwhale / pack.js
Last active October 10, 2020 09:41
Node.js script for pack .epub resources.
const fs = require('fs')
const path = require('path')
const archiver = require('archiver')
var base_path = './epubs'
async function main() {
const dir = await fs.promises.opendir(base_path)
const books = {}
for await (const ent of dir) {
@ncwhale
ncwhale / gist:5311c4e8afb26555de84dbf53a2e51d2
Created June 15, 2020 11:08
Plugin for arealme.com/colors/zh/
function ZhongChuPanTu(){let l=document.querySelector("#box");if("none"===l.children[0].style.display)return;let r="";if(l.children[0].style.backgroundColor!=l.children[1].style.backgroundColor)return l.children[0].style.backgroundColor==l.children[2].style.backgroundColor?void l.children[1].click():(l.children[0].click(),l.children[0]);r=l.children[0].style.backgroundColor;for(let o of l.children)if(o.style.backgroundColor!=r)return void o.click()}ZhongChuPanTu();
@ncwhale
ncwhale / Desktop Play.sh
Last active June 4, 2020 17:53
Play any video on your Cinnamon( nemo-desktop ) Desktop using mpv.
#!/bin/bash
DESKTOP_WID=$(xdotool search --onlyvisible --classname "nemo-desktop" | head -n 1)
mpv --no-border --no-audio --osc=no --title="Desktop" --loop-playlist --wid="$DESKTOP_WID" "$@"
#!/bin/bash
MAC="1234567890AB"
COOKIE_FILE="/tmp/router_cookie.txt"
function fetch_result() {
local R=$(curl -s -b "$COOKIE_FILE" 'http://192.168.1.1/cgi-bin/luci/admin/device/devInfo?type=0&_=0.'"$(date +\"%s\")" | jq '.count = {}| .curip = {} | .[] | select(.mac)')
date
echo "$R" | jq --raw-output '"\(.mac)\t\(.ip)\t\(.restrict)\t\(.upSpeed)\t\(.downSpeed)"'
# This function will automate grep CMD($1) windows and set OPACITY($2).
transparent_windows() {
for i in $(pgrep -f $1); do
for j in $(/usr/bin/xdotool search --pid $i); do
xprop -id $j -f _NET_WM_WINDOW_OPACITY 32c -set _NET_WM_WINDOW_OPACITY $(printf 0x%x $((0xffffffff * $2 / 100)));
done
done
}
# Give vscode an alias.