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
# ISBN 13 桁版チェックディジット計算方法 は https://www.jbpa.or.jp/nenshi/pdf/0208.pdf を参考にした | |
{ | |
# ISBN を stdin から受け取る | |
isbn=$1; | |
# 電子書籍の ISBN から -10 して 13桁目を再計算した値が、紙書籍の ISBN | |
isbn = isbn - 10; | |
isbn_tmp = \ | |
((substr(isbn, 1, 1) + substr(isbn, 3, 1) + substr(isbn, 5, 1) + substr(isbn, 7, 1) + substr(isbn, 9, 1) + substr(isbn, 11, 1)) * 1) + \ | |
((substr(isbn, 2, 1) + substr(isbn, 4, 1) + substr(isbn, 6, 1) + substr(isbn, 8, 1) + substr(isbn, 10, 1) + substr(isbn, 12, 1)) * 3); | |
isbn_chk_digit = 10 - (isbn_tmp % 10); |
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 -e | |
# Windows版Kindleアプリは、購入済みKindle蔵書一覧をXMLファイルとしてローカルに置く。 | |
# XML から JSON に簡易に変換できる CLI ツールとして dasel を利用している。 | |
# https://daseldocs.tomwright.me/ | |
# dasel は凝ったクエリは未だ jq ほどには記述できないので、 dasel からの出を jq で加工している。 | |
# 依存ツールは scoop でインストールできる。 | |
# sort,tr,awk,tailなどUNIXコマンドは Git Bash で入れることにしている。趣味に合わせて好きにしたらよい。 |
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
/** | |
* Feel free to explore, or check out the full documentation | |
* https://docs.newrelic.com/docs/synthetics/new-relic-synthetics/scripting-monitors/writing-api-tests | |
* for details. | |
*/ | |
var assert = require('assert'); | |
// Google Public DNS の API エンドポイントに投げると JSON で DNS レコードを返してくれる | |
// https://developers.google.com/speed/public-dns/docs/doh/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
#!/bin/bash | |
## how to use; | |
## get 1 domein; | |
# $ get_dmarc_policy.sh sasasin.net | |
# "_dmarc.sasasin.net.","reject" | |
## bulk get; | |
# $ cat domain_list.txt | xargs -L1 get_dmarc_policy.sh | |
# "_dmarc.example.com." | |
# "_dmarc.example.net.","none" | |
# "_dmarc.example.org.","reject" |
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 -v | |
BOOK_NAME=$1 | |
# 1ファイルに結合する | |
ls *.mp3 \ | |
| sort -u \ | |
| awk '{print "file " $0 "" }' \ | |
> ${BOOK_NAME}.mp3-list.txt | |
ffmpeg \ | |
-f concat \ |
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
# AWS Bedrock の Claude で標準入力の文章を15分の1の文字数に要約するPythonスクリプト | |
# つかいかた; | |
# pip3 install -u boto3 | |
## デフォの15以外の割合に設定したければ | |
# export SUMMERIZE_RATE=10 | |
## デフォの anthropic.claude-v2 以外のモデルを使うなら | |
# export MODEL_NAME="xxxxxxxxxx" | |
# cat hoge.txt | python3 ./summerize-stdin-by-bedrock.py | |
import os |
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
# OpenAI GPT-4 で標準入力の文章を15分の1の文字数に要約するPythonスクリプト | |
# つかいかた; | |
# pip3 install -u OpenAI | |
# export OPENAI_API_KEY="......." | |
## デフォの15以外の割合に設定したければ | |
# export SUMMERIZE_RATE=10 | |
## デフォの gpt-4-1106-preview 以外のモデルを使うなら | |
# export MODEL_NAME="gpt-3.5-turbo-1106" | |
# cat hoge.txt | python3 ./summerize-stdin-by-openai.py |
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
# 環境変数 LOG_LEVEL のログレベルでロギングできる。無指定のデフォは WARNING となる | |
# 参考; https://docs.python.org/ja/3/howto/logging.html | |
# 参考; https://docs.aws.amazon.com/ja_jp/lambda/latest/dg/python-logging.html | |
# Lambdaランタイムでは LambdaLoggerHandler が挟まってるため、 | |
# ローカルで動いてたのがLambdaランタイムではウンともスンともならないことがある | |
# 参考; https://www.google.com/search?q=LambdaLoggerHandler | |
import os | |
import logging | |
def lambda_handler(event, context): |
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
# MySQL で Waiting for table metadata lock の原因となってるプロセスを特定するSQL | |
select pl.* | |
, ml.* | |
from information_schema.processlist as pl | |
inner join performance_schema.threads as th | |
on pl.id = th.processlist_id | |
inner join performance_schema.metadata_locks as ml | |
on th.thread_id = ml.owner_thread_id | |
where | |
# 「GRANTED」が実際にロックを掴んでる。 |
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
# CloudWatch Logs Insights で調べたいロググループと時間範囲を選んで、以下クエリを実行する。 | |
# bin(24h) は 24h 単位に集約して集計しろという指定。調べたい期間に書き換えて実行する。5m とか 8h とか 2d とか | |
# https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/CWL_QuerySyntax-Stats.html | |
fields @timestamp, @message, @logStream, @log | |
| filter @type = "REPORT" | |
| stats min(@maxMemoryUsed), avg(@maxMemoryUsed), max(@maxMemoryUsed) by bin(24h) |
NewerOlder