Skip to content

Instantly share code, notes, and snippets.

View fubar-coder's full-sized avatar

Mark Junker fubar-coder

View GitHub Profile

By Alex Siepman

Converted to Markdown from http://www.siepman.nl/blog/post/2013/10/28/ID-Sequential-Guid-COMB-Vs-Int-Identity-using-Entity-Framework.aspx

Introduction

Recently i had to choose a type for an Id in a SQL server Database. We are using Entity framework to access the database. I had to choose between Guid an Int. I seems to me that Guid must be a slow solution but in a real world scenario, this was not true (see results later in this blog). First an (optional) small introduction about some terms used here. Then the testresult, folowwing by the C# implementation of a third option, called Sequential Guid.

using Your.CustomFluentMigratorClasses;
namespace Microsoft.Extensions.DependencyInjection
{
public static class ServiceCollectionExtensions
{
public static IServiceCollection AddCustomFluentMigratorSqliteGenerator(
this IServiceCollection services)
{
return services.AddScoped<CustomSqliteGenerator>()
@fubar-coder
fubar-coder / ping6.strace
Created April 29, 2019 15:05
strace for a failing ping6 in WSL
3910 execve("/bin/ping6", ["ping6", "-vvv", "google.de"], 0x7fffe51284d8 /* 14 vars */) = 0
3910 access("/etc/suid-debug", F_OK) = -1 ENOENT (No such file or directory)
3910 brk(NULL) = 0x7fffd485e000
3910 fcntl(0, F_GETFD) = 0
3910 fcntl(1, F_GETFD) = 0
3910 fcntl(2, F_GETFD) = 0
3910 access("/etc/suid-debug", F_OK) = -1 ENOENT (No such file or directory)
3910 access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
3910 access("/etc/ld.so.preload", R_OK) = -1 ENOENT (No such file or directory)
3910 openat(AT_FDCWD, "/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
@fubar-coder
fubar-coder / CreateFromUnitVector.cs
Created January 10, 2019 17:05
Create Quaternion from two unit vectors for rotation
using System.Numerics;
static class Rotation
{
private static Quaternion CreateFromUnitVectors(Vector3 from, Vector3 to)
{
Vector3 v1;
var r = Vector3.Dot(from, to) + 1;
if (r < 0.000001f)
{
@fubar-coder
fubar-coder / plans-3.0.txt
Created April 16, 2018 06:12
Fluent Migrator 3.0 Plans
FluentMigrator 3.0.0 Plan
1. Replacing net40/net45 with net461
2. Switching to dependency injection
3. Options/Configuration
4. Logging
5. async/await
6. System.ComponentModel validation (if applicable)
@fubar-coder
fubar-coder / pam-error.strace
Created March 7, 2018 00:03
pam strace error
This file has been truncated, but you can view the full file.
1650 execve("/usr/bin/dotnet", ["dotnet", "PamTests.dll", "-d", "default", "username", "password"], [/* 16 vars */]) = 0
1650 brk(NULL) = 0x18fc000
1650 access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
1650 access("/etc/ld.so.preload", R_OK) = -1 ENOENT (No such file or directory)
1650 open("/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
1650 fstat(3, {st_mode=S_IFREG|0644, st_size=47959, ...}) = 0
1650 mmap(NULL, 47959, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7fc56f21c000
1650 close(3) = 0
1650 access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
1650 open("/lib/x86_64-linux-gnu/libdl.so.2", O_RDONLY|O_CLOEXEC) = 3

Keybase proof

I hereby claim:

  • I am fubar-coder on github.
  • I am fubarcoder (https://keybase.io/fubarcoder) on keybase.
  • I have a public key ASDPDyv1Q2SB_navNG9GLnwdlVAclY1JPQiseOo0Pv-vxwo

To claim this, I am signing this object:

@fubar-coder
fubar-coder / NonNullableReferenceTypes.md
Last active May 5, 2017 15:08
Random ideas around non-nullable reference types for the C# and the .NET CLR/JIT

NNRT = Non-Nullable Reference Type

  1. Using attributes

    • Feature set similar to what ReSharper delivers today
    • Can attributes be added to generic type arguments?
    • Compatible with the .NET Framework
    • Compatible with languages not supporting NNRTs
    • High overhead because every public function must check if the passed function argument might be null
@fubar-coder
fubar-coder / App.config
Created April 19, 2016 19:28
Modifications to allow PASV to use predefined ports (by Guillaume Pelletier)
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
<system.diagnostics>
<trace autoflush="true"/>
<sources>
<source name="System.Net" maxdatasize="1024">
<listeners>
@fubar-coder
fubar-coder / JsonDeserializerOptional{TError}.cs
Last active December 7, 2015 07:50
Deserialize error object for RestSharp.Portable
public class JsonDeserializerOptional<TError> : IDeserializer
{
/// <summary>
/// Deserialize the response
/// </summary>
/// <typeparam name="T">Object type to deserialize the result to</typeparam>
/// <param name="response">The response to deserialize the result from</param>
/// <returns>The deserialized object</returns>
public T Deserialize<T>(IRestResponse response)
{