Skip to content

Instantly share code, notes, and snippets.


Ikiru Yoshizaki guitarrapc

Block or report user

Report or block guitarrapc

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View FizzBuzz.ps1
#50 {Fizz}[0] = Fizz
1..100|%{($t=""+{Fizz}[$_%3]+{Buzz}[$_%5])?$t :$_}
#51 "Fizz"*$true = Fizz
1..100|%{($t='Fizz'*!($_%3)+'Buzz'*!($_%5))?$t :$_}
1..100|%{$t=$_%3?"":"Fizz";$_%5?$t ?$t :$_ :$t+"Buzz"}
View CSaharp9_TargetTypedNew.cs
using System;
using System.Collections.Generic;
public class TargetTypedNewClass1
// no right side type inference (C# 8)
static readonly Dictionary<string, string> cache1 = new Dictionary<string, string>();
// target typed new. right side type inferenece (C# 9.0)
static readonly Dictionary<string, string> cache2 = new();
guitarrapc / GenerateTerraform_GuardDuty.cs
Last active Mar 5, 2020
generate terraform guardduty for all region via C# template. (member account is not scoped)
View GenerateTerraform_GuardDuty.cs
void Main()
var awsProviderVersion = "2.51.0";
static string[] GenModules()
return Amazon.RegionEndpoint.EnumerableAllRegions
.Where(x => !IsSpetialRegion(x.SystemName))
View 01_Basic_TryExpressionTree.cs
void Main()
// GOAL: (object target) => (object)((T)target).PropertyName
// target => Convert(Convert(target, MyClass).MyProperty, Object)
Expression<Func<object, object>> expr = target => ((MyClass)target).MyProperty;
// trarget => Convert(Convert(trarget, MyClass).MyProperty, Object)
var type = typeof(MyClass);
View RouteLoggingMiddleware.cs
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Logging;
using System.Threading.Tasks;
namespace LoggerSample
public class RouteLoggingMiddleware
private readonly RequestDelegate _next;
guitarrapc / Main.cs
Created Jan 15, 2020
Deserialize Pulumi Resource JSON
View Main.cs
void Main()
var json = File.ReadAllText(@"pulumi_20200115.json");
var pulumi = System.Text.Json.JsonSerializer.Deserialize<PulumiResource>(json);
var parents = pulumi.deployment.resources.Select(x => x.parent).Where(x => x != null).ToArray();
var keys = pulumi.deployment.resources.Select(x => x.urn).ToArray();
View DetectEol.cs
public static class DetectEndOfLine
public static EndOfLineStyle Detect(string pathToFile)
int bufl = 0;
var buf = ArrayPool<char>.Shared.Rent(8192);
return DetectCore(pathToFile, buf, bufl);
View TimeOutXunit.cs
[Fact(Timeout = 50)]
public async Task FactTimeout_TimeoutLessThanProcessingTime_ThrowTestTimeoutException()
Action act = () => Task.Delay(5000);
// Trigger the timeout by attempting something that will take too long
await act;
guitarrapc / Sample.runsettings
Last active Dec 13, 2019
dotnet test RunConfiguration
View Sample.runsettings
You can’t perform that action at this time.