Skip to content

Instantly share code, notes, and snippets.

View holishing's full-sized avatar
🌴
On vacation

holishing holishing

🌴
On vacation
View GitHub Profile
@BaksiLi
BaksiLi / git_user_switcher.zsh
Created July 7, 2023 05:39
zsh function for switching git users (for team, multiple accounts etc.)
function git_user_switcher() {
# Define an associative array to store the user settings
typeset -A -g git_users
# Add the users to the dictionary
# Format: username "name email gpg_key"
git_users=(
adam "adam [email protected]"
)
#main: ~/.mlterm/main
bg_color = black
fg_color = grey75
geometry = 86x24
fontsize = 32
scrollbar_mode = autohide
scrollbar_view_name = next
use_bold_font = false
use_anti_alias = true
letter_space = 0
@typebrook
typebrook / Makefile
Last active July 30, 2022 23:58
Update OSM villages with wikidata #osm #wikidata #village #script
all: final.osc
clean:
rm *.list *.osm *.osc
# P31=屬於 Q7930614=中華民國村里 P5020=中華民國戶政資料代碼
define quest
SELECT DISTINCT ?village ?ref
WHERE {
?village wdt:P31 wd:Q7930614.
@PttCodingMan
PttCodingMan / get_aid_from_url.py
Last active November 5, 2020 17:50
PTT 文章網址轉換成看板與aid
def get_aid_from_url(url: str) -> (str, str):
# from get_aid_from_url in PyPtt
# 檢查是否符合 PTT BBS 文章網址格式
pattern = re.compile('https://www.ptt.cc/bbs/[-.\w]+/M.[\d]+.A[.\w]*.html')
r = pattern.search(url)
if r is None:
raise ValueError('url must be www.ptt.cc article url')
@artman41
artman41 / wsl-install_another_distro.md
Last active August 31, 2024 01:11
Instructions on how to install a custom distro in WSL2 (Windows SubSystem for Linux 2)

WSL install another distro

  1. Here are some default vars for the process
ISO_DIR=~/fedora;
ROOTFS_MOUNT_DIR=/mnt/contents

DISTRO_LOCATION=
@virus-warnning
virus-warnning / ps_exec.py
Created January 16, 2020 09:17
使用 PowerShell 執行程式, 回傳 STDOUT, 並且支援系統管理員身分執行
import os
import random
import subprocess
def ps_exec(cmd, adminPriv=False):
""" 使用 Windows PowerShell Start-Process 執行程式, 回傳 STDOUT, 並且支援以系統管理員身分執行 """
# 產生隨機檔名, 用來儲存 stdout
existed = True
while existed:
/// Make CPUs usage as a sin wave
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/time.h>
#include <unistd.h>
const float PI = 3.1415926;
const int TIME_SLICE = 40000; // 40 ms
@virus-warnning
virus-warnning / classify.py
Created September 4, 2019 06:39
Classify photos by EXIF attributes, designed for my wife.
"""
Classify photos by EXIF attributes.
Before classified:
DCIM
├── 100ANDRO
│   ├── DSC_2828.JPG
│   └── DSC_2830.JPG
├── 99ANDRO
@bessarabov
bessarabov / gist:674ea13c77fc8128f24b5e3f53b7f094
Last active August 23, 2024 19:11
One-liner to generate data shown in post 'At what time of day does famous programmers work?' — https://ivan.bessarabov.com/blog/famous-programmers-work-time
git log --author="Linus Torvalds" --date=iso | perl -nalE 'if (/^Date:\s+[\d-]{10}\s(\d{2})/) { say $1+0 }' | sort | uniq -c|perl -MList::Util=max -nalE '$h{$F[1]} = $F[0]; }{ $m = max values %h; foreach (0..23) { $h{$_} = 0 if not exists $h{$_} } foreach (sort {$a <=> $b } keys %h) { say sprintf "%02d - %4d %s", $_, $h{$_}, "*"x ($h{$_} / $m * 50); }'
@kcchien
kcchien / buildVSCode.sh
Last active July 24, 2020 17:19
在 nVidia Jetson Nano 編譯與安裝 VSCode buildVSCode.sh : 編譯與安裝 product.json: 要記得先覆蓋原始碼裡的那一份
# 退出桌面模式,以節省記憶體,不然編譯到一半會有記憶體不足的狀況,造成失敗
# 你的畫面會進入Console 模式,是正常的
sudo systemctl isolate multi-user
# 準備建置原始碼
yarn
# 建置原始碼,這個會要花一些時間,約15~20分鐘
yarn run gulp vscode-linux-arm64-min
yarn run gulp vscode-linux-arm64-build-deb