Skip to content

Instantly share code, notes, and snippets.

View rsp9u's full-sized avatar

rsp9u rsp9u

  • Japan
View GitHub Profile
@rsp9u
rsp9u / client.log
Last active October 18, 2022 08:59
OpenSSH client disconnecting
OpenSSH_8.0p1, OpenSSL 1.1.1b 26 Feb 2019
debug1: Reading configuration data /home/rsp9u/.ssh/config
debug1: /home/rsp9u/.ssh/config line 1: Applying options for raspi
debug1: Reading configuration data /etc/ssh/ssh_config
debug2: resolve_canonicalize: hostname 192.168.63.10 is address
debug2: ssh_connect_direct
debug1: Connecting to 192.168.63.10 [192.168.63.10] port 50022.
debug1: Connection established.
debug1: identity file /home/rsp9u/.ssh/id_rsa type 0
debug1: identity file /home/rsp9u/.ssh/id_rsa-cert type -1
@rsp9u
rsp9u / randpw.py
Created June 12, 2019 05:42
A password generator (no rules)
import sys
import string
import random
if len(sys.argv) >= 2:
pwlen = int(sys.argv[1])
else:
pwlen = 16
print("".join(random.choices(string.ascii_letters + string.digits + string.punctuation, k=pwlen)))
@rsp9u
rsp9u / exec
Created August 19, 2019 05:53
Changing shell script behavior by stdin file type
$ ./stdin_mode.sh
ISCHR
$ cat a_file | ./stdin_mode.sh
ISFIFO
$ ./stdin_mode.sh < a_file
ISREG
@rsp9u
rsp9u / Dockerfile
Created September 20, 2019 02:31
docker-cypress
FROM cypress/base:10
RUN apt-get update && \
apt-get install -y locales fonts-takao-gothic fonts-takao-mincho && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
RUN echo "ja_JP UTF-8" > /etc/locale.gen && \
locale-gen && \
update-locale LANG=ja_JP.UTF-8 && \
update-locale LANGUAGE="ja_JP:ja" && \
dpkg-reconfigure --frontend nointeractive locales && \
@rsp9u
rsp9u / .zshrc
Created September 24, 2019 07:45
Jump to specified history index with zsh and fzf
fzf-select-history() {
HISTNO=$(history | fzf +m --tac | sed -e 's/^\s*\([[:digit:]]\+\)\s\+.*$/\1/')
zle reset-prompt
}
zle -N fzf-select-history
bindkey '^r' fzf-select-history
@rsp9u
rsp9u / decorator.h
Created October 19, 2019 00:46
c++ function decorator like python
template <template <typename> typename F, typename T>
F<T> deco(T func) {
return F<T>(func);
}
@rsp9u
rsp9u / curl-client.sh
Last active October 27, 2019 13:44
Hydra implicit test
#!/bin/sh
if [ "$1" = "random.js" ]; then
state=$(docker run --rm -v $PWD/random.js:/src/random.js -w /src node:12-alpine sh -c "yarn add uuid && node random.js" | tail -n1)
nonce=$(docker run --rm -v $PWD/random.js:/src/random.js -w /src node:12-alpine sh -c "yarn add uuid && node random.js" | tail -n1)
else
state=$(uuidgen)
nonce=$(uuidgen)
fi
ret=$(curl "http://localhost:4444/oauth2/auth?client_id=my-client&response_type=token&state=$state&nonce=$nonce&scope=openid" -i 2>/dev/null)
@rsp9u
rsp9u / adjust.sh
Last active November 30, 2019 12:39
Adjust timestamps of git author date and committer data.
#!/bin/sh
export FILTER_BRANCH_SQUELCH_WARNING=1
timediff=$(( $(date -d "2019/11/30 18:28:46" +%s) - $(date -d "Wed Nov 27 08:16:58 2019" +%s) ))
for commit_hash in $(git log --pretty=oneline --author=$1 | cut -d" " -f1); do
git log -n1 $commit_hash --pretty=fuller
author_fixed=$(date -d @"$(( $(date -d "$(git log $commit_hash -n1 --pretty=fuller | grep AuthorDate | cut -d: -f2- | rev | cut -d" " -f2- | rev)" +%s) + $timediff ))" +%s)
commit_fixed=$(date -d @"$(( $(date -d "$(git log $commit_hash -n1 --pretty=fuller | grep CommitDate | cut -d: -f2- | rev | cut -d" " -f2- | rev)" +%s) + $timediff ))" +%s)
echo "author: " $(date -d @"$author_fixed")
@rsp9u
rsp9u / Raspi2-Arch.md
Created December 14, 2019 04:21
Installation guide of Archlinux into Raspberry Pi 2
  1. Write to a SD card on the existing linux machine
    # pacman -Syu dosfstools
    # cfdisk /dev/sdb
    # mkfs.vfat /dev/sdb1
    # mkfs.ext4 /dev/sdb2
    # mount /dev/sdb2 /mnt
    # mkdir /mnt/boot
    # mount /dev/sdb1 /mnt/boot
    # wget http://os.archlinuxarm.org/os/ArchLinuxARM-rpi-2-latest.tar.gz  #see https://archlinuxarm.org/about/downloads
    
@rsp9u
rsp9u / plantuml_encoder.go
Created December 27, 2019 16:26
The PlantUML encoder written by Go
package pumlencode
import (
"bytes"
"compress/zlib"
"encoding/base64"
)
func makeTable() map[rune]rune {
src := []rune{}