Skip to content

Instantly share code, notes, and snippets.

View pjxiao's full-sized avatar
🌴
Vacant

pjxiao

🌴
Vacant
  • Before the Law
View GitHub Profile

A web driver API proxy

A proxy app to reuse a web driver session during development. This reduces browswer launch time and let you run your script on the running session.

Quick start

@pjxiao
pjxiao / aiohttp_dump_middleware.py
Created April 17, 2021 09:37
An aiohttp middleware dumps HTTP I/O
import json
import logging
import string
from itertools import zip_longest
from json.decoder import JSONDecodeError
from textwrap import dedent
from typing import (
Awaitable,
Callable,
Iterable,
@pjxiao
pjxiao / hexdump.py
Created April 17, 2021 08:56
A pure python `hexdump -C` mimic
import string
from itertools import zip_longest
from typing import Iterable, Optional
def hexdump(bs: bytes) -> str:
"""A pure python `hexdump -C` mimic
>>> print(hexdump(string.printable.encode('ascii')))
000000000 30 31 32 33 34 35 36 37 38 39 61 62 63 64 65 66 |0123456789abcdef|
000000010 67 68 69 6a 6b 6c 6d 6e 6f 70 71 72 73 74 75 76 |ghijklmnopqrstuv|
// ==UserScript==
// @name SLACK::suppressor
// @version 0.1
// @description Suppress annoying messages in muted channels
// @author You
// @match https://app.slack.com/client/*
// @connect slack.com
// @grant GM_xmlhttpRequest
// @grant GM_getValue
// @grant GM_setValue
@pjxiao
pjxiao / monitor-zoom.ps1
Last active July 9, 2020 08:06
Notify if zoom is running on my computer to Slack
function Monitor-Zoom {
$stat = $fasle
while ($true) {
$cur = $(Get-CimInstance -ClassName Win32_Process -Filter 'name="CptHost.exe"').Length -gt 0
if ($cur -eq $stat) {
# do nothing
}
elseif ($cur -and -not $stat) {
Invoke-WebRequest `
-Method POST `
@pjxiao
pjxiao / b.hatena.ne.jp.user.css
Last active September 25, 2020 12:39
User CSSes
/* ==UserStyle==
@name b.hatena.ne.jp
@namespace gist.github.com/pjxiao
@version 1.0.0
@description Don't let b.hatena annoy me
@author pjxiao
==/UserStyle== */
@-moz-document url-prefix("https://b.hatena.ne.jp/entry/") {
.entry-relationContents,
@pjxiao
pjxiao / .README.TEMPLATES.rst
Last active November 8, 2020 12:56
テンプレートが使えなかったり足りてなかったときの自分用のテンプレート

TODO

@pjxiao
pjxiao / card.html
Created March 22, 2020 08:15
A script to hide English words/sentences in front-side cards. (works on Anki 2.1on Windows , AnkiDroid 2.9)
<script>
(function () {
const IGNORED_TAGS = ["SCRIPT", "STYLE"];
// List all text nodes under the target elements
const nodes = [];
Array
.from(document.getElementsByClassName('ja'))
.forEach(function (root) {
const treeWalker = document.createTreeWalker(root, NodeFilter.SHOW_TEXT, null, false);
@pjxiao
pjxiao / demo-pv-and-pvc.yml
Created January 16, 2020 02:35
Example: API objects which create a PVC and a bound pre-previsioned PV
---
# Reference: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.13/#persistentvolume-v1-core
apiVersion: v1
kind: PersistentVolume
metadata:
name: pv-test-volume
spec:
storageClassName: dir
capacity:
storage: 256Mi
@pjxiao
pjxiao / signalHandlableCli.go
Last active July 16, 2018 14:20
A basic pattern to signal handlable cli implementation in Golang
package main
import (
"os"
"os/signal"
"log"
"context"
"github.com/urfave/cli"
// only for demonstration
"time"