Skip to content

Instantly share code, notes, and snippets.

View vbfox's full-sized avatar
❄️
Winter is coming

Julien Roncaglia vbfox

❄️
Winter is coming
View GitHub Profile
@vbfox
vbfox / LibGit2SharpForLinqPad.cs
Last active May 20, 2019 18:32
Helps libgit2sharp to find it's native dll in LINQPad when loaded via NuGet
static class LibGit2SharpForLinqPad
{
[DllImport("kernel32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
static extern bool SetDllDirectory(string lpPathName);
[DllImport("kernel32.dll", CharSet = CharSet.Unicode, EntryPoint = "GetDllDirectory", SetLastError = true)]
static extern uint GetDllDirectoryPInvoke(uint length, StringBuilder lpPathName);
static string GetDllDirectory()
{
@vbfox
vbfox / web.config.xml
Created March 30, 2016 21:23
Suave IIS https with redir
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<handlers>
<remove name="httpplatformhandler" />
<add name="httpplatformhandler" path="*" verb="*" modules="httpPlatformHandler" resourceType="Unspecified" />
</handlers>
<httpPlatform
stdoutLogEnabled="true"
stdoutLogFile="./logs/SuaveIIS.log"
@vbfox
vbfox / TaskDefinitionHelper.fsx
Last active September 8, 2017 08:19
Allow to define FAKE targets with a syntax similar to Gulp tasks
#r "packages/FAKE/tools/FakeLib.dll"
namespace BlackFox
/// Allow to define FAKE tasks with a syntax similar to Gulp tasks
[<AutoOpen>]
module TaskDefinitionHelper =
open Fake
open System
open System.Text.RegularExpressions
@vbfox
vbfox / fixupDotCoverArgs.fs
Last active January 20, 2016 14:34
Fix dotcover args in FAKE to be correctly passed to CreateProcess
/// Escape arguments in a form that programs parsing it as Microsoft C Runtime will successfuly understand
/// Rules taken from http://www.daviddeley.com/autohotkey/parameters/parameters.htm#WINARGV
module MsvcrCommandLine =
open System.Text
let escapeArg (arg : string) (builder : StringBuilder) =
let needQuote = arg.Contains(" ") || arg.Contains("\t")
let rec escape (builder: StringBuilder) pos =
if pos >= arg.Length then
()
@vbfox
vbfox / ExtractNestedClassesToSeparateFiles.fs
Last active November 3, 2015 00:00
Extract nested classes/struct/enums to their own files
open Microsoft.CodeAnalysis
open Microsoft.CodeAnalysis.CSharp
open Microsoft.CodeAnalysis.CSharp.Syntax
open Microsoft.CodeAnalysis.MSBuild
open Microsoft.CodeAnalysis.Formatting
open System.IO
module FluentRoslynLite =
let (!!) t = Async.AwaitTask t
let emptyFile = SyntaxFactory.CompilationUnit()
@vbfox
vbfox / buildx.fsx
Last active December 14, 2016 15:57
Launching a scriptcs .csx file from FAKE
#r @"packages/FAKE/tools/FakeLib.dll"
#load "./scriptcs.fsx"
open Fake
open Fake.AssemblyInfoFile
open Fake.ReleaseNotesHelper
open System
open System.IO
open Fake.ScriptCs
@vbfox
vbfox / CreateRelativePath.cs
Last active March 21, 2023 07:31
Make a path relative in C# and F#
using System;
using System.IO;
static class RelativePath
{
private static string[] GetPathPart(string path)
{
return path
.TrimEnd(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar)
.Split(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar);
@vbfox
vbfox / es_shield.md
Last active August 29, 2015 14:24
Using ElasticSerarch shield to secure inter-node communications

Using ElasticSerarchshield to secure inter-node communications

All is from a cygwin console like Babun under windows.

CA certificate creation

openssl genrsa -des3 -out root-ca.key 2048
@vbfox
vbfox / EwsExtensions.cs
Last active August 29, 2015 14:24
Utilities for Exchange Webservice
static class EwsExtensions
{
public static string GetFullPath(this Folder folder, string separator = "/")
{
var folderPathProperty = new ExtendedPropertyDefinition(26293, MapiPropertyType.String);
var folderPathPropertySet = new PropertySet(BasePropertySet.FirstClassProperties) { folderPathProperty };
var folderWithFullnameProperty = Folder.Bind(folder.Service, folder.Id, folderPathPropertySet);
object pathObj = null;
if (!folderWithFullnameProperty.TryGetProperty(folderPathProperty, out pathObj))
@vbfox
vbfox / EnumerableBatch.cs
Last active August 29, 2015 14:24
Linq IEnumerable batching
// Variant of MoreLinq Batch implementation
// https://code.google.com/p/morelinq/source/browse/MoreLinq/Batch.cs
public static IEnumerable<IEnumerable<T>> Batch<T>(IEnumerable<T> source, int size)
{
T[] bucket = null;
var count = 0;
foreach (var item in source)
{