Skip to content

Instantly share code, notes, and snippets.

View AllanChain's full-sized avatar

Allan Chain AllanChain

View GitHub Profile
@AllanChain
AllanChain / logseq-live-math.json
Last active January 3, 2024 07:51
My Logseq Live Math plugin settings
{
"triggerSettings": null,
"dollarTrigger": false,
"selectEdit": false,
"selectModifier": "Shift",
"formatSettings": null,
"preferDisplay": false,
"preferMultiline": true,
"smartFormat": true,
"mathliveSettings": null,
@AllanChain
AllanChain / pimg.py
Created October 26, 2023 08:08
Pin image on desktop after spectacle screenshot. Works on Wayland.
#!/usr/bin/python3
import sys
import subprocess
from PySide6 import QtCore, QtWidgets, QtGui
class MyWidget(QtWidgets.QLabel):
def __init__(self):
super().__init__()
@AllanChain
AllanChain / _scancel.zsh
Last active October 13, 2023 13:30
Custom ZSH completion for Slurm's `scancel`
# Learn from https://mrigank11.github.io/2018/03/zsh-auto-completion/
function _scancel {
_describe 'command' "($(squeue -h -o '%i:%T-%j' -u $USER))"
}
compdef _scancel scancel
@AllanChain
AllanChain / tailwind.sty
Last active October 9, 2023 13:36
Tailwind color palette for LaTeX
%
% Copyright (c) Tailwind Labs, Inc.
%
% Permission is hereby granted, free of charge, to any person obtaining a copy
% of this software and associated documentation files (the "Software"), to deal
% in the Software without restriction, including without limitation the rights
% to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
% copies of the Software, and to permit persons to whom the Software is
% furnished to do so, subject to the following conditions:
%
@AllanChain
AllanChain / lunafast.py
Created June 12, 2023 13:31
自然快手辅助码转移
zrmfast = {}
for line in open('./zrmfast.dict.yaml'):
if not '\t' in line or not '[' in line:
continue
char, code, *_ = line.strip().split('\t')
zrmfast[char] = code.split('[')[1]
lines = []
for line in open('/usr/share/rime-data/luna_pinyin.dict.yaml'):
if not '\t' in line:
@AllanChain
AllanChain / start-if-charging.sh
Created December 28, 2022 00:38
Start programs if laptop is charging
#!/bin/bash
bat_status=$(cat /sys/class/power_supply/BAT1/status)
if [[ $bat_status != "Discharging" ]]; then
# More programs before Wayland tray is reday
sleep 30 # wait for Wayland tray
/usr/bin/safeeyes &
# More...
fi
@AllanChain
AllanChain / .tmux.conf.local
Last active November 18, 2022 13:09
Custom tmux config based on oh-my-tmux
# : << EOF
# https://github.com/gpakosz/.tmux
# (‑●‑●)> dual licensed under the WTFPL v2 license and the MIT license,
# without any warranty.
# Copyright 2012— Gregory Pakosz (@gpakosz).
tmux_conf_24b_colour=auto
# default theme
tmux_conf_theme_colour_1="#2e3440" # dark gray
tmux_conf_theme_colour_2="#3b4252" # gray
@AllanChain
AllanChain / .tmux.conf
Created October 25, 2022 02:49
oh my tmux nord theme.
tmux_conf_theme_colour_1="#2e3440" # dark gray
tmux_conf_theme_colour_2="#3b4252" # gray
tmux_conf_theme_colour_3="#4c566a" # light gray
tmux_conf_theme_colour_4="#5e81ac" # light blue
tmux_conf_theme_colour_5="#ebcb8b" # yellow
tmux_conf_theme_colour_6="#2e3440" # dark gray
tmux_conf_theme_colour_7="#e5e9f0" # white
tmux_conf_theme_colour_8="#2e3440" # dark gray
tmux_conf_theme_colour_9="#ebcb8b" # yellow
tmux_conf_theme_colour_10="#d08770" # pink
@AllanChain
AllanChain / pdf-cloud-convert
Created March 16, 2022 02:11
Script to convert ppt(x) to pdf using cloudconvert
#!/bin/python3
from os import environ
from pathlib import Path
from subprocess import call
from sys import argv
API_KEY = """
""".replace(
"\n", ""
)
@AllanChain
AllanChain / dynv6.py
Created September 22, 2021 15:37
Update a dynv6 ip
import socket
import urllib.request
def get_out_ipv6():
s = socket.socket(socket.AF_INET6, socket.SOCK_DGRAM)
s.connect(("2620:0:ccc::2", 80))
ipv6 = s.getsockname()[0]
s.close()
print(ipv6)
return ipv6