Skip to content

Instantly share code, notes, and snippets.

View NickCraver's full-sized avatar
:shipit:
Shipping

Nick Craver NickCraver

:shipit:
Shipping
View GitHub Profile
@NickCraver
NickCraver / TimingExample.ps1
Last active July 14, 2024 21:00
Quick example of how to use script blocks to track timing in an easy-to-wrap way in PowerShell for things like stages of a build
# Track build time components below
$steps = [System.Collections.Generic.List[PSObject]]@()
function TrackTime {
Param(
[string]$name,
[scriptblock]$script
)
Write-Host ""
Write-Host -ForegroundColor Blue "[$(([DateTime](Get-Date)).ToString("u"))] Step: $name"
@NickCraver
NickCraver / Program.cs
Created May 15, 2022 21:13
MSBuild Dupe WriteChecker
// Inspired by https://github.com/dotnet/roslyn/blob/main/src/Tools/BuildBoss/StructuredLoggerCheckerUtil.cs#L33
// Licensed to the .NET Foundation under one or more agreements.
using System;
using Microsoft.Build.Logging.StructuredLogger;
// Invokes the analyzer here:
// https://github.com/KirillOsenkov/MSBuildStructuredLog/blob/master/src/StructuredLogger/Analyzers/DoubleWritesAnalyzer.cs
string _logFilePath = System.IO.Path.GetFullPath(args[0]);
Console.WriteLine($"Running MSBuild binlog checks for '{_logFilePath}'");
@NickCraver
NickCraver / RedisExampleListBlocking.linq
Created February 3, 2022 19:49
Redis Blocking BRPOP example
<Query Kind="Program">
<NuGetReference>StackExchange.Redis</NuGetReference>
<Namespace>StackExchange.Redis</Namespace>
<Namespace>System.Threading.Tasks</Namespace>
</Query>
private static RedisKey WorkToDoList = "work-to-do-list";
private static RedisChannel WorkToDoChannel = "work-to-do";
// List-backed, blocker example
@NickCraver
NickCraver / Microsoft.PowerShell_profile.ps1
Last active August 9, 2024 02:26
Craver's oh-my-posh profile
# This goes in your Microsoft.PowerShell_profile.ps1 (can find the path via $PROFILE in your prompt)
Import-Module -Name posh-git,oh-my-posh,Terminal-Icons
Set-PoshPrompt -Theme craver
@NickCraver
NickCraver / Legion7AspNetCoreTimings.md
Created September 2, 2021 03:08
Legion 7 dotnet/aspnetcore build timings

Machine info

Lenovo Legion 7 AMD 5900HX (8C/16T) 32 GB RAM 2TB NVMe

Repo info

git rev-parse HEAD 916e008178a1dc2c9f33475437e2ebf257cd7cd6

@NickCraver
NickCraver / Metrics.cs
Last active October 29, 2023 00:48
MetricsPrototyping
using System.Collections.Concurrent;
using System.Collections.Immutable;
using System.Collections.Generic;
using System.Net;
using System.Threading;
using System;
namespace MetricsPrototype
{
public class Example
@NickCraver
NickCraver / github-honesty.user.css
Created December 16, 2019 22:53
Label fun for GitHub!
.timeline-comment-label[aria-label*="previously committed"] {
display: inline-block;
text-indent: -9999px;
line-height: 0;
}
.timeline-comment-label[aria-label*="previously committed"]::after {
background: none !important;
color: inherit;
content: "Co-conspirator";
display: block;
@NickCraver
NickCraver / dashboard-5c5ee7780849a005a92cb1a6.json
Created September 7, 2019 13:24
UniFi Dashboard - Overview
gi{"name":"Overview","desc":"System Overview","controller_version":"5.10.12","modules":[{"id":"default:mega|status","module_id":"mega|status","restrictions":{"removable":false,"draggable":false},"config":{}},{"module_id":"internet-connection","config":{},"id":"dd5f7461-f8f0-4017-859c-3d9271b673bf"},{"module_id":"summary|wifi","config":{},"id":"13a78652-ad84-4fcb-943a-86929c638353"},{"module_id":"clients|freq-distribution","config":{"palette":"BLUE_GRADIENT_10"},"id":"c9626f4f-021f-4d46-b22d-86007570bac7"},{"module_id":"clients|top5|active","config":{"trafficType":"total"},"id":"36a9e071-132e-4b4a-baee-250449a6d44f"},{"module_id":"devices|uap|top5|channel-util","config":{"trafficType":"total"},"id":"9803f077-b9cd-4db0-b466-60d92fae2020"},{"module_id":"devices|uap|top5|active","config":{"trafficType":"total"},"id":"e6133049-cc56-44b3-a4c2-b0843912dac5"},{"module_id":"devices|uap|top5|client-count","config":{},"id":"d39f9c80-1827-4ba0-b573-3209789c56b5"},{"module_id":"summary|switching","config":{},"id":"5966437
@NickCraver
NickCraver / TopCPUUsers.sql
Created April 24, 2019 14:52
SQL: Top CPU Users query
SELECT AvgCPU, AvgDuration, AvgReads, AvgCPUPerMinute,
TotalCPU, TotalDuration, TotalReads,
PercentCPU, PercentDuration, PercentReads, PercentExecutions,
ExecutionCount,
ExecutionsPerMinute,
PlanCreationTime, LastExecutionTime,
SUBSTRING(st.text,
(StatementStartOffset / 2) + 1,
((CASE StatementEndOffset
WHEN -1 THEN DATALENGTH(st.text)
@NickCraver
NickCraver / Overview.json
Created March 12, 2019 01:47
Craver's UniFi dashboard layout
{"name":"Overview","desc":"System Overview","controller_version":"5.10.12","modules":[{"id":"default:mega|status","module_id":"mega|status","restrictions":{"removable":false,"draggable":false},"config":{}},{"module_id":"summary|wifi","config":{},"id":"13a78652-ad84-4fcb-943a-86929c638353"},{"module_id":"clients|freq-distribution","config":{"palette":"BLUE_GRADIENT_10"},"id":"c9626f4f-021f-4d46-b22d-86007570bac7"},{"module_id":"clients|top5|active","config":{"trafficType":"total"},"id":"36a9e071-132e-4b4a-baee-250449a6d44f"},{"module_id":"devices|uap|top5|channel-util","config":{"trafficType":"total"},"id":"9803f077-b9cd-4db0-b466-60d92fae2020"},{"module_id":"devices|uap|top5|active","config":{"trafficType":"total"},"id":"e6133049-cc56-44b3-a4c2-b0843912dac5"},{"module_id":"devices|uap|top5|client-count","config":{},"id":"d39f9c80-1827-4ba0-b573-3209789c56b5"},{"module_id":"summary|switching","config":{},"id":"5966437b-54f7-43e6-9c03-2adbdeb3c0a6"},{"module_id":"devices|usw|top5|active","config":{},"id":"c83ac