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 / kustomization.yaml
Last active May 6, 2022 07:12
Agones configMapGenerator suffix hash reference in Agones GameServer and Fleet.
bases:
- ../../agones/overlays/dev
- ../../configmap/overlays/dev
configurations:
- nameref.yaml
public static class TaskExtentions
{
public static Task<TResult[]> WhenAllFailFast<TResult>(IEnumerable<Task<TResult>> tasks)
{
return WhenAllFailFast(tasks.ToArray());
}
public static Task<TResult[]> WhenAllFailFast<TResult>(params Task<TResult>[] tasks)
{
if (tasks is null) throw new ArgumentNullException(nameof(tasks));
if (tasks.Length == 0) return Task.FromResult(new TResult[0]);
@guitarrapc
guitarrapc / CancelCancellationTokenSource.cs
Last active April 15, 2022 02:26
C# CancellatonSource Status when Cancel on cts or LinkedCancellationSource.
// cancel on Source CancellationTokenSource
async Task Main()
{
using var cts = new CancellationTokenSource();
var ct = cts.Token;
var task = FooAsync(ct);
await Task.Delay(TimeSpan.FromSeconds(3));
cts.Cancel();
cts.Dump("cts"); // IsCancellationRequested True
}
@guitarrapc
guitarrapc / command.sh
Created March 15, 2022 07:46
Connect redis-cli in Docker to TLS Encypted ElastiCache Redis Cluster.
# run on host...
docker run -it --entrypoint /bin/bash redis
# run inside docker...
apt-get update
apt-get install -y stunnel net-tools
cat <<EOF > /etc/stunnel/redis-cli.conf
fips = no
setuid = root
setgid = root
pid = /var/run/stunnel.pid
@guitarrapc
guitarrapc / gitsubmodule_cheatsheet.md
Last active January 21, 2022 08:06
git submodule のチートシート。ベースはこれで。十分そろってる。 https://www.m3tech.blog/entry/git-submodule

サブモジュールごと clone したい

git clone https://example.com/repo-with-sub-modules --recursive

サブモジュールのファイルを取得したい

git submodule update --init --recursive
@guitarrapc
guitarrapc / _get_github_oidc_thumbprint.sh
Last active May 26, 2024 18:45
Get Thumbprint of GitHub OIDC, updated on 2022/01/13.
$ openssl s_client -servername token.actions.githubusercontent.com -showcerts -connect token.actions.githubusercontent.com:443 < /dev/null 2>/dev/null | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' | sed "0,/-END CERTIFICATE-/d" > certificate.crt
$ openssl x509 -in certificate.crt -fingerprint -noout | cut -f2 -d'=' | tr -d ':' | tr '[:upper:]' '[:lower:]'
6938fd4d98bab03faadb97b34396831e3780aea1
name: dotnet lint
on:
workflow_dispatch:
schedule:
- cron: 0 1 * * 1 # At AM10:00 JST on Monday
env:
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1
DOTNET_NOLOGO: true
<Main>g__Operator|4_0 (String, String)
L0000 jmp System.String.Equals(System.String, System.String)
<Main>g__Equals|4_1 (String, String)
L0000 mov rax, 0x7fff58527b68
L000a mov rax, [rax]
L000d cmp [rcx], ecx
L000f jmp rax
<Main>g__EqualsComparer|4_2<T> (T, T)
@guitarrapc
guitarrapc / GetSSOProfileCredentials.cs
Last active April 14, 2025 16:50
Reuse AWS SSO Credential in LinqPad or Any C# code. Make sure run `aws sso login` before run code. based on https://github.com/aws/aws-sdk-net/issues/1676
var profile = "YOUR_PROFILE_NAME";
var credentials = LoadSsoCredentials(profile);
// any operation you want to do with sso credentials.
var s3client = new AmazonS3Client(credentials, RegionEndpoint.APNortheast1);
var buckets = await s3client.ListBucketsAsync();
buckets.Dump();
static AWSCredentials LoadSsoCredentials(string profileName)
{
// before .NET 5: Array Bound Check emitted. (BAD)
// after .NET 6: Array Bound Check removed. (GOOD)
void A(int[] a)
{
if (a.Length > 3)
{
a[0] = 1;
a[1] = 2;
a[2] = 3;
}