Skip to content

Instantly share code, notes, and snippets.

@warappa
warappa / FoldToAscii.cs
Last active Dec 12, 2021
Ignore diacritics in Like using a custom SQLite function
View FoldToAscii.cs
public static class StringExtensions
{
/// <summary>
/// Converts characters above ASCII to their ASCII equivalents. For example,
/// accents are removed from accented characters.
/// </summary>
/// <param name="input"> The string of characters to fold </param>
/// <param name="length"> The length of the folded return string </param>
/// <returns> length of output </returns>
public static string FoldToASCII(this string input, int? length = null)
@warappa
warappa / AppDbContext.cs
Last active Jun 17, 2019
Using global value converters with Entity Framework Core 2.2.5. Based on Andrew Lock's StronglyTypedIdValueConverterSelector https://andrewlock.net/strongly-typed-ids-in-ef-core-using-strongly-typed-entity-ids-to-avoid-primitive-obsession-part-4/
View AppDbContext.cs
using Microsoft.EntityFrameworkCore;
namespace GlobalValueConverterSample
{
public class AppDbContext : DbContext
{
public AppDbContext(DbContextOptions<AppDbContext> options)
: base(options)
{
@warappa
warappa / App.xaml
Last active May 20, 2017
Overriding Styles in Xaml
View App.xaml
<Application x:Class="WpfApp1.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:WpfApp1"
StartupUri="MainWindow.xaml">
<Application.Resources>
<!-- base colors -->
<SolidColorBrush x:Key="buttonBackground" Color="#ff00ff"></SolidColorBrush>
<!-- base button style -->
@warappa
warappa / Bootstrap.cs
Last active Dec 22, 2015
A possible way of doing event-versioning with NEventStore and a custom Json.Net NEventStore-serializer.
View Bootstrap.cs
public class EventStorageBootStrap
{
public static void BootStrap()
{
...
var eventStore = Wireup.Init()
...
.UsingNewtonsoftJsonSerialization(new VersionedEventSerializationBinder())
...
.Build();