Skip to content

Instantly share code, notes, and snippets.

Cédric Luthi 0xced

Block or report user

Report or block 0xced

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
0xced / DisplayException.cs
Created May 1, 2019
Display exceptions with a TaskDialog or a MessageBox
View DisplayException.cs
// For setting up unhandled exceptions handlers:
// Using Ookii.Dialogs:
static void DisplayException(Exception exception)
var baseException = exception.GetBaseException();
var title = @"Error: " + baseException.GetType().Name;
var message = baseException.Message;
if (TaskDialog.OSSupportsTaskDialogs)
using (var dialog = new TaskDialog())
0xced / Working without a
Created Mar 7, 2019
Working without a nib blog posts by Jeff Johnson (@lapcatsoftware)
View Working without a
  • [Working without a nib, Part 1][1]
  • [Working without a nib, Part 2: Also Also Wik][2]
  • [Working without a nib, Part 5: No, 3!][3]
  • [Working without a nib, Part 4: setAppleMenu][4]
  • [Working without a nib, Part 5: Open Recent menu][5]
  • [Working without a nib, Part 6: Working without a xib][6]
  • [Working without a nib, Part 7: The empire strikes back][7]
  • [Working without a nib, Part 8: The nib awakens][8]
  • [Working without a nib, Part 9: Shipping without a nib][9]
  • [Working without a nib, Part 10: Mac Main Menu][10]
0xced / NativeSQLiteWithCostura.csproj
Created Feb 27, 2019
Embed native e_sqlite3.dll with Costura without having to manually copy any dll
View NativeSQLiteWithCostura.csproj
<!-- Useful when bundling an app using Microsoft.EntityFrameworkCore.Sqlite, which depends on SQLitePCLRaw.bundle_green, which depends on SQLitePCLRaw.lib.e_sqlite3.v110_xp (having native Windows dlls) -->
<EmbeddedResource Include="$(NugetPackageRoot)\sqlitepclraw.lib.e_sqlite3.v110_xp\1.1.13\runtimes\win-x86\native\e_sqlite3.dll">
<EmbeddedResource Include="$(NugetPackageRoot)\sqlitepclraw.lib.e_sqlite3.v110_xp\1.1.13\runtimes\win-x64\native\e_sqlite3.dll">
0xced / StringTrimmerInterceptor.cs
Created Nov 13, 2018
Entity Framework interceptor to trim strings (remove leading and trailing spaces) before saving to database
View StringTrimmerInterceptor.cs
using System.Data.Entity;
using System.Data.Entity.Core.Common.CommandTrees;
using System.Data.Entity.Core.Common.CommandTrees.ExpressionBuilder;
using System.Data.Entity.Core.Metadata.Edm;
using System.Data.Entity.Infrastructure.Interception;
using System.Linq;
namespace gist
/// Adapted from
0xced / DbContextExtensions.cs
Created Oct 2, 2018
Get invariant provider name from DbContext
View DbContextExtensions.cs
using System.Data.Entity;
using System.Reflection;
namespace gist
public static class DbContextExtensions
public static string GetProviderName(this DbContext context)
var internalContextProperty = context.GetType().GetProperty("InternalContext", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
0xced / WindowsAuthorizationMiddleware.cs
Last active Oct 3, 2018
OWIN Middleware for authenticating + authorizing windows accounts (users or groups)
View WindowsAuthorizationMiddleware.cs
using System.Collections.Generic;
using System.Linq;
using System.Security.Principal;
using System.Threading.Tasks;
using Microsoft.Owin;
// ReSharper disable once CheckNamespace
namespace Owin
public static class WindowsAuthorizationAppBuilderExtensions
0xced /
Created Jun 20, 2018
Workarounds for using System.Data.SQLite and Microsoft.Azure.Management.ServiceBus on Mono
#!/bin/bash -e -x
# For System.Data.SQLite to work on Mono, see
function Install_libSQLiteInterop
pushd ~/Downloads
if [ ! -f "${SQLITE_DYLIB}" ]; then
0xced / ForEachAsync.cs
Created May 26, 2018
Parallel foreach async enumeration with maximum degree of parallelism
View ForEachAsync.cs
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace Parallel
public static class EnumerableExtensions
0xced / DbEntityValidationException.cs
Last active Jun 8, 2018
Improved DbEntityValidationException message
View DbEntityValidationException.cs
public partial class MyContext
// Adapted from
public override Task<int> SaveChangesAsync()
return base.SaveChangesAsync();
catch (DbEntityValidationException exception)
0xced /
Created Jan 25, 2018
Generate constants from storyboard identifiers
#!/usr/bin/env python
# Adapted from (
# * Support for accessibility identifiers and accessibility labels
# * Easily extendable with xpath definitions
# * Valid identifiers
# * Namespaced constants, idea from
SPACING = '\t'
You can’t perform that action at this time.