Skip to content

Instantly share code, notes, and snippets.

View magicnat's full-sized avatar

Honghao Zeng magicnat

View GitHub Profile
#!/usr/bin/env python3
from pyrogram import Client
from pyrogram.api import types
import time
def update_handler(client, update, users, chats):
if isinstance(update, types.UpdateUserStatus):
print("%d,%d\n" % (time.time(), update.user_id))
#!/bin/bash
filter_log () {
next=0
while read line; do {
IFS=, read -ra dates <<< "$(cut -d',' -f1 <<< "$line")"
date=${dates[0]}
[ $date -gt $next ] && {
echo "$date"
read m s <<< $(gdate -d @$date +"%M %S")
@magicnat
magicnat / cndns
Created March 31, 2018 05:32
cndns: try to avoid bad DNS replies
#!/bin/bash
[ -z "$2" ] && echo "usage: $0 <query> <ns> [timeout=5]" && exit 1
{ sleep 1; dig $1 @$2 > /dev/null; } &
timeout ${3:-5} tcpdump -nvi any src port 53 and src $2 2>&1 \
| grep '>' \
| tail -n1 \
| cut -d':' -f2 \
# for org:
query=orgs/nat-lab
# for user:
# query=users/magicnat
curl -s https://api.github.com/$query/repos | jq -cr '.[] .full_name' | while read r; do curl -s https://api.github.com/repos/$r/license | jq -cr '.license .spdx_id'; done | sort | uniq -c
@magicnat
magicnat / osu_pp.js
Created January 9, 2017 13:05
A UserScript to show FC PP, # of circles, sliders, and spinners on osu! map info page.
// ==UserScript==
// @name osu!pp
// @namespace http://nat.moe/
// @version 0.1
// @description show FC PP on osu info page.
// @author NAT
// @include /^http.*:\/\/osu.ppy.sh/[sb]?\/.*$/
// @grant none
// ==/UserScript==
@magicnat
magicnat / tg_bash_bot.sh
Created December 7, 2016 17:04
Telegram Bash Bot
#!/bin/bash
# bot configuration
TOKEN=''
URL='https://api.telegram.org/bot'$TOKEN
INTV=1
# log: logger
# usage: log <loglevel> <message>
# loglevel: integer, 1 to 3, INFO/DEBUG/VERBOSE

Keybase proof

I hereby claim:

  • I am MagicNAT on github.
  • I am magicnat (https://keybase.io/magicnat) on keybase.
  • I have a public key whose fingerprint is 1846 9E41 8F1F C388 0D4C DCD1 6EFA 43E6 ABDE 2194

To claim this, I am signing this object:

@magicnat
magicnat / tg-bot-chat.sh
Last active April 20, 2019 23:56
A simple script allows you to chat as a bot in Telegram.
#!/bin/bash
# Simple script allows you to chat as a bot in Telegram.
# based on topkecleon/telegram-bot-bash.
# dependencies: python3, python-telegram-bot (pip3 install python-telegram-bot);
# tmux
TOKEN=""
URL='https://api.telegram.org/bot'$TOKEN
MSG_URL=$URL'/sendMessage'
ACTION_URL=$URL'/sendChatAction'
PHO_URL=$URL'/sendPhoto'
@magicnat
magicnat / zhwiki-proxy.conf
Last active May 10, 2017 18:44
中文維基nginx代理配置:為大牆之後的人民開啟通往知識的大門吧
server
{
listen 443;
listen [::]:443;
server_name zhwiki.example.org;
ssl on;
ssl_certificate /path/to/ssl/cert.crt;
ssl_certificate_key /path/to/ssl/key.pem;