Skip to content

Instantly share code, notes, and snippets.

View azrsh's full-sized avatar

azarashi azrsh

  • University of Tsukuba
  • Tsukuba
View GitHub Profile

Keybase proof

I hereby claim:

  • I am azrsh on github.
  • I am azarashi2931 (https://keybase.io/azarashi2931) on keybase.
  • I have a public key ASBuV-Oz4zUSmODkuzgDXKUPcjOeol9Kft-3Wgw5Ny1_JQo

To claim this, I am signing this object:

@azrsh
azrsh / carshare-calendarize.gs
Last active February 18, 2024 16:35
カーシェアの予約時間帯をカレンダーに入れる
const CALENDARIZED_LABEL = "carshare-calendarized";
function isCalendarizable(m) {
return [
"新規予約受付のご案内",
"予約延長受付のご案内",
"予約変更受付のご案内",
].includes(m.getSubject());
}
@azrsh
azrsh / end-time-notification.gs
Last active February 19, 2024 02:01
カレンダーのイベントの終了時刻を通知する。無限に user properties が増えるのでエラーが出たら掃除するといい
function remind() {
const calendars = CalendarApp.getAllCalendars();
for (const calendar of calendars) {
const now = new Date();
for (const event of calendar.getEventsForDay(now)) {
const endTime = event.getEndTime();
const minutesBefore = (minutes) => {
const date = new Date(endTime);
date.setMinutes(endTime.getMinutes() - minutes);
return date;
@azrsh
azrsh / cv.typ
Last active February 10, 2024 01:39
Typst で履歴書を作るテンプレート
#set text(font: ("IPAexMincho"))
#let data = yaml("input/data.yaml")
= 履歴書
#let today = datetime.today()
#let birthday = datetime(year: data.birth_day.year, month: data.birth_day.month, day: data.birth_day.day)
#let age = {
let after-birthday = today.month() > birthday.month() or (
today.month() == birthday.month() and today.day() >= birthday.day()
@azrsh
azrsh / ssh-copy-gh-id
Created January 30, 2024 16:10
Copy public keys registered in GitHub
#!/bin/bash
HOST=$1
curl -sSL "https://github.com/$(gh api user | jq -r '.login').keys" | ssh "${HOST}" 'TEMP=$(mktemp); cat - ~/.ssh/authorized_keys | sort | uniq > ${TEMP}; cat ${TEMP} > ~/.ssh/authorized_keys'
@azrsh
azrsh / azssh
Last active September 6, 2023 11:24
SSH to Azure Virtual Machine with Azure CLI
#!/bin/bash -e
while [[ $# -gt 0 ]]; do
case $1 in
-g|--resource-group)
group="$2"
shift
shift
;;
-n|--name)
font:
normal:
family: "FiraCode Nerd Font"
bold:
family: "FiraCode Nerd Font"
italic:
family: "FiraCode Nerd Font"
env:
TERM: xterm-256color
window:
@azrsh
azrsh / noti
Last active August 31, 2023 08:15
Notify a command completion
#!/bin/bash
$@
EXIT_CODE=${?}
if [ ${EXIT_CODE} = 0 ]; then
MESSAGE="✅ \`${@}\` terminated with exit code ${EXIT_CODE}"
else
MESSAGE="🚨 \`${@}\` terminated with exit code ${EXIT_CODE}"
fi
@azrsh
azrsh / git-branch-prune
Last active November 7, 2022 05:25
origin の デフォルトブランチを取得する / マージ済みブランチを削除する
#!/bin/bash
set -euCo pipefail
function main() {
local default_branch="$(git default-branch)"
git branch -d $(git branch --merged "${default_branch}" | grep -vE "\*|${default_branch}")
}
main
@azrsh
azrsh / assume-chain
Last active November 6, 2022 15:14
assume role + envchain
#!/bin/bash
set -euo pipefail
function main() {
local -r name=$1
local -r arn=$2
local out
out=$(aws sts assume-role --role-arn "$arn" --role-session-name "$USER-$(date +'%s')")