Skip to content

Instantly share code, notes, and snippets.

@davidfowl
davidfowl / MinimalAPIs.md
Last active May 1, 2024 20:58
Minimal APIs at a glance
# Starter pipeline
# Start with a minimal pipeline that you can customize to build and deploy your code.
# Add steps that build, run tests, deploy, and more:
# https://aka.ms/yaml
trigger:
- master
pool:
vmImage: 'ubuntu-latest'
@johnazariah
johnazariah / LinqExtensions.cs
Last active March 28, 2024 08:50
Maybe Monad in C#
public static partial class LinqExtensions
{
public static Maybe<C> SelectMany<A, B, C>(this Maybe<A> ma, Func<A, Maybe<B>> f, Func<A, B, C> select) => ma.Bind(a => f(a).Map(b => select(a, b)));
}
namespace System.Collections.ObjectModel
{
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System.Collections.Generic;
using System.Collections.Specialized;
using System.ComponentModel;
using System.Diagnostics;
@dannyc02
dannyc02 / gist:6d42b90154d8478dc6fd
Created February 18, 2016 15:51
CQRS - generic handlers
using FluentAssertions;
using MediatR;
using NUnit.Framework;
using StructureMap.Graph;
using System;
using System.IO;
using System.Linq;
using System.Security.Cryptography.X509Certificates;
using StructureMap;
using StructureMap.Graph.Scanning;
@witwall
witwall / pdfdecrypt.cpp
Created July 10, 2014 10:39
Decrypt PDF(remove pdf password and limitations) with pdfium
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "../fpdfsdk/include/fpdfview.h"
#include "../fpdfsdk/include/fpdfsave.h"
/*
author:Steven Lee
@MrZoidberg
MrZoidberg / OpenFileWithRetry.cs
Created October 12, 2012 13:17
C# FileStream Lock. How to wait for a file to get released and lock safely.
public static FileStream OpenFileWithRetry(string path, FileMode mode, FileAccess fileAccess, FileShare fileShare)
{
ArgumentsChecker.ArgumentNotNull(path, "path");
var autoResetEvent = new AutoResetEvent(false);
while (true)
{
try
{