Skip to content

Instantly share code, notes, and snippets.

View sakkke's full-sized avatar

Konosuke Sakai sakkke

View GitHub Profile
function fat32_img_size {
declare dir="$1"
declare -i unit_sector=512
declare -i reserved_sectors=32
declare -i num_fats=2
declare -i num_paths=$(find "$dir" -mindepth 1 | wc -l)
declare -i fat_sectors=$((num_paths * unit_sector / num_fats - 1))
untar() { local tar="$1"; tar -tf "$tar" | fzf -m | tar -vxT - -f "$tar"; }
[Containments][2]
lastScreen=0
plugin=org.kde.panel
[Containments][2][Applets][1]
plugin=org.kde.plasma.panelspacer
[Containments][2][Applets][2]
plugin=org.kde.plasma.kickoff
@sakkke
sakkke / git-editdate.sh
Created January 2, 2023 00:30
One-liner of editing author and committer date
git commit --amend --date "$(date --date="$(git show --format=%ai --no-patch HEAD) 2 minutes ago" '+%Y/%m/%d %H:%M:%S %z')" --no-edit
@sakkke
sakkke / git-editdate.sh
Last active October 7, 2022 05:26
A function to edit author date and committer date of a git commit
# Usage: git-editdate 10 minutes ago
# Usage: git-editdate 3 hours 2 minutes 1 second
# Usage: git-editdate author
#
# Extra Usage:
# # Set command to edit since HEA0~10
# env GIT_SEQUENCE_EDITOR='sed --in-place "s/^pick /edit /"' git rebase --interactive HEAD~10
#
# # do-while
# while
#!/bin/bash
set -e
screenshots_dir="$HOME/Pictures/screenshots"
[ ! -d "$screenshots_dir" ] && mkdir -vp "$screenshots_dir"
crop="$(crop)"
screenshot_path="$screenshots_dir/screenshot-$(date +%s).jpg"
import -window root -crop "$crop" "$screenshot_path"
#!/bin/sh
hash "$@" >/dev/null 2>&1
@sakkke
sakkke / hr.sh
Created September 5, 2021 09:20
Bash version of <hr>
#!/bin/bash
(shopt -s checkwinsize)
for i in $(seq 1 $COLUMNS); do
printf ─
done
echo
@sakkke
sakkke / setup.sh
Last active September 23, 2021 01:46
Setup script for 2021-05-07-raspios-buster-arm64-lite.img
# raspberrypi login: pi
# Password: raspberry
# Time zone: Asia/Tokyo
# Keyboard layout: jp
function setup1 {
sudo raspi-config nonint do_change_locale ja_JP.UTF-8
sudo raspi-config nonint do_boot_behaviour B2
function debug (foo) {
console.log(foo)
return foo
}