Skip to content

Instantly share code, notes, and snippets.

View babarot's full-sized avatar
:octocat:
Work Hard

Masaki ISHIYAMA babarot

:octocat:
Work Hard
View GitHub Profile
@babarot
babarot / convert_arw_to_jpg.sh
Created July 27, 2024 09:00
Convert Sony RAW to JPEG data
dir="${1:-.}"
cnt=1
done=0
files=()
for file in ${dir}/*
do
case ${file##*.} in
"ARW" | "arw")
true
@babarot
babarot / parallel_wait.sh
Last active July 27, 2024 08:14
Wait for a fix number of process in bash
for i in {1..10}
do
{
c=$((RANDOM % 6 + 1))
echo "start $c"
sleep $c
echo "end $c"
} &
if (( (i % 5) == 0 )); then
wait
package main
import (
"errors"
"github.com/jmoiron/sqlx"
_ "github.com/mattn/go-sqlite3"
)
func main() {
Output afx.gif
# Set Theme "Builtin Solarized Dark"
Set FontSize 55
Set Width 2400
Set Height 800
Type "afx install"
Enter
@babarot
babarot / gocover.sh
Created February 16, 2023 01:28
Get go test coverage and open it in browser
#!/bin/bash
out=/tmp/cover.out
html=/tmp/cover.html
go test -cover ./... -coverprofile=$out
go tool cover -html=$out -o $html
open $html
sleep 1
rm $out $html
@babarot
babarot / tmuxx.sh
Created March 11, 2022 15:18
tmux executor
#!/bin/bash
# is_login_shell returns true if current shell is first shell
is_login_shell() {
[[ $SHLVL == 1 ]]
}
# is_git_repo returns true if cwd is in git repository
is_git_repo() {
git rev-parse --is-inside-work-tree &>/dev/null
#!/bin/bash
if ! type sd &>/dev/null; then
echo "sd: command not found" >&2
exit 1
fi
case "${#}" in
0)
echo "too few arguments" >&2
@babarot
babarot / gcp-context
Last active February 28, 2022 07:32
Get current GCP project name / Kubernetes context which you are on.
#!/bin/bash
if ! type jq &>/dev/null; then
echo "jq: not found" >&2
exit 1
fi
if ! type gcloud &>/dev/null; then
echo "gcloud: not found" >&2
exit 1
@babarot
babarot / migrate.sh
Created February 28, 2020 04:00
migrate rego file
for policy in $@
do
if [[ $policy == *_test.rego ]]; then
continue
fi
if [[ $policy == *.rego ]]; then
file=${policy##*/}
mkdir -p .policy/rego/prc/"${file%*.rego}"
git mv $policy .policy/rego/prc/"${file%*.rego}"/src.rego
@babarot
babarot / dockerfile-parser.go
Created February 3, 2020 11:07
Test for parsing Dockerfile
package main
import (
"io"
"os"
"github.com/k0kubun/pp"
"github.com/moby/buildkit/frontend/dockerfile/instructions"
"github.com/moby/buildkit/frontend/dockerfile/parser"
)