./avatar.png
should be the targeted avatar file.- Setup
Pyrogram
(MTProto
) at first: https://docs.pyrogram.ml/start/ProjectSetup.
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/sh | |
# Copyright (C) 2020 Michel Stam <michel@reverze.net> | |
# Copyright (C) 2021 Hung-I Wang <whygowe@gmail.com> | |
# | |
# The script is adatped from: | |
# https://github.com/ndilieto/uacme/blob/5edec0eea1bcf6f454ec1787297c2408c2f2e97a/nsupdate.sh | |
# | |
# Licensed under the the GNU General Public License <http://www.gnu.org/licenses/>. | |
# The script is meant to be used as a hook script of uacme to update TXT records for acme challenges. |
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
async function downloadBook(aid, bid) { | |
const [title, myreader, kime, fime] = await getBookKey(aid, bid) | |
const r = await fetch(`http://read.nlc.cn/menhu/OutOpenBook/getReader?aid=${aid}&bid=${bid}&kime=${kime}&fime=${fime}`, { method: "POST", headers: { myreader: myreader }}) | |
const d = await r.arrayBuffer() | |
saveByteArray(title + ".pdf", d) | |
} | |
async function getBookKey(aid, bid) { | |
const r = await fetch(`http://read.nlc.cn/OutOpenBook/OpenObjectBook?aid=${aid}&bid=${bid}`) |
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
#!/usr/bin/env python3 | |
import urllib.request | |
import re | |
from collections import namedtuple | |
from math import log | |
def ip2num(ip_address: str) -> int: | |
a, b, c, d = map(int, ip_address.split(".")) | |
return (a << 24) + (b << 16) + (c << 8) + d |
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
// CloudFlare API token | |
// for zone: example.com (Edit) | |
const CLOUDFLARE_API_TOKEN = "TO_BE_FILLED"; | |
// Currently, there seems not to be a way to get zone ids with tokens. So hardcode it here. | |
// https://community.cloudflare.com/t/bug-in-list-zones-endpoint-when-using-api-token/115048 | |
// Trailing dots CANNOT BE OMITTED. | |
const ZONES = { | |
"example.org.": { | |
id: "TO_BE_FILLED" | |
}, |
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
#!/usr/bin/env python3 | |
import sys | |
from PIL import Image, ImageDraw, ImageFont | |
from PIL.ExifTags import TAGS, GPSTAGS | |
from datetime import date, datetime, timezone | |
def calculate_crop_dimensions(image, ratio=3/2): | |
width, height = image.size | |
l = width > height # is landscape | |
if not l: |
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 WOW_TOKEN = "W0w!" | |
async function handleRequest(request) { | |
const upgradeHeader = request.headers.get('Upgrade'); | |
const token = request.headers.get('X-WOW-TOKEN'); | |
const addr = request.headers.get('X-WOW-ADDR'); | |
if (token !== WOW_TOKEN) { | |
return new Response('Forbidden', { status: 403 }); | |
} | |
if (!upgradeHeader || upgradeHeader !== 'websocket') { |
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
#!/usr/bin/dev python3 | |
# -*- coding: utf-8 -*- | |
import requests | |
from bs4 import BeautifulSoup | |
import urllib.parse | |
import json | |
from PIL import Image | |
import pytesseract | |
import time |
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/sh | |
parted /dev/vda -- mklabel gpt | |
parted /dev/vda -- mkpart esp 1MiB 100MiB | |
parted /dev/vda -- mkpart primary 100MiB 100% | |
parted /dev/vda -- set 1 boot on | |
mkfs.ext4 -L nixos /dev/vda2 # btrfs not working? | |
mkfs.vfat -F32 -n boot /dev/vda1 | |
mkdir -p /mnt | |
mount /dev/vda2 /mnt | |
mkdir -p /mnt/boot |
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
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
# Backup 2017-01-07. | |
from uuid import uuid4 | |
from telegram import InlineQueryResultArticle, ParseMode, \ | |
InputTextMessageContent | |
from telegram.ext import Updater, InlineQueryHandler, CommandHandler |
NewerOlder