Skip to content

Instantly share code, notes, and snippets.

Avatar
:octocat:

Ikiru Yoshizaki guitarrapc

:octocat:
View GitHub Profile
@guitarrapc
guitarrapc / Pulumi_ResourcePropertyChanged.md
Last active Jun 21, 2022
Pulumi のパッケージ更新をしたらプロパティ名が変わっており craete-replacement が生じしてしまった時の対処方法
View Pulumi_ResourcePropertyChanged.md

Pulumi リソースのプロパティが変わってしまい create-replacement が発生する場合の対処方法

tl;dr;

  • リソースのプロパティ名変更に対応するには、一度該当 URN を Stateから削除して、インポートしなおす。
  • 残念ながら、リソースの必須プロパティ名の変更で生じる reate-replacement に対処できる Custom Resource Options は存在しない。

see: Allow aliasing when a property which requires replacement changes name · Issue #9115 · pulumi/pulumi pulumi/pulumi#9115

問題の概要

@guitarrapc
guitarrapc / Allow-WSL2UuntuFirewall.ps1
Created Jun 12, 2022
Allow WSL2 Ubuntu 22.04 to access Host Windows Docker Desktop (Windows 11 21H2)
View Allow-WSL2UuntuFirewall.ps1
# set this on Windows TaskScheduler with `At Logon, Run with highest priviledge, Delay task for 1min`
wsl.exe -d Ubuntu-22.04 --exec cat /etc/resolv.conf
Set-NetFirewallProfile -DisabledInterfaceAliases "vEthernet (WSL)" -Name Public
View RightShift.cs
void Main()
{
// 符号なし (unsigned) の 0xFF = 255
byte u = 0xFF;
// 符号付き (signed) の 0xFF = -1
sbyte s = (sbyte)u;
// 符号なしを右シフトすると、左端には 0 が入る。
// 11111111 FF
@guitarrapc
guitarrapc / ExponentialBackoff.cs
Last active Jun 1, 2022
ExponentialBackoff Implemantation via C#.
View ExponentialBackoff.cs
public class ExponentialBackoff
{
private readonly int _delayMilliseconds;
private readonly int _maxDelayMilliseconds;
public int Retries => _retries;
private int _retries;
private int _pow;
public ExponentialBackoff(int delayMilliseconds, int maxDelayMilliseconds)
{
View embed-code.yaml
name: README embed-code
on:
workflow_dispatch:
pull_request:
branches: ["main"]
jobs:
embed-code:
runs-on: ubuntu-latest
View README.md
This is a *markdown* document with a code block:

```ts
// src/example.ts

export function helloWorld(name: string): string {
  return `Hello ${name}!, how are you today?`;
}
View README.md
This is a *markdown* document with a code block:

```ts
// src/example.ts
@guitarrapc
guitarrapc / kustomization.yaml
Last active May 6, 2022
Agones configMapGenerator suffix hash reference in Agones GameServer and Fleet.
View kustomization.yaml
bases:
- ../../agones/overlays/dev
- ../../configmap/overlays/dev
configurations:
- nameref.yaml
View FailFastWhenAll.cs
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 Apr 15, 2022
C# CancellatonSource Status when Cancel on cts or LinkedCancellationSource.
View CancelCancellationTokenSource.cs
// 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
}