Skip to content

Instantly share code, notes, and snippets.

View kyontan's full-sized avatar
♨️

kyontan kyontan

♨️
View GitHub Profile
@kyontan
kyontan / pamove
Created June 2, 2020 08:40
PulseAudio sink-output changer
#!/usr/bin/env ruby
class String
def to_i_first
self.match(/\d+/)[0].to_i
end
def unquote_str
self.match(/"(.*)"/)[1]
end
@kyontan
kyontan / bpf.c
Created December 27, 2020 15:24
pyroute2 + SRv6 example
#include <linux/bpf.h>
int pass(struct __sk_buff *skb) {
return BPF_OK; // packet continues
// return BPF_DROP; // packet drops
}
@kyontan
kyontan / fanboxdl.rb
Last active June 14, 2022 13:16
Pixiv FANBOX downloader
#!/usr/bin/env ruby
require "net/http"
require 'net/https'
require "uri"
require "json"
require "fileutils"
require "date"
def fetch(url, sessid)
@kyontan
kyontan / gp_latest_photo_url
Created May 9, 2021 08:44
GoPro interval photo taker (Hero5)
#!/bin/bash
tmpfile=$(mktemp)
while true; do
curl --silent http://10.5.5.9/gp/gpMediaList > $tmpfile
grep "busy" $tmpfile > /dev/null
if [ $? -eq 1 ]; then break; fi
sleep 1
done
@kyontan
kyontan / bash_profile.bash
Created June 10, 2021 09:52
envchain autocompletion (wip)
# not used, copied function body into _delegate
function _executables {
local exclude=$(compgen -abkA function | sort)
local executables=$(
comm -23 <(compgen -c) <(echo $exclude)
type -tP $( comm -12 <(compgen -c) <(echo $exclude) )
)
COMPREPLY=( $(compgen -W "$executables" -- ${COMP_WORDS[COMP_CWORD]}) )
}
@kyontan
kyontan / deployment.yaml
Created June 19, 2021 16:24
Migrate existing WordPress to bitnami/wordpress-nginx
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: wordpress
name: blog
namespace: default
spec:
replicas: 1
selector:
@kyontan
kyontan / usage.sh
Created June 20, 2021 18:29
Use AWS CLI to access MinIO
$ envchain -s minio AWS_ACCESS_KEY_ID
minio.AWS_ACCESS_KEY_ID: XXX
$ envchain -s minio AWS_SECRET_ACCESS_KEY
minio.AWS_SECRET_ACCESS_KEY: XXX
$ envchain minio docker run --rm -it -e AWS_ACCESS_KEY_ID -e AWS_SECRET_ACCESS_KEY amazon/aws-cli --endpoint-url https://[MinIO Endpoint] s3 ls
@kyontan
kyontan / README.md
Created July 19, 2021 11:40
aws assume-role helper for aws cli

To use this script, set environment variables below:

AWS_ROLE_ARN=arn:aws:iam::XXX:role/XXX
AWS_ROLE_SESSION_NAME=a_role_accessed_from_cli
AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
AWS_DEFAULT_REGION=
@kyontan
kyontan / .bash_profile
Created July 19, 2021 11:50
envchain completion (わからん)
function _delegate() {
local cur subs
cur="${COMP_WORDS[COMP_CWORD]}" # partial word, if any
subs=$(envchain -l)
# echo "cword: $COMP_CWORD"
# echo "cw: ${COMP_WORDS[COMP_CWORD]}"
# echo "cl: ${COMP_LINE}, ccw: ${COMP_CWORD}, cp: ${COMP_POINT}, cw3: ${COMP_WORDS[2]}"
if [[ $COMP_CWORD == 1 ]]; then
# complete with the list of subcommands
@kyontan
kyontan / clustername-0-mysqld.log
Created July 29, 2021 04:21
moco-cluster failed to create cluster log
2021-07-29T03:11:56.234169Z 0 [Note] [MY-010098] [Server] --secure-file-priv is set to NULL. Operations related to importing and exporting data are disabled
2021-07-29T03:11:56.234218Z 0 [Note] [MY-010949] [Server] Basedir set to /usr/local/mysql/.
2021-07-29T03:11:56.234230Z 0 [System] [MY-010116] [Server] /usr/local/mysql/bin/mysqld (mysqld 8.0.25) starting as process 1
2021-07-29T03:11:56.436463Z 0 [Note] [MY-012366] [InnoDB] Using Linux native AIO
2021-07-29T03:11:56.436607Z 0 [Note] [MY-010747] [Server] Plugin 'FEDERATED' is disabled.
2021-07-29T03:11:56.438916Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2021-07-29T03:11:56.439002Z 1 [Note] [MY-013546] [InnoDB] Atomic write enabled
2021-07-29T03:11:56.439053Z 1 [Note] [MY-012932] [InnoDB] PUNCH HOLE support available
2021-07-29T03:11:56.439084Z 1 [Note] [MY-012944] [InnoDB] Uses event mutexes
2021-07-29T03:11:56.439112Z 1 [Note] [MY-012945] [InnoDB] GCC builtin __atomic_thread_fence() is used for memory barrier