Skip to content

Instantly share code, notes, and snippets.

View JKamsker's full-sized avatar

Jonas Kamsker JKamsker

View GitHub Profile
@JKamsker
JKamsker / ConstructorRedirect.md
Created August 17, 2023 14:32
Constructor Redirect

Proposal: Constructor redirect

Summary: Allow for constructor arguments to be seemingly mirrored by a generic factory method.

Sample: myfactory.Create("param1", "param2", "param3");

class CommandType

@JKamsker
JKamsker / CompletionScript.ps1
Created July 30, 2023 23:20
AutoComplete Ideas
$script:process = $null
$script:path = "C:\Users\W31rd0\source\repos\work\Apro\Apro.AutoUpdater\ApGet\bin\Debug\net6.0\ApGet.exe"
$script:logPath = "C:\Users\W31rd0\Downloads\tmp\gpt\log.log"
$script:useCompletionServer = $false
function Invoke-ApGet {
# call external debugger
return & $script:path $args
}
@JKamsker
JKamsker / ApGet.ps1
Last active July 25, 2023 14:23
ApgetWebInstall
# Set the URL of the ZIP file and the target directory
$zipUrl = "https://apropatchcdn.blob.core.windows.net/patch-staging/apget/latest/apget.zip"
# https://apropatchcdn.blob.core.windows.net/patch-staging/apget/latest/apget.zip"
# https://apropatchcdn.blob.core.windows.net/patch-staging/apget/latest/apget.zip
# $targetDirectory = "$env:USERPROFILE\Tools\Apget"
$targetDirectory = Split-Path ($profile.CurrentUserAllHosts)
$targetDirectory = Join-Path $targetDirectory "Tools"
$targetDirectory = Join-Path $targetDirectory "Apget"
@JKamsker
JKamsker / DriveUtils.cs
Last active June 15, 2023 09:45
Detect If Drive is SSD - windows
using Microsoft.Win32.SafeHandles;
using System;
using System.IO;
using System.Runtime.InteropServices;
using System.Text;
// Refactored from https://emoacht.wordpress.com/2012/11/06/csharp-ssd/
public class DriveUtils
{
@JKamsker
JKamsker / RainbowSpinner.cs
Last active May 11, 2023 12:41
Spectre-RainbowSpinner
/*
Usage:
var spinner = new SpectreConsoleSpinner()
.WithRenderer(RenderableSpinner.SpinnerRenderer.Colored(Color.Rainbow));
// Checking logic
table.UpdateCell(currentRow, 0, spinner);
*/
using System;
@JKamsker
JKamsker / FormattableStringHelper.cs
Last active April 15, 2023 01:03
Code Snippets
/*
Problem: You want to inline arguments in a FormattableString.
Example:
return queryable.FromSqlInterpolated($@"
SELECT *
FROM {tableName}
WHERE dbo.compare({columnName}, {lowerString}) >= 0
AND dbo.compare({columnName}, {upperString}) <= 0
");
@JKamsker
JKamsker / StateMachine.cs
Last active March 22, 2023 22:09
dnSpySamples
using System;using System.Collections;using System.Collections.Generic;using System.Diagnostics;using System.Globalization;using System.IO;using System.Linq;using System.Linq.Expressions;using System.Net;using System.Net.Configuration;using System.Reflection;using System.Runtime.CompilerServices;using System.Runtime.InteropServices;using System.Text;using System.Text.RegularExpressions;using System.Threading;using System.Threading.Tasks;using CrawlerNGLib.models;using Microsoft.CSharp.RuntimeBinder;using Newtonsoft.Json;using NLog;using ns0;namespace CrawlerNGLib{public class HttpHandler{public HttpHandler(string serverUrl, string username, string password, string customUseragent, WebProxy webProxy){this.string_11 = serverUrl;this.string_13 = username;this.string_10 = password;this.string_12 = customUseragent ?? "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36";this.webProxy_0 = webProxy;HttpHandler.logger_0.Debug("[HttpHandler] Initialized.");Ht
@JKamsker
JKamsker / Benchmark.cs
Last active April 21, 2022 21:16
SpanWriter
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Diagnostics.Windows.Configs;
using BenchmarkDotNet.Running;
using Interop_pg;
using Interop_Pg.Extensions;
[MemoryDiagnoser]
[InliningDiagnoser(true, true)]
@JKamsker
JKamsker / AudibleTag.cs
Created January 5, 2022 01:03
My findings
public class AudibleTag
{
public string LONG_DESCRIPTION { get; set; }
/// <summary>
/// eg: Transport: Transport 1
/// </summary>
public string SHORT_TITLE { get; set; }
/// <summary>
// ==UserScript==
// @name New Userscript
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author You
// @match https://www.iboys.at/search/*
// @grant none
// ==/UserScript==