Skip to content

Instantly share code, notes, and snippets.

Avatar

Andreas Gullberg Larsen angularsen

View GitHub Profile
View NamespaceGuid.cs
// 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>
View gist:bc6fc0d76d8eb3514c19430592aa9c65
### 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 Apr 10, 2019
A neverending gist about developer tips, because blogs are lame
View dev_tips.md

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 Jan 18, 2020 — 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.
View AsmdefDebug.cs
#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 Jan 6, 2020
Git dotfiles for Unity 3D
View .gitattributes
# Disable EOL conversions by default
* -text
## Unity ##
*.cs diff=csharp text
*.cginc text
*.shader text
*.mat merge=unityyamlmerge
@angularsen
angularsen / unitsnet-equations.linq
Created Jan 20, 2017
LINQpad example for dynamically converting source quantity strings to other units
View unitsnet-equations.linq
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 Dec 17, 2016
Helper class for converting property expression x => x.Foo.Bar to property path string "Foo.Bar"
View PropertyPath.cs
/// <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)
{
@angularsen
angularsen / Application_Start.cs
Last active Nov 5, 2019
CreateOrMigrateDatabase()
View Application_Start.cs
// Call me on startup, such as in Application_Start() of Global.asax.cs
private static void CreateOrMigrateDatabase()
{
// Disable automatic migrations as it prevents us from deploying DB changes without breaking the production web instance.
Database.SetInitializer<ApplicationDbContext>(null);
var migrator = new DbMigrator(new Configuration());
// Order by migration names to get oldest first, such as 201403221133523_AddSetting
List<string> pendingMigrations = migrator.GetPendingMigrations().OrderBy(x => x).ToList();
@angularsen
angularsen / nuget log
Created Apr 9, 2016
Loggur.Uwp: Failed to add nuget Microsoft.AspNetCore.Hosting-rc3-20533
View nuget log
Restoring packages for 'Loggur.Uwp'.
Restoring packages for C:\Repos\Loggur\Loggur.Uwp\project.json...
Version conflict detected for System.Collections.
Loggur.Uwp (>= 1.0.0) -> Microsoft.AspNetCore.Hosting (>= 1.0.0-rc3-20533) -> Microsoft.AspNetCore.Http.Extensions (>= 1.0.0-rc3-20533) -> Microsoft.AspNetCore.Http.Abstractions (>= 1.0.0-rc3-20533) -> System.Reflection.TypeExtensions (>= 4.1.0-rc2-23931) -> System.Linq (>= 4.1.0-rc2-23931) -> System.Collections (>= 4.0.11-rc2-23931)
Loggur.Uwp (>= 1.0.0) -> Microsoft.NETCore.UniversalWindowsPlatform (>= 5.0.0) -> Microsoft.NETCore.Runtime (>= 1.0.0) -> Microsoft.NETCore.Runtime.CoreCLR-x64 (>= 1.0.0) -> System.Collections (= 4.0.10).
System.Console 4.0.0-rc2-23931 provides a compile-time reference assembly for System.Console on UAP,Version=v10.0, but there is no run-time assembly compatible with win10-x64.
System.Reflection.Extensions 4.0.1-rc2-23931 provides a compile-time reference assembly for System.Reflection.Extensions on UAP,Version=v10.0, but the
@angularsen
angularsen / NameValueCollectionExtensions.cs
Created Mar 19, 2016
Get web/app.config setting and expand environment variables when developing locally
View NameValueCollectionExtensions.cs
using System;
using System.Collections.Specialized;
using JetBrains.Annotations;
namespace MyExtensions
{
public static class NameValueCollectionExtensions
{
[CanBeNull]
public static string GetWithEnv([NotNull] this NameValueCollection nvc, [NotNull] string name)