Skip to content

Instantly share code, notes, and snippets.

@Artin0123
Artin0123 / trans.txt
Last active October 8, 2025 07:31
翻譯排名
To be, or not to be, that is the question:
Whether 'tis nobler in the mind to suffer
The slings and arrows of outrageous fortune,
Or to take arms against a sea of troubles
And by opposing end them. To die—to sleep,
No more; and by a sleep to say we end
The heart-ache and the thousand natural shocks
That flesh is heir to: 'tis a consummation
Devoutly to be wish'd. To die, to sleep;
To sleep, perchance to dream—ay, there's the rub:
@Artin0123
Artin0123 / img.py
Last active September 22, 2025 08:09
圖片模糊檢測程式
"""
圖片模糊檢測程式
目標:嚴格篩選出確定模糊的圖片進行刪除,寧可放過模糊,也不可錯殺清晰。
pip install opencv-python pandas numpy
"""
import cv2
import os
import pandas as pd
import numpy as np
import time
@Artin0123
Artin0123 / comp.py
Created June 27, 2025 10:15
對齊兩個字串
def right_align_strings(str1, str2):
# 找出兩個字串中較長的長度
max_length = max(len(str1), len(str2))
# 對兩個字串進行右對齊
aligned_str1 = str1.ljust(max_length)
aligned_str2 = str2.ljust(max_length)
return aligned_str1, aligned_str2
@Artin0123
Artin0123 / dict.py
Created March 25, 2025 08:19
建dict的2種方式
# 1
for char in n1:
n1Dic[char] = n1Dic.get(char, 0) + 1
# 2
for char in n1:
if char in n1Dic:
n1Dic[char] += 1
else:
n1Dic[char] = 1
@Artin0123
Artin0123 / main.py
Created March 23, 2025 14:58
一年吃藥1比2
import calendar
def count_pills_consumed():
# 記錄A、B的總消耗
count_A = 0
count_B = 0
# 依照規則遍歷一年
for month in range(1, 13): # 1 到 12 月
days_in_month = calendar.monthrange(2023, month)[1] # 該月天數
@Artin0123
Artin0123 / ram.ps1
Last active July 14, 2025 07:39
windows查看程式使用的ram
# 1. 計算工作集百分比
$CompObject = Get-WmiObject -Class WIN32_OperatingSystem
$MemoryPercentage = ((($CompObject.TotalVisibleMemorySize - $CompObject.FreePhysicalMemory) * 100) / $CompObject.TotalVisibleMemorySize)
Write-Host "Memory usage in Percentage: $MemoryPercentage"
# 2. 計算工作集總量 (GB)
# Get all processes
$allProcesses = Get-WmiObject WIN32_PROCESS
# Sum the WorkingSetSize of all processes
$totalProcessMemoryBytes = ($allProcesses | Measure-Object -Property WorkingSetSize -Sum).Sum
@Artin0123
Artin0123 / cpp_version.cpp
Created February 24, 2025 15:40
查詢cpp版本
#include <iostream>
int main() {
if (__cplusplus == 202002L)
std::cout << "C++20\n";
else if (__cplusplus == 201703L)
std::cout << "C++17\n";
else if (__cplusplus == 201402L)
std::cout << "C++14\n";
else if (__cplusplus == 201103L)
std::cout << "C++11\n";