Skip to content

Instantly share code, notes, and snippets.

View rflechner's full-sized avatar

Flechner Romain rflechner

View GitHub Profile
@rflechner
rflechner / Benchmark.cs
Created May 26, 2016 13:50
Benchmark C# collections
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication3
{
class Program
@rflechner
rflechner / Huffman.fs
Last active September 29, 2023 07:30
A FSharp implementation of Huffman compression algorithm
module Huffman
open System
open System.IO
type bit = bool
type path = bit list
type BinaryTreeNode =
| Leaf of byte * frequency:int
@rflechner
rflechner / MainActivity.fs
Created April 4, 2016 09:36
Android button like FB chat bubble
namespace UILearning
open System
open Android.App
open Android.Content
open Android.OS
open Android.Runtime
open Android.Views
open Android.Widget
(**
Depends of https://gist.github.com/rflechner/60fc8a1074fb21cb5ff5
------------------------------------------------------------------------
Example where we can parse a CSS file in a non-seekable stream.
*)
#load "ParsingBase.fs"
module Css =
type CssBlock =
@rflechner
rflechner / ParsingBase.fs
Last active January 15, 2016 11:22
Small FSharp parsing toolkit
(**
Small parsing bases classes inspired by technique used to parse HTML in FSharp.Data.
(see https://github.com/fsharp/FSharp.Data/blob/master/src/Html/HtmlParser.fs#L226)
I liked this parsing strategy and it inspired me for other parsing algorithms.
*)
module ParsingBase
open System
open System.IO
#r "packages/Newtonsoft.Json.7.0.1/lib/net45/Newtonsoft.Json.dll"
open System
open System.Net
open Newtonsoft.Json
type NugetSearchItemResult =
{ Version:string
Published:DateTime }
type NugetSearchResult =
@rflechner
rflechner / Dapper.fs
Created December 14, 2015 17:00 — forked from vbfox/Dapper.fs
Minimal dapper in F#
module DapperFSharp =
open System.Data.SqlClient
open System.Dynamic
open System.Collections.Generic
open Dapper
let dapperQuery<'Result> (query:string) (connection:SqlConnection) =
connection.Query<'Result>(query)
let dapperParametrizedQuery<'Result> (query:string) (param:obj) (connection:SqlConnection) : 'Result seq =
@rflechner
rflechner / RC4.fsx
Created July 2, 2015 15:41
RC4 stream encoding and decoding (bad performances)
open System
open System.Text
open System.IO
open System.Diagnostics
let mutable lastPercent = 0L
let computeRc4 (password:string) (content:Stream) (output:Stream) =
let swap (arr:byte array) (i:int) (j:int) =
let t = arr.[j]
@rflechner
rflechner / TinyRestServer-sample.fsx
Last active August 29, 2015 14:23
Tiny REST server
#r "System.Xml.Linq.dll"
open System
open System.Net
open System.Text
open System.IO
open System.Xml.Linq
open System.Collections.Generic
#load "TinyRestServer.fs"