Skip to content

Instantly share code, notes, and snippets.

@kflu
kflu / query_ad.fsx
Created January 6, 2017 01:31
Accessing AD through LDAP
(* Accessing AD through LDAP
Inspired by http://stackoverflow.com/a/14814508/695964
Need nuget package System.DirectoryServices
*)
#r @"./packages/System.DirectoryServices/lib/System.DirectoryServices.dll"
open System
@kflu
kflu / HashVsBinarySearch.cs
Last active December 14, 2016 20:10
This profiling program shows that on a 64 bit machine, binary search on a int64 list is faster than binary searching on a in32 list.
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using MathNet.Numerics.Statistics;
namespace HashVsBinarySearch
@kflu
kflu / unsign.ps1
Created November 28, 2016 04:16
Unsign an assembly by tweaking the IL code before assembling it again.
[cmdletbinding()]
param($assembly, [switch]$DisplaySigningOnly)
$fullpath = [System.IO.Path]::GetFullPath($assembly)
$dir = [System.IO.Path]::GetDirectoryName($fullpath)
$ext = [System.IO.Path]::GetExtension($fullpath)
$filename = [System.IO.Path]::GetFileNameWithoutExtension($fullpath)
$assemblyBackupPath = [System.IO.Path]::Combine($dir, $filename + ".signed" + $ext)
$assemblyBackupDir = [System.IO.Path]::Combine($dir, "original")
@kflu
kflu / self-elevated.template.ps1
Created November 19, 2016 05:26
self elevated ps script
# this is from https://blogs.msdn.microsoft.com/virtual_pc_guy/2010/09/23/a-self-elevating-powershell-script/
# Get the ID and security principal of the current user account
$myWindowsID=[System.Security.Principal.WindowsIdentity]::GetCurrent()
$myWindowsPrincipal=new-object System.Security.Principal.WindowsPrincipal($myWindowsID)
# Get the security principal for the Administrator role
$adminRole=[System.Security.Principal.WindowsBuiltInRole]::Administrator
# Check to see if we are currently running "as Administrator"
@kflu
kflu / FakeFake.fsx
Created November 16, 2016 06:40
a drop in replacement for the core Fake functionality - dependency resolution and run tasks
(* It's a drop in replacement for the core Fake functionality - dependency resolution and run tasks
*)
open System
open System.Text
open System.Collections.Generic
open System.IO
let private args = Environment.GetCommandLineArgs() |> List.ofArray |> List.skip 2
printfn "All args: %A" args
@kflu
kflu / schedule.fsx
Last active November 13, 2016 00:53
schedule.fsx
(* Run process on a schedule
Given a process (and arguments) and a schedule, it ensures that the process is run on the schedule:
If the process is not run when it should, it's started
If the process is running when it shouldn't, it's killed
*)
module Schedule =
open System
@kflu
kflu / compute_covariance.m
Created September 5, 2016 06:13
Compute covariance
clc;
close all;
mm = []
E1 = []
E2 = []
for m = 10:50:1000
e1 = 0.0;
@kflu
kflu / springer-free-maths-books.md
Created September 1, 2016 00:42 — forked from bishboria/springer-free-maths-books.md
Springer made a bunch of books available for free, these were the direct links
@kflu
kflu / factorial.rkt
Created June 15, 2016 19:21
Some racket snippets
#lang racket
(define (factorial x)
(cond
[(< x 0) (raise "Value can't be less than zero")]
[(= x 0) 1]
[(= x 1) 1]
[else (* x (factorial (- x 1)))]))
(factorial 99)
(factorial -1)