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
0xced / NuGet with native dynamic libraries.txt
Created Oct 17, 2019
NuGet with native dynamic libraries [dylib] [dll] [so]
View NuGet with native dynamic libraries.txt
https://stackoverflow.com/questions/38728583/how-to-create-nuget-package-for-native-c/57616597#57616597
--> https://digitalhouseblog.wordpress.com/2019/08/22/how-to-make-a-nuget-package-for-c/
https://dev.to/jeikabu/loading-native-libraries-in-c-fh6
--> https://docs.microsoft.com/en-us/windows/win32/dlls/dynamic-link-library-search-order
--> https://rendered-obsolete.github.io/2018/08/15/nupkg-with-native.html (broken link on dev.to)
--> https://natemcmaster.com/blog/2018/07/25/netcore-plugins/
https://stackoverflow.com/questions/49270527/can-you-dynamically-load-cross-platform-native-unmanaged-dlls-libs-in-net-core/52286519#52286519
@0xced
0xced / Yak Shaving.md
Last active Sep 24, 2019
Diagnosing issues when building Nerdle.AutoConfig on Travis CI
View Yak Shaving.md

I'm submitting a [pull request][17] to Nerdle.AutoConfig and [Build #103][1] fails with this error:

Installing Mono
E: Unable to locate package referenceassemblies-pcl
The command "sudo apt-get install -qq mono-complete mono-vbnc fsharp nuget referenceassemblies-pcl" failed and exited with 100 during .

Your build has been stopped.
@0xced
0xced / netcore single exe.md
Last active Sep 18, 2019
Building a .NET Core single exe for Linux on macOS or Windows
View netcore single exe.md

Building a .NET Core single exe for Linux on macOS or Windows

Run the .NET Core SDK docker image and share your working directory containing your .csproj file at /home in the container.

On Linux/macOS:

docker run --interactive --tty --rm --volume "$(pwd):/home" mcr.microsoft.com/dotnet/core/sdk:2.2 /bin/bash

On Windows:

@0xced
0xced / DisplayException.cs
Created May 1, 2019
Display exceptions with a TaskDialog or a MessageBox
View DisplayException.cs
// For setting up unhandled exceptions handlers: https://stackoverflow.com/questions/5762526/how-can-i-make-something-that-catches-all-unhandled-exceptions-in-a-winforms-a
// Using Ookii.Dialogs: https://www.nuget.org/packages?q=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
0xced / Working without a nib.md
Created Mar 7, 2019
Working without a nib blog posts by Jeff Johnson (@lapcatsoftware)
View Working without a nib.md
  • [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
0xced / NativeSQLiteWithCostura.csproj
Last active Sep 20, 2019
Embed native e_sqlite3.dll or SQLite.Interop.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) -->
<ItemGroup>
<EmbeddedResource Include="$(NugetPackageRoot)\sqlitepclraw.lib.e_sqlite3.v110_xp\1.1.13\runtimes\win-x86\native\e_sqlite3.dll">
<Link>costura32\e_sqlite3.dll</Link>
</EmbeddedResource>
<EmbeddedResource Include="$(NugetPackageRoot)\sqlitepclraw.lib.e_sqlite3.v110_xp\1.1.13\runtimes\win-x64\native\e_sqlite3.dll">
<Link>costura64\e_sqlite3.dll</Link>
</EmbeddedResource>
</ItemGroup>
@0xced
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 https://stackoverflow.com/questions/20133696/how-can-i-configure-entity-framework-to-automatically-trim-values-retrieved-for/27504530#27504530
@0xced
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
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
0xced / install_mono_workarounds.sh
Last active Jun 27, 2019
Workarounds for using System.Data.SQLite and Microsoft.Azure.Management.ServiceBus on Mono
View install_mono_workarounds.sh
#!/bin/bash -e -x
# For System.Data.SQLite to work on Mono, see https://stackoverflow.com/questions/21293105/system-dllnotfoundexception-on-mono-sqlite/43173220#43173220
function Install_libSQLiteInterop
{
# Latest version is on https://system.data.sqlite.org/index.html/doc/trunk/www/downloads.wiki
SQLITE_VERSION=1.0.111.0
SQLITE_DYLIB=sqlite-netFx-source-${SQLITE_VERSION}/bin/2013/Release/bin/libSQLite.Interop.dylib
pushd ~/Downloads
You can’t perform that action at this time.