Skip to content

Instantly share code, notes, and snippets.

Avatar

Dan Rigby DanRigby

View GitHub Profile
@ninjarobot
ninjarobot / strace-netcore.md
Last active May 24, 2022
Trace .NET Core Applications on Linux with `strace`
View strace-netcore.md

Trace .NET Core Applications on Linux with strace

Troubleshooting a running application can be difficult, usually it starts around checking log output and then following through the likely code paths to get an idea of where a failure may occur. In a development environment, you might attach a debugger a step through source, but troubleshooting isn't always that convenient. There are several helpful tools that can assist, but one that gives the most comprehensive view of a running application is strace. With strace you are able to see all of the system calls an application makes to get a detailed understanding of what is going on "under the hood" in order to troubleshoot an issue.

Take a simple "hello world" F# application, the kind you get from dotnet new console -lang F# -n strace-sample". Build it with dotnet build and then launch it with strace to get a trace of all the system calls in a file called trace.log(adjusting for your build output path if on a different framework vers

@tomasaschan
tomasaschan / aks-restart-nodes.sh
Last active Jul 24, 2021
Rolling restart of all nodes in an AKS cluster
View aks-restart-nodes.sh
#!/bin/bash
set -e
resourceGroupDefault='<set your default here, to avoid having to specify in the common case>'
resourceGroup=${RESOURCE_GROUP:-$resourceGroupDefault}
clusterNameDefault='<set your default here>'
clusterName=${CLUSTER_NAME:-$clusterNameDefault}
regionDefault='<set your default here>'
region=${REGION:-$regionDefault}
@ayende
ayende / LetsEncryptClient.cs
Created Jan 11, 2018
ACME v2 client for Let's Encrypt
View LetsEncryptClient.cs
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net.Http;
using System.Security.Cryptography;
using System.Security.Cryptography.X509Certificates;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
View Update-Package-Versions.cs
void Main()
{
var writeChanges = false;
var basePath = Path.GetFullPath(Path.Combine(Path.GetDirectoryName(Util.CurrentQueryPath), @"..\.."));
UpdateVersions(basePath, writeChanges);
}
void UpdateVersions(string basePath, bool writeChanges = false)
{
View foo1.cs
while (ReferenceNameNavigator.GetByQualifier(referenceName) != null)
referenceName = ReferenceNameNavigator.GetByQualifier(referenceName);
@plaurin
plaurin / DependenciesVisualizer.linq
Last active Aug 17, 2018
LinqPad query to generate a DMGL of projects, libraries and NuGet packages dependencies
View DependenciesVisualizer.linq
<Query Kind="Program" />
private string[] projectExtensionExclusions = new[] { ".vdproj", ".ndproj", ".wdproj", ".shfbproj" };
private string rootFolder = @"C:\Users\Pascal\Dev\MyProject";
void Main()
{
LoadAllProjects();
LoadAllPackagesConfig();
GenerateDGML(Path.Combine(rootFolder, "Dependencies.dgml"));
@erichexter
erichexter / downloadBuildVideos.ps1
Created Nov 2, 2012
Download build 2012 videos
View downloadBuildVideos.ps1
[Environment]::CurrentDirectory=(Get-Location -PSProvider FileSystem).ProviderPath
$rss = (new-object net.webclient)
#Set the username for windows auth proxy
$rss.proxy.credentials=[system.net.credentialcache]::defaultnetworkcredentials
$a = ([xml]$rss.downloadstring("http://channel9.msdn.com/Events/Build/2012/RSS/wmvhigh"))
$a.rss.channel.item | foreach{
$url = New-Object System.Uri($_.enclosure.url)
$file = $_.creator + "-" + $_.title.Replace(":", "-").Replace("?", "").Replace("/", "-") + ".wmv"
if (!(test-path $file))
{
@hellerbarde
hellerbarde / latency.markdown
Created May 31, 2012 — forked from jboner/latency.txt
Latency numbers every programmer should know
View latency.markdown

Latency numbers every programmer should know

L1 cache reference ......................... 0.5 ns
Branch mispredict ............................ 5 ns
L2 cache reference ........................... 7 ns
Mutex lock/unlock ........................... 25 ns
Main memory reference ...................... 100 ns             
Compress 1K bytes with Zippy ............. 3,000 ns  =   3 µs
Send 2K bytes over 1 Gbps network ....... 20,000 ns  =  20 µs
SSD random read ........................ 150,000 ns  = 150 µs

Read 1 MB sequentially from memory ..... 250,000 ns = 250 µs

@jboner
jboner / latency.txt
Last active Aug 7, 2022
Latency Numbers Every Programmer Should Know
View latency.txt
Latency Comparison Numbers (~2012)
----------------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD
@dragan
dragan / install-nuget.sh
Created May 5, 2012 — forked from half-ogre/install-nuget.sh
A bash script to install nuget.exe and make it available in bash with a proxy script
View install-nuget.sh
#!/usr/bin/env sh
set -e
# Respect PREFIX if set, otherwise default to /usr/local
if [ -z "${PREFIX}" ]; then
PREFIX="/usr/local"
fi
# Respect TMPDIR if set, otherwise default to /tmp