Skip to content

Instantly share code, notes, and snippets.

@larsw
larsw / PosetEnumerableExtensions.cs
Last active November 18, 2016 18:18
PartialOrderBy extension method over IEnumerable<T>
public static class EnumerableExtensions
{
public static IEnumerable<TSource> PartialOrderBy<TSource, TKey>(this IEnumerable<TSource> source,
Func<TSource, TKey> keySelector,
IComparer<TKey> comparer)
{
var list = new List<TSource>(source);
while (list.Count > 0)
{
var minimum = default(TSource);
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<div id="main"></div>
<script src="vendor.js"></script>
<script src="bundle.js"></script>
</body>
l_events_then_should_throw [FAIL]
System.TypeInitializationException : The type initializer for 'System.Data.SqlLocalDb.Logger' threw an exception.
---- System.TypeInitializationException : The type initializer for 'System.Data.SqlLocalDb.SqlLocalDbConfig' threw
an exception.
-------- System.Runtime.Serialization.SerializationException : Type is not resolved for member 'Serilog.Context.Im
mutableStack`1[[Serilog.Core.ILogEventEnricher, Serilog, Version=1.5.0.0, Culture=neutral, PublicKeyToken=24c2f752a8e58a
10]],Serilog.FullNetFx, Version=1.5.0.0, Culture=neutral, PublicKeyToken=24c2f752a8e58a10'.
Stack Trace:
at System.Data.SqlLocalDb.SqlLocalDbApi.GetInstanceNames()
at System.Data.SqlLocalDb.SqlLocalDbProvider.GetInstances()
@larsw
larsw / Win10Dev.ps1
Last active February 7, 2016 13:35 — forked from damieng/WinDev.ps1
Make Windows 10 more developer workstation oriented
# Run this from Powershell as Administrator with (New-Object System.Net.WebClient).DownloadString("https://gist.github.com/larsw/fceb8d9b13ddd197c2aa/raw") | powershell -command -
Write-Output "Making Windows 10 more developer workstation oriented..."
Set-ExecutionPolicy Unrestricted
Write-Output "Bloatware removing..."
$apps = @(
"Microsoft.3DBuilder"
"Microsoft.Appconnector"
"Microsoft.BingFinance"
"Microsoft.BingNews"
@larsw
larsw / gist:b5a771044050faa854ac
Created January 25, 2016 12:37
bootstrap-loader problems
npm run dev
> shave@1.0.0 dev /home/larsw/shave
> webpack-dev-server --port 8080 --hot --inline
http://localhost:8080/
webpack result is served from /
content is served from /home/larsw/shave
[bootstrap-loader]: Hey, we're in DEBUG mode! Yabba dabba doo!
@larsw
larsw / gist:f435ac3c3ef26d81e320
Created November 11, 2015 10:12
Serilog.Sinks.Serilog client-side
$(function() {
var serilog = $.connection.serilogHub;
serilog.client.sendLogEvent = function(logEvent) {
console.log(logEvent);
}
});
@larsw
larsw / gist:49659bff4f6e9a5da5f3
Created October 9, 2015 07:48 — forked from tjrobinson/gist:0ad6c790e90d7a385eb1
ActiveDirectoryUserService.cs
using System;
using System.Collections.Generic;
using System.DirectoryServices.AccountManagement;
using System.Linq;
using System.Security.Claims;
using System.Threading.Tasks;
using Thinktecture.IdentityServer.Core;
using Thinktecture.IdentityServer.Core.Models;
using Thinktecture.IdentityServer.Core.Services;
@larsw
larsw / WorksOnWin10.cs
Last active April 26, 2018 11:22
Stuff that stopped working in Win10 but works in Win7/Win8.1. Running on NET 4.6 on both Win7/8.1 and Win10.
// reference xunit
// reference BouncyCastle
// reference Security.Cryptography.dll (CLR Security project @ Codeplex)
public static byte[] ConvertToNCryptEccPrivateBlob(BigInteger d, ECPoint q)
{
// from bcrypt.h: #define BCRYPT_ECDSA_PRIVATE_P384_MAGIC 0x34534345 // ECS4
var magic = new byte[] { 0x45, 0x43, 0x53, 0x34 };
var len = new byte[] { 0x30, 0, 0, 0 }; // key length - 384 bit / 8
@larsw
larsw / boom.fsx
Last active August 26, 2015 08:10
Unexpected sequence of output on Linux/F# 3.1/Mono 3.12.0 (expected "foo" to be output after the numerical sequence)
let seqGen a b =
seq {
yield! seq { a .. b }
raise (System.UnauthorizedAccessException("foo"))
}
try
seqGen 1 10
|> Seq.iter (fun x -> printf "%A " x)
with
@larsw
larsw / -
Created August 25, 2015 08:59
System.UnauthorizedAccessException: Access to the path "/home/larsw/.cache/dconf" is denied.
at System.IO.Directory+<EnumerateKind>c__Iterator0.MoveNext () [0x00000] in <filename unknown>:0
at FSI_0001.Kodekamp+getFiles@22.GenerateNext (IEnumerable`1& next) [0x00000] in <filename unknown>:0
at Microsoft.FSharp.Core.CompilerServices.GeneratedSequenceBase`1[System.String].MoveNextImpl () [0x00000] in <filename unknown>:0
at Microsoft.FSharp.Core.CompilerServices.GeneratedSequenceBase`1[System.String].System-Collections-IEnumerator-MoveNext () [0x00000] in <filename unknown>:0
at FSI_0001.Kodekamp+getFiles@22.GenerateNext (IEnumerable`1& next) [0x00000] in <filename unknown>:0
at Microsoft.FSharp.Core.CompilerServices.GeneratedSequenceBase`1[System.String].MoveNextImpl () [0x00000] in <filename unknown>:0
at Microsoft.FSharp.Core.CompilerServices.GeneratedSequenceBase`1[System.String].System-Collections-IEnumerator-MoveNext () [0x00000] in <filename unknown>:0
at FSI_0001.Kodekamp+getFiles