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
| #!/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 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
| # 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 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
| # 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 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
| # 環境変数 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 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
| # 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 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
| # 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) |
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 boto3 | |
| from datetime import datetime | |
| def lambda_handler(event, context): | |
| # CloudWatch Metrics に付与するタイムスタンプとして使う | |
| timestamp = datetime.utcnow() | |
| client = boto3.client('ec2') | |
| responses = [] | |
| next_token = None |
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
| #!/bin/bash | |
| set -eo pipefail | |
| # オライリージャパンで購入した電子書籍を、ブクログにISBN登録するやつ。 | |
| # https://www.oreilly.co.jp/ebook/bookshelf をウェブブラウザで開いて、全選択 & コピーして、 | |
| pbpaste \ | |
| | grep ISBN \ | |
| | sed -e 's| |\n|g' \ | |
| | grep 978 \ | |
| | sed -e 's|-||g' | |
| # で出てきた ISBN コードのリストを https://booklog.jp/input に「ISBN コードでまとめて登録」 |
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
| #!/bin/bash | |
| # コンテナイメージ名っぽい文字列を抽出するやつ | |
| # 組織のgitリポジトリをドサッと手元に持ってきて、リポジトリ横断でリストアップしたい | |
| # ファイル形式それぞれで漁り方が異なる | |
| # フィルタリングが不完全で、コンテナ名ではないものが残ることがあるし、コンテナ名が除外されてることもある(かもしれない) | |
| # rg は ripgrep | |
| # rg --type xxxx が指す拡張子の調べ方は rg --list-type | grep xxxx で出る | |
| # 詳しくは https://github.com/BurntSushi/ripgrep/blob/master/GUIDE.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
| #!/bin/bash -e | |
| set -o pipefail | |
| # AWS Amplify Hosting の任意の年月日のアクセスログをダウンロードしてS3にアップするやつ。 | |
| # 1個2個なら app id や domain name を直接指定してもいいけど、数が多いと面倒なので、 | |
| # app id と domain name のリストを作って、ループで回して全部取ってくる。 | |
| # このシェルスクリプトを毎日1回 cron で回せば毎日のアクセスログを取得できる。 | |
| # 本音は CloudFront みたくポチポチしたらS3に勝手に出るようになってほしい。 | |
| # この S3 バケットのパスにアップロードする | |
| S3_BUCKET_NAME_PATH=$1 |