Skip to content

Instantly share code, notes, and snippets.

@vizv
vizv / parse.rb
Last active Feb 2, 2021
docx -(pandoc)-> html -(pup)-> txt -(parse.rb)-> csv
View parse.rb
# ls -1prt | grep -v "/$" | cat -n | while read n f; do mv -n "${f}" "$(printf "%03d" $n).${f#*.}"; done
# ls *.docx | sed 's/\(.*\)\.docx/pandoc & -o \1.html/g' | sh
# ls *.html | sed 's/\(.*\)\.html/pup --plain "body" "text{}" < & | rg -v "^$" > \1.txt/g' | sh
# ruby parse.rb
# printf '\xEF\xBB\xBF' | cat - output.csv > bom.csv
require 'csv'
txts = Dir['*.txt']
CSV.open('output.csv', 'w') do |csv|
@vizv
vizv / tracker_log_analyzer.c
Last active Jan 17, 2021
Trancker log analyzer
View tracker_log_analyzer.c
// gcc -Wall tracker_log_analyzer.c && ./a.out | sort | uniq -c | sort -nr > rank.txt
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<ctype.h>
#define BUF_SIZE (1024 * 64)
#define PREFIX "info_hash="
@vizv
vizv / bot.sh
Last active Jan 10, 2021
Kemonomimi Bot
View bot.sh
#!/bin/sh -e
AUTH_KEY=''
QQ=''
SESSION_KEY="$(http :8080/auth "authKey=${AUTH_KEY}" | jq -r .session)"
[ "$(http :8080/verify "sessionKey=${SESSION_KEY}" "qq=${QQ}" | jq '.code')" = 0 ] || exit 1
echo "SESSION_KEY=${SESSION_KEY}"
@vizv
vizv / process.sh
Last active Dec 23, 2020
Stickerize
View process.sh
#!/bin/sh -e
SRC=source
MARGIN=5
WIDTH=512
HEIGHT=512
function step() {
PREV="$1"
CURR="$2"
@vizv
vizv / config.yml
Last active Dec 21, 2020
comics-cutter
View config.yml
setting:
source:
dir: src
format: jpg
output:
dir: _output
format: jpg
height: 1920
width: 1350
digits: 3
@vizv
vizv / boot.sh
Last active Aug 13, 2020
用于在维护后启动 TFCLOUD 实例的脚本
View boot.sh
#!/bin/bash -e
# 用于在维护后启动 TFCLOUD 实例的脚本
# 获取更新:https://gist.github.com/vizv/e55741af2b16acad861a424549bae520
# boot.sh Copyright (C) 2020 Viz <viz@linux.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
@vizv
vizv / gdindex-list.sh
Last active Jun 29, 2020
GDIndex Listing Script
View gdindex-list.sh
#!/bin/bash
[ $# -eq 1 ] || { echo "Usage: $0 URL" >&2; exit 1; }
GD_DIR_MIME='application/vnd.google-apps.folder'
JQ_COND_DIR="select(.mimeType == \"${GD_DIR_MIME}\")"
JQ_COND_FILE="select(.mimeType != \"${GD_DIR_MIME}\")"
URL="${1%/}"
View gist:01130b45d85e6f05545e6b36794799b0
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQDVbeZcLeYUjeBQdWBIw0/+3dNshXMC9oeszs5MAf4Mm0F/VlDxouZjJ84fI6JXtlLOpRBEJ6ZT8lUG3V6ELwCVXoa2FYVWU4FxhBuVascEFrXjBqaF0LlhmSgQmknrsx/Q6lVOVKjUs6cK6KHPVBOf7tv3v5kpinl8vyKeein3fKm1tAjTIIDtv6DFp8XFbN3UKltDJF1PJfaDLUhH/0TIePQSE6jNI2A70viJEBW1N/28/vj8ZMQ8hUk2nfMM0d+PDK1a2TS2SzMh5VjTxQPfElM68uf65qiukQdm+dUtncs66e2jjV1dGat88cffwgVLXUYRfby+bCzJ/meHTHXpb1TaQN+I4wgTqyFw4mdY8ujAifceCk5MLffjKTuurXh5Her75Ntrex0YOHk+zqUTs7y5XyJ+Y1rCiUystqrU+YhXBhrr3K+PXH4L7iz2N9A3dLbrQ/mxfPQ8PN+ApxJGFMiT5rZj7RtmVsmDExGaq5v6bAaKGln2Ml+4CkF20kSaimChEgc3Zn/U6XSCwzFOQAttPB1pByluHoJ26KjXBqqQNhuBsXEpFJ9nN3UQ1PJV1TPkE2znmsvlcgX10ZRPHs/UPyAM/8AHfsgOktkAlst6b7hgy6rk+EPhIjLz0l+r4Ckh0tJorhskHnV7KRB/fPZ/8yAOQ82xhZjFKdG8lw== viz
@vizv
vizv / qrv
Last active Dec 13, 2019
QR code video encoder / decoder
View qrv
#!/bin/sh -e
# preflight & usage
CMD="$1"
FILE="$2"
[ -z "$CMD" ] || [ -z "$FILE" ] && {
cat >&2 <<EOF
usage: $(basename "$0") encode FILE
$(basename "$0") decode FILE
EOF
@vizv
vizv / outlook-notification.js
Last active Mar 22, 2019
Outlook Notification UserScript
View outlook-notification.js
// ==UserScript==
// @name Outlook Notification
// @namespace http://tampermonkey.net/
// @version 0.3
// @description Send desktop notification from Outlook Web Application
// @author Wenxuan Zhao
// @match https://outlook.office.com/mail/inbox
// @iconURL http://ow2.res.office365.com/owamail/2019031801.04/resources/images/favicons/mail-seen.ico
// @updateURL https://gist.githubusercontent.com/vizv/0a2b53d4c15569020152aa52e43fd0cb/raw/outlook-notification.js
// @grant GM_notification