This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
_script_path = os.path.dirname(os.path.abspath(__file__)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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,)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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\'') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: deploy-blog | |
on: | |
schedule: | |
- cron: '22 22 * * *' | |
push: | |
branches: | |
- publish | |
paths: | |
- 'source/**/*.md' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import logging | |
import threading | |
import time | |
import subprocess | |
import platform | |
def ping_ip(ip_address, results): | |
""" | |
檢查 IP 是否可連線,如果可連線則將結果寫入 results 變數中。 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int func(....){ | |
// declare variable here | |
// check input here | |
if(pointer == NULL) goto end; | |
if(!run_condition) goto end; | |
// do something |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def obj2base64(obj): | |
# convert object to base64 string using json | |
return base64.b64encode(json.dumps(obj).encode('utf-8')).decode('utf-8') | |
def base642obj(s): | |
# convert base64 string to object using json | |
return json.loads(base64.b64decode(s).decode('utf-8')) |
NewerOlder