Skip to content

Instantly share code, notes, and snippets.

View mamemomonga's full-sized avatar

Shotaro Takahashi mamemomonga

View GitHub Profile
@mamemomonga
mamemomonga / awscli.md
Last active December 11, 2019 12:47
AWSとawscliメモ

AWSとawscliメモ

Profile機能をつかって、複数のAWSアカウントを利用する

初期設定

$ aws configure --profile=myaws1

次回以降、ターミナルログインのたびに以下のコマンドを実行すれば、そのプロファイルが使用される

@mamemomonga
mamemomonga / xrdp.md
Created December 8, 2019 13:42
Ubuntu 18.04へのxrdpの導入と面倒なダイアログ削除

Ubuntu 18.04へのxrdpの導入と面倒なダイアログ削除

$ sudo apt install xrdp
$ sudo sh -c 'cat > /etc/polkit-1/localauthority.conf.d/02-allow-colord.conf' << 'EOS'
polkit.addRule(function(action, subject) {
   if ((action.id == "org.freedesktop.color-manager.create-device" ||
        action.id == "org.freedesktop.color-manager.create-profile" ||
        action.id == "org.freedesktop.color-manager.delete-device" ||
        action.id == "org.freedesktop.color-manager.delete-profile" ||

action.id == "org.freedesktop.color-manager.modify-device" ||

@mamemomonga
mamemomonga / tmux-plus.md
Last active March 1, 2022 16:06
tmuxにおけるssh-agentの継続利用

tmuxにおけるssh-agentの継続利用

  • bin/run-tmuxというシェルスクリプトを経由して起動する。デタッチ後も以前のssh-agentを利用できるようにする。
  • セッションがあればattach、セッションがなければ新しいセッションを開始する
  • セッションがなければ、ssh-agentを起動し、SSH_AUTH_SOCK, SSH_AGENT_PIDを .ssh/tmux-ssh-agent に保存しtmuxセッションを開始する。
  • bash や zsh起動時には .ssh/tmux-ssh-agent の環境変数を読み込むことでssh-agentを利用可能にする。
  • セッション開始時に bin/run-tmux agent-killer を起動し、数秒おきにtmuxの終了をチェック、終了されていたらssh-agentを停止する。
  • ssh-agentのPIDが無効ならばファイルを削除する。

注意点

@mamemomonga
mamemomonga / arduino-cli.md
Created November 12, 2019 21:56
arduino-cliメモ

arduino-cliメモ

ArduinoチームがつくってるCLIのArduino

arduino-cli

事前準備

$ cd
$ mkdir bin
@mamemomonga
mamemomonga / gh-user.sh
Created November 7, 2019 05:45
GitHubに登録されている公開鍵を参照する
apt install jq
bash << 'EOS'
GH_USERNAME=mamemomonga
curl -s "https://api.github.com/users/$GH_USERNAME/keys" | jq -r '.[]|.key+" '$GH_USERNAME'@github/"+(.id|tostring)'
EOS
@mamemomonga
mamemomonga / append-github-user.sh
Last active April 6, 2022 03:03
GitHubに登録されたSSH公開鍵でログイン可能な同名のUNIXユーザを作成する。
#!/bin/bash
set -eu
# デフォルトのパスワードが作成され ~/passwords.txt で保存されます。
if [ "$(id -u)" != "0" ]; then
echo "please run as root"
exit 1
fi
@mamemomonga
mamemomonga / マリリンマンソン.pl
Last active September 25, 2019 12:17
マリリンマンソン
#!/usr/bin/env perl
use strict;
use warnings;
my @d=qw(リ ン ソ);
my $d;
sub c { $d.=$d[int(rand($#d))] }
foreach(1..20) {
$d.="マ";
foreach(0..2) { c }
@mamemomonga
mamemomonga / launch.md
Last active September 20, 2019 01:42
サーバが起動して SSHが有効になるまで待つ

サーバが起動して SSHが有効になるまで待つ

while ! ssh -o 'ConnectTimeout=1' user@host true; do
	sleep 1
done
@mamemomonga
mamemomonga / amazon-shop-url-cleanup.sh
Last active March 22, 2022 04:41
クリップボードにあるAmazon.co.jpの商品URLを綺麗にする(macOS用)
#!/bin/bash
set -eu
RESULT="$(pbpaste | perl -E 'my $url=<>; chomp; $url=~m#(/dp/[^/]+)(?:\?|/)#; say "https://amazon.co.jp$1"')"
echo "$RESULT"
echo "$RESULT" | pbcopy