Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@zhsj
zhsj / cat.go
Created September 13, 2022 15:49
🐱
package main
import (
"bufio"
"bytes"
"flag"
"fmt"
"io"
"log"
"os"
@zhsj
zhsj / oauth2.py
Created December 26, 2019 17:51
mutt oauth refresh command
#!/usr/bin/python3
import json
import argparse
import urllib.request
import urllib.parse
client_id = "1008555780204-finbc9qn6gss7t099l96t1pbqmidv9hm.apps.googleusercontent.com"
client_secret = ""
@zhsj
zhsj / clean-images.py
Created August 9, 2019 15:10
clean containerd cri images
#!/usr/bin/python3
import json
import itertools
import subprocess
out = subprocess.check_output(["crictl", "images", "-o", "json"])
images = json.loads(out.decode("utf-8"))
tags = itertools.chain.from_iterable([i["repoTags"] for i in images["images"]])
for repo, repo_tags in itertools.groupby(tags, lambda x: "".join(x.split(":")[:-1])):
@zhsj
zhsj / rsa.go
Last active May 10, 2019 17:45
encrypt with RSA private key and decrypt with public key
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package main
import (
"crypto"
"crypto/rand"
"crypto/rsa"
@zhsj
zhsj / tv.py
Created January 28, 2019 16:07
play url on tv
#!/usr/bin/env python3
from contextlib import contextmanager
import re
import select
import socket
import sys
import urllib.request
@zhsj
zhsj / sks-poison-key.patch
Created July 16, 2018 03:54
sks poison key
diff --git a/keydb.ml b/keydb.ml
index 949a1f4..7ff976a 100644
--- a/keydb.ml
+++ b/keydb.ml
@@ -1166,6 +1166,11 @@ struct
try
if has_hash hash then [] else
let keyid = Fingerprint.keyid_from_key ~short:true key in
+ let keyid_long = Fingerprint.keyid_to_string ~short:false (Fingerprint.keyid_from_key ~short:false key) in
+
@zhsj
zhsj / nutstore-pydaemon.py
Last active January 16, 2020 09:04
nutstore-pydaemon.py python3 port
#!/usr/bin/env python3
# vim: set sw=4 ts=4:
import socket
import os
import threading
import time
import sys
import platform
import tempfile
import fcntl
@zhsj
zhsj / strace-on-amd64.txt
Last active September 3, 2017 06:51
go syscall bug
go version go1.9 linux/amd64 (from Debian unstable)
$ strace ./test 2>&1|grep ioctl
ioctl(0, TCGETS, {B9600 opost isig icanon echo ...}) = 0
ioctl(0, TCGETS, {B9600 opost isig icanon echo ...}) = 0
go version go1.8.1 gccgo (Debian 7.2.0-1) 7.2.0 linux/amd64
$ strace ./test 2>&1|grep ioctl
import debian.deb822
import debian.copyright
import debian.changelog
with open('debian/control', 'r') as f:
ctrl_p = list(debian.deb822.Deb822.iter_paragraphs(f))
with open('debian/copyright', 'r') as f:
copyright = debian.copyright.Copyright(f)
@zhsj
zhsj / decode.py
Created January 23, 2017 17:50
HZ characters decode, RFC 1843
#!/usr/bin/env python3
hz = "VP9z?F<<4sQ'"
print(bytes([ord(i)+0x80 for i in hz]).decode('gb2312'))