Skip to content

Instantly share code, notes, and snippets.

@davidfowl
davidfowl / TimeHttpEvents.cs
Last active August 7, 2024 01:57
Using Yarp.Telemetry.Consumption to track outbound network events (this package isn't tied to YARP)
using System.Diagnostics;
using System.Net.Sockets;
using System.Security.Authentication;
using Yarp.Telemetry.Consumption;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddTelemetryConsumer<TelemetryConsumer>();
var app = builder.Build();
@georgiyordanov
georgiyordanov / pam-tid-sudo.sh
Created January 23, 2023 17:03 — forked from steigr/pam-tid-sudo.sh
Enable TouchID-support with sudo
#!/usr/bin/env bash
sudo sed -i '' -e '/^#/a\'$'\n''auth sufficient pam_tid.so' /etc/pam.d/sudo
@georgiyordanov
georgiyordanov / search_query_plan_cache.sql
Created February 10, 2020 13:10
Search the SQL Server query plan cache
SELECT
databases.name,
dm_exec_sql_text.text AS TSQL_Text,
dm_exec_query_stats.creation_time,
dm_exec_query_stats.execution_count,
dm_exec_query_stats.total_worker_time AS total_cpu_time,
dm_exec_query_stats.total_elapsed_time,
dm_exec_query_stats.total_logical_reads,
dm_exec_query_stats.total_physical_reads,
dm_exec_query_plan.query_plan
@milesgratz
milesgratz / Update-machine-certificate-private-key-permissions.ps1
Created May 31, 2019 17:40
PowerShell example of updating machine certificate private key permissions (CAPI vs CNG)
# Get cert on local computer by thumbprint
$thumbprint = '89D3FC64B6405E161EDC7A4CF14E111F5F6895AA'
$Cert = Get-ChildItem Cert:\LocalMachine\My | Where-Object { $_.Thumbprint -eq $thumbprint }
###################################################
# Manage private key of CAPI cert
###################################################
# Find private key
$privKey = $Cert.PrivateKey.CspKeyContainerInfo.UniqueKeyContainerName
@rbrayb
rbrayb / CNGRSA.cs
Created July 26, 2018 01:13
C# CNG library
using System;
using System.Security.Cryptography;
namespace CNGMediumConsoleApp
{
class Program
{
static byte[] data = {0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20};
static byte[] privateKey;
@jhorsman
jhorsman / Cisco_Anyconnect.ps1
Created January 6, 2015 10:11
PowerShell to automate VPN connection with Cisco AnyConnect Secure Mobility Client
#Source www.cze.cz
#This script is tested with "Cisco AnyConnect Secure Mobility Client version 3.1.00495"
# Usage: & '.\Cisco_Anyconnect.ps1' [-Server <server name or ip>] [-Group <group>] [-User <user>] [-Password <password>]
#Please change following variables
#IP address or host name of cisco vpn, Username, Group and Password as parameters
param (
[string]$Server = $( Read-Host "Input server, please" ),
@millermedeiros
millermedeiros / osx_setup.md
Last active November 14, 2024 03:45
Mac OS X setup

Setup Mac OS X

I've done the same process every couple years since 2013 (Mountain Lion, Mavericks, High Sierra, Catalina) and I updated the Gist each time I've done it.

I kinda regret for not using something like Boxen (or anything similar) to automate the process, but TBH I only actually needed to these steps once every couple years...

@AArnott
AArnott / ApmExtensions.cs
Last active May 1, 2020 21:40
Converts .NET TPL async task pattern to the APM pattern. See [Stephen Toub's blog post](http://blogs.msdn.com/b/pfxteam/archive/2011/06/27/10179452.aspx)
// LICENSED under the Ms-PL (http://opensource.org/licenses/MS-PL)
public static Task<TResult> ToApm<TResult>(this Task<TResult> task, AsyncCallback callback, object state) {
if (task == null) {
throw new ArgumentNullException("task");
}
if (task.AsyncState == state) {
if (callback != null) {
task.ContinueWith(
@jammycakes
jammycakes / LazyDisposable.cs
Last active December 26, 2022 22:31
A subclass of System.Lazy<T> that implements IDisposable and forwards calls to the Dispose method on to the lazily created instance if it exists.
/// <summary>
/// A <see cref="Lazy"/> object that implements <see cref="IDisposable"/>.
/// </summary>
/// <typeparam name="T">
/// The object being lazily created.
/// </typeparam>
public class LazyDisposable<T> : Lazy<T>, IDisposable where T: IDisposable
{
/// <summary>
@digitaljhelms
digitaljhelms / gist:4287848
Last active November 16, 2024 01:10
Git/GitHub branching standards & conventions

Branching

Quick Legend

Description, Instructions, Notes
Instance Branch