Skip to content

Instantly share code, notes, and snippets.

View Tyrrrz's full-sized avatar
🇺🇦
Fuck russia 🖕

Oleksii Holub Tyrrrz

🇺🇦
Fuck russia 🖕
View GitHub Profile
@Tyrrrz
Tyrrrz / Benchmark results.md
Last active December 13, 2021 18:00
Global cache in C#

// * Summary *

BenchmarkDotNet=v0.13.1, OS=Windows 10.0.19043.1348 (21H1/May2021Update) 11th Gen Intel Core i5-11600K 3.90GHz, 1 CPU, 12 logical and 6 physical cores .NET SDK=6.0.100 [Host] : .NET 6.0.0 (6.0.21.52210), X64 RyuJIT DefaultJob : .NET 6.0.0 (6.0.21.52210), X64 RyuJIT

| Method | Mean | Error | StdDev | Ratio | RatioSD | Allocated |

@Tyrrrz
Tyrrrz / Examples.md
Created September 22, 2021 21:42
CliWrap examples for JetBrains OSS Power-ups webinar

Basic execution

await Cli.Wrap("docker")
    .WithArguments("run --detach -e POSTGRES_PASSWORD=password postgres")
    .ExecuteAsync();
  • Show contents of command result
  • Show how to get process ID
@Tyrrrz
Tyrrrz / like-all-tweets.js
Last active August 29, 2022 21:25
Useful browser scripts
// Likes all tweets on the screen
// Copy the lines below and add them as a bookmark
javascript: (() => {
const processedTweetIds = new Set();
const parseTweet = (el) => {
const id = [...el.querySelectorAll("a[href]")]
.map((a) => a.href)
.find((href) => href.includes("/status/"))
.split("/")
@Tyrrrz
Tyrrrz / Start-ChromeTempProfile.ps1
Created September 26, 2022 20:44
Start Google Chrome with a disposable profile
$profileDirPath = New-TemporaryFile | %{ Remove-Item $_; New-Item -ItemType Directory $_ }
Start-Process "c:/Program Files/Google/Chrome/Application/chrome" -ArgumentList "--user-data-dir=$profileDirPath" -Wait
Remove-Item $profileDirPath -Recurse -Force
@Tyrrrz
Tyrrrz / ColorTemperatureToRgbMultipliers.cs
Created May 13, 2023 16:17
Color temperature to RGB multipliers
// Algorithm taken from http://tannerhelland.com/4435/convert-temperature-rgb-algorithm-code
private static double GetRed(double temperature)
{
if (temperature > 6600)
{
return Math.Clamp(
Math.Pow(temperature / 100 - 60, -0.1332047592) * 329.698727446 / 255,
0, 1
);
@Tyrrrz
Tyrrrz / ResizableSemaphore.cs
Created May 18, 2023 23:17
Implementation of a semaphore that can be dynamically resized
internal partial class ResizableSemaphore : IDisposable
{
private readonly object _lock = new();
private readonly Queue<TaskCompletionSource> _waiters = new();
private readonly CancellationTokenSource _cts = new();
private bool _isDisposed;
private int _maxCount = int.MaxValue;
private int _count;
@Tyrrrz
Tyrrrz / Remove-Forks.ps1
Created May 26, 2023 12:00
GitHub CLI script to delete all forks
gh auth login --web
$owner = "" # leave empty for current user
$repos = gh repo list $owner --fork --json nameWithOwner | ConvertFrom-Json
foreach ($repo in $repos) {
$repoName = $repo.nameWithOwner
Write-Host "Deleting repository: $repoName..."
Read-Host -Prompt "Press ENTER to confirm..."
@Tyrrrz
Tyrrrz / Remove-Issues.ps1
Created June 22, 2023 18:07
GitHub CLI script to delete all issues by a user
gh auth login --web
$repo = "" # set repo here
$author = "" # set author here
$issues = gh issue list --repo $repo --author $author --limit 1000 --json number,author,title | ConvertFrom-Json
foreach ($issue in $issues) {
$issueNumber = $issue.number
$issueAuthor = $issue.author.login
@Tyrrrz
Tyrrrz / WindowsFreshStart.md
Last active November 3, 2023 22:06
Windows Fresh Start