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 -xe | |
# リポジトリルートへ移動 | |
cd $(dirname $0)/.. | |
# up API server | |
docker compose up -d --build --wait --quiet-pull api | |
# openapi.jsonの保存先 |
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
/** | |
* オブジェクトの配列を辞書化 | |
*/ | |
const indexBy = <T, K extends T[keyof T] & (string | number | symbol)>(arr: T[], getKey: ((t: T) => K)): Record<K, T> => { | |
return arr.reduce((acc, cur) => { | |
const key = getKey(cur); | |
acc[key] = cur; | |
return acc; | |
}, {} as Record<K, T>); | |
}; |
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
// /:(.*株式会社.*)/ というテキストを含む h3 要素を探して、: **********に置換する | |
[...document.querySelectorAll("h3")].forEach(h3 => {h3.innerText?.includes("株式会社") && (h3.innerHTML = h3.innerText.replace(/:.+/, ": **********")) && console.log(h3.innerText)}); | |
[...document.querySelectorAll("p")].forEach(p => {p.innerText?.includes("氏名:") && (p.innerHTML = p.innerText.replace(/氏名:.+/, "氏名:********"))}); | |
[...document.querySelectorAll("a")].forEach(a => {a.href.includes("misebox") && a.remove()}); | |
[...document.querySelectorAll("script")].forEach(s => { s.remove()}); |
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 | |
if [ $# -lt 1 ] | |
then | |
echo "usage: $0 <input video file>" | |
fi | |
INPUT_FILE="$1" | |
OUTPUT_FILE=`echo ${INPUT_FILE} | sed -E 's/\.[^\.]*$//'`.gif |
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 sys | |
import pathlib | |
def parse_project_data(file_path): | |
with open(file_path, 'r', encoding='utf-8') as f: | |
content = f.read() | |
parts = content.split('=============================') | |
projects = [] | |
for i in range(0, len(parts)-2, 2): | |
projects.append(parts[i] + parts[i+1]) |
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 | |
# Usage: ./generate-certificates.sh {OUTPUT_PATH (default: ./certs)} | |
function genclient() { | |
# Create the client-side certificates | |
OUT=$1 | |
OPENSSL_CLIENT=$2 | |
docker run --rm -v $OUT:/certs -it nginx \ |
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 time | |
import alog | |
def chunks(l, n, logging_step=10): | |
count = 0 | |
total = len(l) | |
start_time = time.perf_counter() | |
for i in range(0, len(l), n): | |
chunk = l[i:i + n] |
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 functools import wraps | |
import time | |
import alog | |
level = 0 | |
def stopwatch(func): | |
@wraps(func) | |
def wrapper(*args, **kwargs): | |
global level | |
level += 1 |
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/sh | |
# Create /etc/nginx/**/*.conf from replacing the strings like | |
# ${NGINX_xxxxx} contained in /etc/nginx/**/*.conf.template | |
# with the value of each environment variable. | |
envs="$(env | egrep '^NGINX_' | sed -r 's/^(.+)=.*/\$\$\1/g')" | |
for template in `find /etc/nginx -name '*.conf.template'` | |
do | |
conf=`basename -s .template $template` |
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 typing import Union | |
import base64 | |
def base64encode(data: Union[bytes, str]) -> bytes: | |
data = data.encode() if type(data) is str else data | |
return base64.urlsafe_b64encode(data).rstrip(b'=') | |
def base64decode(b64: Union[bytes, str]) -> bytes: |
NewerOlder