Skip to content

Instantly share code, notes, and snippets.

View guitarrapc's full-sized avatar
:octocat:

Ikiru Yoshizaki guitarrapc

:octocat:
View GitHub Profile
@guitarrapc
guitarrapc / README.md
Last active June 22, 2023 15:05
Minimum sample of IAM User MFA input on awscli. This is same pattern of switch role to same account.

README

  1. Terraformを実行して IAM user a-user と IAM Role mfa-roleを作成します。 a-usermfa-role にAssumeRoleできます。mfa-role は 同一アカウントからの AssumeRoleを許可しますが利用には mfaが必須です。mfa-role は S3 へのフルアクセスを持っています。
  2. ~/.aws/credentials を作成します。 ~/.aws/credentials の a-user プロファイルは IAM User a-user の aws access/secretkey の入力に使います。
  3. ~/.aws/config を作成します。 ~/.aws/config で、 mfa-role プロファイルは、a-user から mfa-role にAssumeRoleし利用すること。mfa-role が求めるmfaに mfa_serialで指定した に IAM User a-user の仮想MFAデバイスのarnを使うことを宣言します。mfa_serial によって、aws cli はmfaが必要な時に自動的にプロンプトを行います。

準備ができました。aws cli で mfa-role プロファイルとして s3一覧取得を実行しましょう。 コマンドを実行すると、.aws/config で指定した IAM User の MFAデバイスのパスコード入力が求められます。TOTP を入力すると、IAM Role mfa-role に付与されたポリシーに従って S3 バケットのリストを列挙します。 S3 アクセス権限は IAM User a-user にはなかったので、mfa-role に AssumeRole され、また MFA が必須になっていることがわかります。

@guitarrapc
guitarrapc / BlittableBool.cs
Created June 21, 2023 07:07
C# bool is not Blittable. Instead, use byte or wrap byte to offer BlittableBool.
public struct BlittableBool
{
public readonly byte Value;
public BlittableBool(byte value)
{
Value = value;
}
public BlittableBool(bool value)
@guitarrapc
guitarrapc / FontInstaller.cs
Last active May 31, 2023 19:53
Windows Font installer. Install Fonts to System Font, and use it without Windows restart.
using Microsoft.Win32; // use NuGet Microsoft.Win32.Registry
using System;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
public static class FontNative
{
[DllImport("user32.dll")]
public static extern IntPtr SendMessage(IntPtr hWnd, int Msg, IntPtr wParam, IntPtr lParam);
@guitarrapc
guitarrapc / README.md
Created May 15, 2023 09:30
Reids Cluster on docker

Subscribe

docker compose exec redis /bin/bash
redis-cli -h redis-node-5 -a bitnami -c
> ssubscribe sfoo
> ssubscribe sbar

Publish

@guitarrapc
guitarrapc / parse.bat
Created May 8, 2023 06:52
Using parameters in batch files at Windows command line.
@echo off
:: parse.bat --foo --bar
:: parse.bat --foo --bar --param 1
:: parse.bat --foo --bar --param2 5
:: parse.bat --foo --bar --param2 5 --param 100
:: parse.bat --foo --bar --param 1 --param2 5
setlocal
:parse
if "%~1"=="" GOTO endparse
@guitarrapc
guitarrapc / git-pull.bat
Last active May 10, 2023 19:04
Script to run `git pull` inside all subdirectories which are git repositories. For Windows, macOS and Linux.
:: Script to run `git pull` inside all subdirectories which are git repositories.
:: usage 1: keep local changes, then up to date.
:: > git-pull.bat
:: usage 2: abort local changes, reset if possible, then up to date.
:: > git-pull.bat --force --no-stash
:: usage 3: try keep local changes, reset if possible, then up to date.
:: > git-pull.bat --force
@echo off
@guitarrapc
guitarrapc / README.md
Last active April 20, 2023 06:41
Workaround for https://github.com/googleforgames/agones/issues/1990. Agones on DockerDesktop k8s and host access.
# dry-run
bash ./local_agones_forwarder.sh --dry-run true
# apply yaml
bash ./local_agones_forwarder.sh
@guitarrapc
guitarrapc / curl_retry.sh
Created April 13, 2023 08:20
curl retry. docker gpg server is unstable these days.... 2023
# connect-timeout: 1s = connect timeout. if network connect is stopped frequentry, 1s will be strong option.
# max-time: 10s = must finish within this time
# retry: 5 = retry count
# retry-delay: 0 = no exponential backoff
# retry max time: 60 = retry no longer than
curl --connect-timeout 1 --max-time 10 --retry 5 --retry-delay 0 --retry-max-time 60 -fsSL https://download.docker.com/linux/ubuntu/gpg
@guitarrapc
guitarrapc / README.md
Created April 12, 2023 18:19
Terraform Graph generator and visualizer comparison

tl;dr;

terraform graph ではグラフ表示が厳しすぎる。 もっといい感じにリソースを構成図に落とし込んだり確認したい。

できれば、Pulumi の Graph View がよい。

候補1. terraform-graph-beautifier

pcasteran/terraform-graph-beautifier: Terraform graph beautifier

@guitarrapc
guitarrapc / README.md
Created April 12, 2023 09:46
2023年4月の Agones 事情

Agones

Kubernetes 上に Agones Controller (+ Agones Allocator) を配置して、DGS (Dedicated Game Server = Agones で管理する専用Pod) を確保する。

  • セルフホスト: 自分の Kubernetes Cluster (GKE、EKS、AKS どれでもOK) に Agones をインストールして、Agones Controller 経由でリクエストを投げて DGS を管理していく。
  • マネージド: オワコン気配

Managed Agones

GCPお得意のサービス終了させた気配がある。アナウンスはないようだが、サイレントにしれっと終了っぽい。