Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View waf's full-sized avatar

Will Fuqua waf

View GitHub Profile
@waf
waf / RedisGetAndUncompress.ps1
Last active February 7, 2024 03:44
Get gzip/deflate-compressed content from redis in powershell
# one time setup
Install-Module PsRedis
# connect
Import-Module PsRedis
Connect-Redis -ConnectionString "my-redis-server.example.com"
# create function, given a redis key, get the bytes, ungzip/deflate them and return the string.
function Get-RedisKeyAndUncompress($key) {
# get ambient connection
@waf
waf / Debugging Tips.md
Created July 6, 2022 07:15
Debugging Tips - the following is originally from https://www.debug.coach/ which is super useful but has since gone offline.

A collection of questions and mental models the pros use when debugging

  1. What question can you ask that will eliminate half the possible answers? Ask that first.
    • Ask broad questions before asking specific ones. For example ask “have you checked the logs?” Before asking “have you checked the dev tools console log?”
  2. Have you checked the logs?
    • Application Logs
    • System Logs
    • Web Server Logs
    • Database Logs
  • Browser Dev Tools Console/Network Tabs

MSBuild

  • MSBuild is a build system.
  • Given files and commands, it tries to do the "minimal amount of work"
  • You can execute csproj files by running msbuild (from your Developer terminal)

Three main parts to a csproj

  • PropertyGroup - Defines variables
@waf
waf / Program.cs
Created August 7, 2020 02:12
Testing threadpool behavior
using System;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
namespace ThreadPoolLogger
{
class Program
{
const int ThreadChange = 40;
@waf
waf / Program.cs
Created June 25, 2020 04:53
Regex Memory Benchmarking
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Diagnostics.Windows.Configs;
using BenchmarkDotNet.Running;
using System;
using System.Linq;
using System.Text.RegularExpressions;
// Benchmark Results:
//
// BenchmarkDotNet=v0.12.1, OS=Windows 10.0.19041.329 (2004/?/20H1)
@waf
waf / Program.cs
Last active April 11, 2020 08:57
Various ways of using async/await and their end result
using System;
using System.Diagnostics;
using System.Linq;
using System.Threading.Tasks;
namespace AsyncPatterns
{
public class Program
{
public static async Task Main(string[] args)
@waf
waf / Program.cs
Created March 20, 2020 10:16
AsyncLocal Demo
using System;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
namespace AsyncLocalPlayground
{
class Program
{
//private static string ThreadId; // too wide! per AppDomain
@waf
waf / CurlyBraces.cs
Last active October 26, 2019 17:31
C# 8 port of F# brace matching
//
// C# 8 port of F# brace matching.
//
using System;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace BraceMatching
{
using ParseState = Nullable<int>; // we get to cheat a bit because the C# compiler will "map" over nullable types implicitly
@waf
waf / ConEmu-Theme.xml
Last active October 8, 2018 16:07
Dracula ConEmu Theme - matches the colors of http://github.com/waf/dracula-cmd/
<!--
Quick instructions below, see full, detailed instructions here:
https://github.com/joonro/ConEmu-Color-Themes/blob/master/README.org#how-to-install
To install this ConEmu theme, add it to C:\Users\USER\AppData\Roaming\ConEmu.xml:
...
<key name="Colors" modified="2018-10-08 22:42:53" build="180503">
<value name="Count" type="long" data="1"/>
... paste the xml tag here and increment the above count...
@waf
waf / DisableAutoInstallApps.reg
Created May 16, 2018 06:26
disable windows 10 auto-installed apps
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager]
"SilentInstalledAppsEnabled"=dword:00000000