Skip to content

Instantly share code, notes, and snippets.

View dungpa's full-sized avatar

Anh-Dung Phan dungpa

View GitHub Profile
@dungpa
dungpa / FiniteStateMachine.fs
Last active May 13, 2017 18:25
Create a simple FSM model
// A representation from http://stackoverflow.com/questions/5840292/automata-in-ocaml
type FiniteStateMachine<'State, 'Input> = {
Initial : 'State;
Final : 'State -> bool;
Transition : 'Input -> 'State -> 'State;
}
type IntegerKind =
| Odd

Create a 64-bit version of PerfView for bigger memory space

copy PerfView.exe PerfView64.exe
src\tools\corflags /32bitPref- PerfView64.exe

Reference microsoft/perfview#175 (comment)

Debug StackOverflow exceptions

open Sc_util
open OUnit
open Mlfi_check
let test_count = 100
module UtilTests = struct
let gen_function ~(gen_input: 'a gen) ~(map_output: 'a -> 'b): ('a * ('a -> 'b)) gen =
let f a = return (a, (fun (_: 'a) -> map_output a)) in
gen_input >>= f
@dungpa
dungpa / Program.fs
Created June 7, 2015 10:46
SourceLink's PdbReader
module SourceLink.Program
open System
open System.IO
open SourceLink
open SourceLink.SymbolStore
open System.Reflection
//let pdbSourceLink = @"..\..\..\packages\SourceLink.Fake\tools\SourceLink.pdb"
//let dllSourceLink = @"..\..\..\packages\SourceLink.Fake\tools\SourceLink.dll"
@dungpa
dungpa / fscheck_generator.fs
Last active August 29, 2015 14:10
FsCheck code snippets
let rec generateDeclExpr size =
if size <= 2 then
generateIdentExpr size
else
let genSubDeclExpr = generateDeclExpr (size/2)
let genSubDeclExprList = Gen.listOf genSubDeclExpr
let genSubIdentExpr = generateIdentExpr (size/2)
let genSubSynType = generateSynType (size/2)
let genSubSynTypeList = Gen.listOf genSubSynType
let genSubSynPat = generateSynPat (size/2)
@dungpa
dungpa / Companion.md
Last active August 29, 2015 14:05
Companion code for "F# and linear programming: an introduction to Z3 optimization APIs"
@dungpa
dungpa / ComplexConstraints.fs
Last active August 29, 2015 14:05
Boolean encoding of Virtual Machine placement problem
let mkBoolLe coeffs args k = context.MkPBLe(coeffs, args, k)
let assertHard (b: BoolExpr) = solver.Assert(b)
// Each server has fulfilled capability constraints
for j in 1..n do
let yj = ys.[j-1]
let capabilityJ = capabilities.[j-1]
let coeffs =
[|
yield! requirements
@dungpa
dungpa / Constraints.fs
Last active August 29, 2015 14:05
Integer encoding of Virtual Machine placement problem
// Place each VM on exactly one server
for xi in xs do
assertHard (add xi =. mkInt 1)
// A used server always has at least a VM on it
for j in 1..n do
let yj = ys.[j-1]
xs |> Array.iter (fun xi ->
let xij = xi.[j-1]
assertHard (yj >=. xij))
namespace FSharpVSPowerTools.ProjectSystem
open System
open System.IO
open System.Diagnostics
open EnvDTE
open VSLangProj
open FSharp.CompilerBinding
open System.Reflection
open Microsoft.FSharp.Reflection
type Direction =
| Up
| Down
| Left
| Right
with override this.ToString() =
match this with
| Up -> "Up"
| Down -> "Down"