Skip to content

Instantly share code, notes, and snippets.

@knishioka
knishioka / moneyfoward_login.py
Last active January 16, 2021 22:37
moneyforward login attempt
import requests
s = requests.Session()
url = "https://id.moneyforward.com/sign_in"
payload = {"mfid_user[email]": "[email protected]", "mfid_user[password]": "barbaz"}
s.post(url, data=payload)
res = s.get("https://moneyforward.com/bs/portfolio")
@knishioka
knishioka / update_aws_access_key.sh
Last active December 11, 2020 08:09
Update AWS Access Key by awscli
username=
current_access_key=$(aws configure get aws_access_key_id)
aws=$(aws iam create-access-key --user-name $username)
aws configure set aws_access_key_id $(jq -r '.AccessKey.AccessKeyId' <<< $aws)
aws configure set aws_secret_access_key $(jq -r '.AccessKey.SecretAccessKey' <<< $aws)
aws iam delete-access-key --access-key-id $current_access_key
@knishioka
knishioka / add_datetime_prefix_to_mp4_files.sh
Last active November 8, 2020 14:10
Add datetime prefix to MP4 files
for file in *.MP4; do
new_file_name=$(date -v+9H -j -f "%Y-%m-%dT%H:%M:%S.000000Z" "$(ffprobe -v quiet -select_streams v:0 -show_entries stream_tags=creation_time -of default=noprint_wrappers=1:nokey=1 $file)" "+%Y-%m-%d %H%M%S_$file")
cp "$file" "$new_file_name"
done
@knishioka
knishioka / add_datetime_prefix_to_gopro_files.sh
Last active November 8, 2020 14:10
Add datetime prefix to GoPro files
for file in GH*.MP4; do
new_file_name=$(date -j -f "%Y-%m-%dT%H:%M:%S.000000Z" "$(ffprobe -v quiet -select_streams v:0 -show_entries stream_tags=creation_time -of default=noprint_wrappers=1:nokey=1 $file)" "+%Y-%m-%d %H%M%S_$file")
cp "$file" "$new_file_name"
done
@knishioka
knishioka / sub_9h_from_creation_time.sh
Created August 30, 2020 11:55
subtract 9hours from creation time
target_dir=creation_time_changed
mkdir "$target_dir"
for movie in *.MP4; do
creation_time=$(TZ=0 gdate -d "$(ffprobe -v quiet -select_streams v:0 -show_entries stream_tags=creation_time -of default=noprint_wrappers=1:nokey=1 $movie | sed 's/Z/+09:00/')" "+%Y-%m-%dT%T.000000Z")
ffmpeg -i $movie -metadata creation_time="$creation_time" -c copy "${target_dir}/${movie}"
done
@knishioka
knishioka / convert_mp4_to_60fps
Created August 30, 2020 02:01
Convert MP4 to 60fps with keeping meta data
mkdir 60fps
for movie in *.MP4; do
echo converting $movie
ffmpeg -i $movie -map_metadata 0 -map_metadata:s:v 0:s:v -map_metadata:s:a 0:s:a -c copy -f ffmetadata ffmetadata.txt -y
ffmpeg -i $movie -i ffmetadata.txt -map_metadata 1 -r 60 "60fps/${movie}"
done
@knishioka
knishioka / count_merged_pull_requests.py
Last active May 15, 2022 22:23
Count merged pull requests
import requests
import json
token = ''
org = ''
author = ''
start_date = '2019-10-01'
end_date = '2019-12-31'
query = f'org:{org}+author:{author}+merged:{start_date}..{end_date}'
@knishioka
knishioka / terraform_iam_pass_decryption
Created July 27, 2019 14:40
terraformでiamのパスがリストで返ってくるときに複合するための手順
for encrypted_pass in $(terraform output -json | jq -r '.aws_iam_user_admin_password.value[]'); do
pass=$(echo $encrypted_pass | tr -d '\n' | base64 -D | gpg -dr $keyname)
echo $pass
done

Keybase proof

I hereby claim:

  • I am knishioka on github.
  • I am kenichiro (https://keybase.io/kenichiro) on keybase.
  • I have a public key whose fingerprint is FE43 3018 8F51 FF88 4084 296E CD38 E38D 4B5D 72B1

To claim this, I am signing this object:

@knishioka
knishioka / create_new_aws_credential.sh
Last active July 6, 2019 16:27
create new aws credential key and set it to aws cli and s3cmd
# 使い方
# curl https://gist.githubusercontent.com/knishioka/86df4725105bd28d910fb67613c81b76/raw/create_new_aws_credential.sh | bash -s username
# usernameに対象となるユーザを指定
# linuxのユーザ名とiamのユーザ名同じ場合を想定
username=$1
echo $username
# 古いキーを取得。一つのアカウントに付き一つのキーで管理しているとする
old_key=$(aws iam list-access-keys --user-name $username | jq -r '.AccessKeyMetadata[0].AccessKeyId')