Skip to content

Instantly share code, notes, and snippets.

View PttCodingMan's full-sized avatar
🎯
Seeking new job

CodingMan PttCodingMan

🎯
Seeking new job
View GitHub Profile
@PttCodingMan
PttCodingMan / 4000_english_words.json
Last active August 22, 2025 07:34
從英文詞頻分析研究找到的最常見 4381 個單字,使用 AI 加上定義、例句還有片語。
This file has been truncated, but you can view the full file.
[
{
"word": "FALSE",
"definition": "j. (形容詞) 錯誤的",
"sentence": "Choose whether the statement is true or false.",
"translation": "選擇這個陳述是真是假。"
},
{
"word": "TRUE",
"definition": "j. (形容詞) 真的;真實的",
_script_path = os.path.dirname(os.path.abspath(__file__))
import multiprocessing
import threading
import time
class ServerConsole:
def __init__(self):
self.msg_queue = multiprocessing.Queue()
self.console_process = threading.Thread(target=self.console, args=(self.msg_queue,))
@PttCodingMan
PttCodingMan / test.py
Created November 10, 2023 08:53
反數列使用 binary search
import bisect
from typing import List
def reversePairs(nums: List[int]) -> int:
q = []
res = 0
for v in nums:
i = bisect.bisect_left(q, -v)
res += i
module = None
try:
if module is None:
module = importlib.import_module(f'module_folder.module')
else:
module = importlib.reload(module)
except Exception as e:
raise e
@PttCodingMan
PttCodingMan / server_util.py
Created August 12, 2023 14:42
the server utils of Rock Minecraft server
import datetime
import os
import time
from argparse import ArgumentParser
from typing import List
def send_server_command(command) -> None:
os.system(f'screen -S rock-server -p 0 -X eval \'stuff "{command}"\\015\'')
name: deploy-blog
on:
schedule:
- cron: '22 22 * * *'
push:
branches:
- publish
paths:
- 'source/**/*.md'
import logging
import re
from queue import PriorityQueue
from sentence_transformers import SentenceTransformer, util
from sklearn.metrics.pairwise import cosine_similarity
from post_walker import post_walker
logging.basicConfig(
@PttCodingMan
PttCodingMan / check_network_status.py
Last active May 30, 2023 03:06
check network status
import logging
import threading
import time
import subprocess
import platform
def ping_ip(ip_address, results):
"""
檢查 IP 是否可連線,如果可連線則將結果寫入 results 變數中。
@PttCodingMan
PttCodingMan / example.c
Last active February 10, 2023 09:19
C language function example to avoid memory leak using goto.
int func(....){
// declare variable here
// check input here
if(pointer == NULL) goto end;
if(!run_condition) goto end;
// do something