Skip to content

Instantly share code, notes, and snippets.

View Sansui233's full-sized avatar
🙉
Boom!

Sansui233 Sansui233

🙉
Boom!
View GitHub Profile
@Sansui233
Sansui233 / sync-rightfont-to-sysfont.py
Last active December 1, 2020 17:24
Sync RightFont library to system font book user dir using hard link on macOS
#!/user/bin/python
#!conding=utf8
import os
g = os.walk("$HOME/RightFont/Font Library.rightfontlibrary/fonts")
for path,folder,filelist in g:
# print "===Dir List===",folder;
for filename in filelist:
src = os.path.join(path, filename)
dst = os.path.join("$HOME/Library/Fonts/", filename)
@Sansui233
Sansui233 / autodarkmode.plist
Created December 1, 2020 17:17
auto-dark-mode-for-mac
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key><string>autodarkmode</string>
<key>ProgramArguments</key>
<array>
<string>$HOME/Developer/shell/tools/autodarkmode.sh</string>
</array>
@Sansui233
Sansui233 / globalprotect.sh
Created December 1, 2020 17:26
start-or-kill-globalprotect
#!bin/bash
if [ $# -eq 0 ]; then
echo "-l launch"
echo "-k kill"
echo "-a launch and autostart"
echo "-u kill and unset autostart"
echo "-h help"
exit 0
fi
@Sansui233
Sansui233 / pgservice.sh
Created December 1, 2020 17:29
start and stop postgresql on mac
#!/bin/bash
user=postgres
if [ $# -eq 0 ]; then
echo "-start|-stop"
exit 0
fi
case "$1" in
-start)
sudo -u $user pg_ctl -D /Library/PostgreSQL/13/data start
exit 0
@Sansui233
Sansui233 / imgwidth640.sh
Created December 1, 2020 17:46
fix image width to 640px with ffmpeg
echo "Fix your images width into 640px"
path=$(pwd)
cd $path
echo "\033[34m[Info] Workdir: $path" $(tput sgr0)
files=$(ls $path)
for filename in $files
do
echo "\033[34m[Info] Converting $filename ........." $(tput sgr0)
@Sansui233
Sansui233 / default
Created December 6, 2020 08:13
nginx
##
# You should look at the following URL's in order to grasp a solid understanding
# of Nginx configuration files in order to fully unleash the power of Nginx.
# https://www.nginx.com/resources/wiki/start/
# https://www.nginx.com/resources/wiki/start/topics/tutorials/config_pitfalls/
# https://wiki.debian.org/Nginx/DirectoryStructure
#
# In most cases, administrators will remove this file from sites-enabled/ and
# leave it as reference inside of sites-available where it will continue to be
# updated by the nginx packaging team.
@Sansui233
Sansui233 / crc32calc.go
Last active January 30, 2021 05:38
crc32 encoding and decoding example / bilibili uid hash
func main() {
// IEEE is crc32b, which is used to hash bilibili uid
// Encode
uid := "21670130"
h := fmt.Sprintf("%x", crc32.ChecksumIEEE([]byte(uid)))
fmt.Printf("Encoding of %s: %s\n", uid, h)
// Decode
hashed := "6acc8733"
fmt.Printf("Start Decoding... \n")
for i := 1; i < 500000000; i++ {
@Sansui233
Sansui233 / wubiConv.py
Last active March 31, 2021 11:47
五笔字典格式转换-清歌to落格
#!/usr/local/bin/python3.8
#!conding=utf8
import os
from datetime import date
# ==== Config ====
qgpath = "/Users/sansui233/Library/Mobile Documents/com~apple~CloudDocs/App备份/五笔/qgdict.txt"
lgpath = "/Users/sansui233/Library/Mobile Documents/com~apple~CloudDocs/App备份/五笔/output.txt"
outpath = "/Users/sansui233/Library/Mobile Documents/com~apple~CloudDocs/App备份/五笔/"
@Sansui233
Sansui233 / fix-indentation-logseq.py
Last active June 7, 2021 09:06
fix indentation destroyed by logseq
import re
import os
one = re.compile(r'(\t )+')
two = re.compile(r'(\t\t )+')
three = re.compile(r'(\t\t\t )+')
four = re.compile(r'(\t\t\t\t )+')
five = re.compile(r'(\t\t\t\t\t )+')
six = re.compile(r'(\t\t\t\t\t\t\t )+')
@Sansui233
Sansui233 / Microsoft.PowerShell_profile.ps1
Last active August 11, 2025 07:09
Make powershell command more unix-like.
Write-Host ("Current time: " + (Get-Date -Format "yyyy-MM-dd HH:mm:ss"))
# Import-Module posh-git # select posh-git or oh-my-posh
oh-my-posh init pwsh --config "$env:POSH_THEMES_PATH\pure.omp.json" | Invoke-Expression
#Invoke-Expression (&starship init powershell)
Import-Module PSReadLine
Set-PSReadLineKeyHandler -Key Ctrl+Shift+c -Function Copy
Set-PSReadLineKeyHandler -Key Ctrl+v -Function Paste
#Set-PSReadLineOption -EditMode Emacs