Skip to content

Instantly share code, notes, and snippets.

View sakkke's full-sized avatar

Konosuke Sakai sakkke

View GitHub Profile
# https://superuser.com/a/532109
param([switch]$Elevated)
function Test-Admin {
$currentUser = New-Object Security.Principal.WindowsPrincipal $([Security.Principal.WindowsIdentity]::GetCurrent())
$currentUser.IsInRole([Security.Principal.WindowsBuiltinRole]::Administrator)
}
if ((Test-Admin) -eq $false) {
if ($elevated) {
function debug (foo) {
console.log(foo)
return foo
}
@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
@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
#!/bin/sh
hash "$@" >/dev/null 2>&1
#!/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"
@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
@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
[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
untar() { local tar="$1"; tar -tf "$tar" | fzf -m | tar -vxT - -f "$tar"; }