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 / LuceneIndexEml.linq
Last active May 6, 2017 22:32
LINQPad script to index & search a folder full of .eml files
<Query Kind="Program">
<NuGetReference>HtmlAgilityPack</NuGetReference>
<NuGetReference>Lucene.Net</NuGetReference>
<NuGetReference>MimeKit</NuGetReference>
<Namespace>HtmlAgilityPack</Namespace>
<Namespace>Lucene.Net</Namespace>
<Namespace>Lucene.Net.Analysis</Namespace>
<Namespace>Lucene.Net.Analysis.Standard</Namespace>
<Namespace>Lucene.Net.Analysis.Tokenattributes</Namespace>
<Namespace>Lucene.Net.Documents</Namespace>
@vbfox
vbfox / ConEmuToCmd.fsx
Created April 21, 2017 12:39
Configure cmd.exe to use the same colors as the current theme configured in ConEmu
#r "System.Xml.Linq"
open System
open System.Text.RegularExpressions
open System.Xml.Linq
open System.Xml.XPath
open Microsoft.Win32
let convert () =
let doc = XDocument.Load(Environment.ExpandEnvironmentVariables(@"%APPDATA%\ConEmu.xml"))
@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
@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 / 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 / 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 / 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 / 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 / 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 / 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"