- Note those single & double quotes around variables.
- Note there are backticks around
$(hostname -I)
to style it as code block.
TITLE="$1"
MESSAGE="$2"
#!/bin/bash | |
io_benchmark() { | |
# Fixed block size and initial conditions | |
local bs_size=4 # MB fixed | |
local count=512 # start count | |
local timeout_val=1 # seconds initial timeout | |
local tmpfile="/tmp/io_spike" | |
local min_count=1 # stop at count=1 | |
local max_timeout=64 # stop at timeout=64s |
g-back-main () { | |
# Determine current and default branch names | |
local current_branch default_branch | |
current_branch=$(git symbolic-ref --short HEAD) | |
# Try to detect default branch (main or master) | |
if git show-ref --quiet refs/remotes/origin/main; then | |
default_branch="main" | |
elif git show-ref --quiet refs/remotes/origin/master; then | |
default_branch="master" |
#!/bin/bash | |
# | |
# Usage: | |
# [Basic] | |
# n <namespace> | |
# kgn deploy | |
# kgn pod | |
# kdn pod <pod_name> | |
# ...etc | |
# |
import time | |
CONSTANT_STRINGS = ( | |
"0123456789abcdefghjkmnpqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ" # 移除 i, I, l, o, O | |
) | |
def to_custom_radix(num: int, string_pool: str) -> str: | |
q, r = divmod(num, len(string_pool)) |
#!/bin/bash | |
# Author: ktlast | |
# Blog/Doc: https://ktlast.com/p/glance-tw-stock-cli%E5%81%87%E5%A6%82%E4%BD%A0%E9%9C%80%E8%A6%81%E7%94%A8-cli-%E4%B8%8A%E7%8F%AD%E5%81%B7%E7%9C%8B%E7%9B%A4/ | |
# shellcheck source=./ | |
set -e | |
TSE_API_URL_PREFIX='https://mis.twse.com.tw/stock/api/getStockInfo.jsp?json=1&delay=0&ex_ch=' | |
REFRESH_INTERVAL=${1:-3} | |
OUTPUT_ENV_FILE=${2:-"./.glance.sh.env"} |
#!/bin/bash | |
function info_start { | |
echo "╷ " | |
} | |
function info_body { | |
echo "│ $*" | |
} |
tse
_ 2330
.tw
otc
_ 2330
.tw
e.g.
# Left rotate | |
def lrot(byte_string, offset): | |
for i in range(offset): | |
byte_string = byte_string[1:]+byte_string[0] | |
return byte_string | |
# Transfer num to binary (string), e.g "00101011" | |
def b(num, bits=8): | |
if -num > 2**(bits-1) or num > 2**(bits-1) - 1: |
# coding=utf-8 | |
import smtplib | |
import csv | |
from email.mime.text import MIMEText | |
# Prepare a template as mail body. | |
def get_template(): | |
with open("Mail\\Text\\Template\\Path", "r", encoding="utf-8") as template_txt: | |
template = template_txt.read() | |
return template |