This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// IMPORTANT: THIS SCRIPT ONLY WORKS IN SYSTEM WHICH SUPPORT UNIX SOCKET! | |
import fs from 'node:fs' | |
import http from 'node:http' | |
import path from 'node:path' | |
async function lock_server(lock_service_path) { | |
const server = http.createServer((req, res) => { res.end("ok") }) | |
// make sure this server doesn't keep the process running | |
server.unref() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 = {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import copy | |
import typing | |
import transaction | |
from aiogram.dispatcher.storage import BaseStorage | |
from BTrees.LOBTree import BTree | |
from ZODB import DB | |
class ZODBStorage(BaseStorage): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"compilerOptions": { | |
"lib": [ | |
"ES2020" | |
], | |
"target": "ES2020", | |
"module": "ES2020", | |
"moduleResolution": "node", | |
"allowSyntheticDefaultImports": true, | |
"outDir": "./build", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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" "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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)"' |
NewerOlder