Skip to content

Instantly share code, notes, and snippets.

View holishing's full-sized avatar
🌴
On vacation

holishing holishing

🌴
On vacation
View GitHub Profile
/// 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 / 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:
@artman41
artman41 / wsl-install_another_distro.md
Last active July 13, 2025 15:12
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=
@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')
@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.
#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
@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]"
)