- Thread-Safe between multiple processes.
- No need for any dependency.
This file contains 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 learning_path(first: str, second: str, third: str, fourth: str, target: str) -> str: | |
record: Dict[str, List[str]] = {} | |
for i in [first, second, third, fourth]: | |
rule = i.split(" ") | |
if len(rule) == 1: | |
record[rule[0]] = [] | |
else: | |
if rule[0] not in record: | |
record[rule[0]] = [] | |
rule[1:].sort() |
- Logger file Auto-Rotation.
- Thread-Safe
- No need for any dependency.
- Thread-Safe
- No need for any dependency.
This file contains 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 threading | |
import sys | |
class KillableThread(threading.Thread): | |
def __init__(self, *args, **keywords): | |
threading.Thread.__init__(self, *args, **keywords) | |
self.killed = False | |
def start(self): | |
self.__run_backup = self.run |
This file contains 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
package main | |
import ( | |
"io" | |
"net/http" | |
) | |
func sayhello(res http.ResponseWriter, req *http.Request) { | |
io.WriteString(res, "hello world") | |
} |
This file contains 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
#!/usr/bin/env python3 | |
import requests | |
from bs4 import BeautifulSoup | |
import json | |
import re | |
def main(document): | |
document = BeautifulSoup(document, 'lxml') | |
result = {} |
This file contains 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 requests | |
import time | |
import asyncio | |
import functools | |
# async IO is a single-threaded, single-process design | |
# event_loop | |
# coroutine | |
# task | |
# future |
This file contains 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
#!/bin/bash | |
# 賦值 | |
pathName='hello world' | |
# echo 是列印值,印出變數 pathName 內容 demo.sh | |
echo ${pathName} | |
# $$ 目前 process PID | |
# ${0} 為檔名 |
This file contains 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
from email.message import EmailMessage | |
import smtplib | |
content = '''<html><body><table style="margin-bottom: 0px; border:1px solid #d8d8d8;"><thead><tr><th>Index</th><th>Count</th><th>Del after 6 Hrs</th><th>Rate</th><th>Extension Enable</tr></th></thead><tbody>\n''' | |
for i in alarms: | |
content += '<tr><td>{}</td><td>{:,}</td><td>{:,}</td><td>{}</td><td>{}</td></tr>\n'.format(i[0], i[1], i[2], | |
round(i[2] / i[1], 3), gc_nindex.get(i[0], '')) | |
content += '</tbody></table><table><tr><td>TTL 關掉的 index</td></tr>\n' | |
for i in sweeper.disabled: | |
content += '<tr><td>{}</td></tr>'.format(i) |
NewerOlder