Skip to content

Instantly share code, notes, and snippets.

View guitarrapc's full-sized avatar
:octocat:

Ikiru Yoshizaki guitarrapc

:octocat:
View GitHub Profile
<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;
}
@guitarrapc
guitarrapc / aws_oidc-auth_workflow.yaml
Last active January 5, 2023 08:03
GitHub Actions to cache aws auth in each workflow run, then reuse in jobs. Workaround for https://github.com/aws-actions/configure-aws-credentials/issues/299.
name: aws oidc credential with cache
on:
workflow_dispatch:
push:
branches: ["main"]
pull_request:
branches: ["main"]
# github.job = job name
@guitarrapc
guitarrapc / main.tf
Created November 4, 2021 16:59
IAM Role Assume for GitHub Actions OIDC with AWS OIDC Provider.
// oidc provider
resource "aws_iam_openid_connect_provider" "main" {
url = "https://token.actions.githubusercontent.com"
client_id_list = ["sts.amazonaws.com"]
thumbprint_list = ["a031c46782e6e6c662c2c87c76da9aa62ccabd8e"]
}
// role
data "aws_iam_policy_document" "github_oid_assume_role_policy" {
statement {
@guitarrapc
guitarrapc / aws_oidc_credential.yaml
Last active October 31, 2021 20:16
Allow GitHub Actions to assume AssumeRoleWithWebIdentity. terraform to create OIDC Provider and IAM Role.
# see: https://github.com/guitarrapc/githubactions-lab
name: aws oidc credential
on:
workflow_dispatch:
push:
branches: ["main"]
# allow use id-token
permissions:
BenchmarkRunner.Run<BenchmarkLinqWhereFirst>();
[BenchmarkDotNet.Attributes.MemoryDiagnoser]
public class BenchmarkLinqWhereFirst
{
private readonly int[] data;
public BenchmarkLinqWhereFirst()
{
data = Enumerable.Range(1, 1000).ToArray();
}
BenchmarkRunner.Run<BenchmarkInterpolatedHandler>();
[BenchmarkDotNet.Attributes.MemoryDiagnoser]
public class BenchmarkInterpolatedHandler
{
[Benchmark]
public void StringInterpolationInline() => PrintAInline(0);
[Benchmark]
public void StringInterpolationNoInline() => PrintANoInline(0);
BenchmarkRunner.Run<BenchmarkInline>();
[BenchmarkDotNet.Attributes.MemoryDiagnoser]
public class BenchmarkInline
{
[Benchmark]
public void StringInterpolationInline() => PrintAInline(0);
[Benchmark]
public void StringInterpolationNoInline() => PrintANoInline(0);
@guitarrapc
guitarrapc / Get-StorageBusType.ps1
Last active May 20, 2023 07:42
Detect is Windows Storage is NVMe, SSD or USB
# Run on Windwos PowerShell or pwsh. Don't needd Administrator Priviledge
# BusType 17 = NVMe, 11 = SATA, 7 = USB. see https://docs.microsoft.com/en-us/previous-versions/windows/desktop/stormgmt/msft-disk
Get-CimInstance -namespace Root\Microsoft\Windows\Storage -class msft_physicaldisk | select FriendlyName, BusType