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 / 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 / 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 / paket.dependencies.json
Created June 28, 2016 22:07
Paket dependency files syntax color v2
{
"fileTypes": [
"paket.dependencies"
],
"foldingStartMarker": "",
"foldingStopMarker": "",
"name": "Paket",
"patterns": [
{
"include": "#line"
@vbfox
vbfox / uuid.ts
Created August 30, 2016 12:30
Simple typescript code to generate random (v4) UUID for browsers
// Adapted from https://github.com/broofa/node-uuid/
// Under MIT License
// tslint:disable:no-bitwise
function getRandomFromMathRandom() {
const result = new Array(16);
let r = 0;
for (let i = 0; i < 16; i++) {
@vbfox
vbfox / MutableFsharp.fs
Last active September 13, 2016 16:31
Naive F# Game
open System
open System.Diagnostics
open System.Threading
[<Struct>]
type Vector =
val X: float32
val Y: float32
val Z: float32
@vbfox
vbfox / WindowsPath.fs
Created October 2, 2016 21:20
F# module for WindowsPath access (Useful in FAKE scripts)
module WindowsPath =
open System
open System.IO
let path = lazy (Environment.GetEnvironmentVariable("PATH").Split(';') |> List.ofArray)
let pathExt = lazy (Environment.GetEnvironmentVariable("PATHEXT").Split(';') |> List.ofArray)
let find names =
path.Value
|> Seq.collect (fun dir -> names |> List.map (fun name -> Path.Combine(dir, name)))
@vbfox
vbfox / CommandLine.fs
Last active October 2, 2016 21:47
Windows Command Line escaping (Useful in FAKE scripts)
namespace BlackFox.CommandLine
/// 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 =
@vbfox
vbfox / Term.fsx
Last active October 16, 2016 21:51
256 colors in F#, just for fun
module Term
let private esc = string (char 0x1B)
let private csi = esc + "["
let printsequencef f = Printf.kprintf (fun s -> System.Console.Write(esc + s)) f
let printcsif f = Printf.kprintf (fun s -> System.Console.Write(csi + s)) f
let resetToInitialState() = printsequencef "c"
let cursorUp (rows: int) = printcsif "%iA" rows
let cursorDown (rows: int) = printcsif "%iB" rows
@vbfox
vbfox / GenJObject.fs
Created February 9, 2017 17:28
FSCheck for Newtonsoft.Json
let genByteArray = Gen.arrayOf Arb.generate<byte>
let genJValue =
Gen.oneof
[
Arb.generate<int> |> Gen.map JValue
Arb.generate<UInt32> |> Gen.map JValue
Arb.generate<bool> |> Gen.map JValue
Arb.generate<char> |> Gen.map JValue
Arb.generate<DateTime> |> Gen.map JValue
@vbfox
vbfox / security.fsx
Last active March 10, 2017 21:19
Security for @fsibot
#r "../packages/FSharp.Compiler.Service/lib/net45/FSharp.Compiler.Service.dll"
open System
open System.IO
open System.Threading
open System.Threading.Tasks
open System.Net
open Microsoft.FSharp.Compiler
open Microsoft.FSharp.Compiler.Ast
open Microsoft.FSharp.Compiler.Interactive.Shell