Skip to content

Instantly share code, notes, and snippets.

View angularsen's full-sized avatar

Andreas Gullberg Larsen angularsen

View GitHub Profile
@angularsen
angularsen / IPAddressExtensions.cs
Last active November 13, 2023 11:44
IsPrivate extension method for IPAddress
using System;
using System.Net;
using System.Net.Sockets;
namespace MyNamespace
{
/// <summary>
/// Extension methods on <see cref="System.Net.IPAddress"/>.
/// </summary>
public static class IPAddressExtensions
@angularsen
angularsen / TypeMemberLayout.xaml
Last active December 9, 2021 08:46 — forked from collinbarrett/TypeMemberLayout.xaml
Rider/ReSharper File Layout for StyleCop.Analyzers with alphabetical order
<?xml version="1.0" encoding="utf-16"?>
<!--
Inspired by: https://collinmbarrett.com/stylecop-ordering-resharper/
Source: https://gist.github.com/angularsen/98bfab4d5e887ab37143214fad1fadbd
Modifications:
- Sort by Name after all other sorting criteria
-->
<Patterns xmlns="urn:schemas-jetbrains-com:member-reordering-patterns">
<TypePattern DisplayName="StyleCop Classes, Interfaces, &amp; Structs" RemoveRegions="All">
<TypePattern.Match>
@angularsen
angularsen / SimpleRequestTelemetryNameActionFilter.cs
Created November 20, 2021 19:11
Simple request telemetry names
#nullable enable
using System;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Filters;
namespace Digma.Api.Common.Telemetry
{
/// <summary>
/// Action filter to construct a simpler telemetry name from the route name or the route template.
@angularsen
angularsen / NamespaceGuid.cs
Created November 24, 2020 08:56
NamespaceGuid
// Original source: https://github.com/Faithlife/FaithlifeUtility/blob/master/src/Faithlife.Utility/GuidUtility.cs
using System;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
namespace Faithlife.Utility
{
/// <summary>
### Keybase proof
I hereby claim:
* I am angularsen on github.
* I am angularsen (https://keybase.io/angularsen) on keybase.
* I have a public key ASBk63TsyBng27LKfVncxiMbyB326LmFLu2_IjffuoOFDAo
To claim this, I am signing this object:
@angularsen
angularsen / dev_tips.md
Last active April 10, 2019 07:32
A neverending gist about developer tips, because blogs are lame

Browsers

Network: Show only page navigations including redirects

Using the Doc filter in Chrome seems to merge entries during redirects, losing info. Instead, use the Filter input.

  • Chrome: mime-type: text/html
  • FireFox: cause: document
@angularsen
angularsen / AsmdefDebug.cs
Last active November 16, 2023 13:24 — forked from karljj1/Unity Assembly Definition Debugger.cs
Find out what assemblies are being built and how long each takes. Updated to only build for Editor, and to include total time in first line of log output.
#if UNITY_EDITOR
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Text;
using UnityEditor;
using UnityEditor.Compilation;
using UnityEngine;
/// <summary>
@angularsen
angularsen / .gitattributes
Last active January 6, 2020 12:31
Git dotfiles for Unity 3D
# Disable EOL conversions by default
* -text
## Unity ##
*.cs diff=csharp text
*.cginc text
*.shader text
*.mat merge=unityyamlmerge
@angularsen
angularsen / unitsnet-equations.linq
Created January 20, 2017 21:42
LINQpad example for dynamically converting source quantity strings to other units
void Main()
{
ElectricCurrent sourceQuantity = ElectricCurrent.Parse("8A");
ElectricCurrentUnit milliAmpsUnit = ElectricCurrent.ParseUnit("mA");
// 8000
double milliAmps = sourceQuantity.As(milliAmpsUnit);
// 8,000 mA (current culture, happens to be US English on my Windows)
Console.WriteLine(sourceQuantity.ToString(milliAmpsUnit));
@angularsen
angularsen / PropertyPath.cs
Last active December 17, 2016 11:40
Helper class for converting property expression x => x.Foo.Bar to property path string "Foo.Bar"
/// <remarks>Inspired by: http://stackoverflow.com/a/22135756/134761 </remarks>
public static class PropertyPath<TSource>
{
public static string GetString(Expression<Func<TSource, object>> expression, string separator = ".")
{
return string.Join(separator, GetPropertyPathSegments(expression));
}
public static IReadOnlyList<string> GetPropertyPathSegments(Expression<Func<TSource, object>> expression)
{