Skip to content

Instantly share code, notes, and snippets.

View latkin's full-sized avatar

Lincoln Atkinson latkin

View GitHub Profile
@latkin
latkin / speclet_scriptdebug.md
Last active February 14, 2025 10:14
F# Script Debugging Speclet

#F# Script Debugging

Adds supprt the to Visual F# tooling for rich debugging of F# scripts.

##Motivation F# developers love the low-overhead, iterative REPL experience they have today, but when scripts become larger and more complex, they become difficult to debug. There is no interaction whatsoever today between Editor + F# Interactive and the VS Ddbugger. Thus to debug complex scripts, devs must resort to one of:

  • printf debugging
  • Create a console app, paste in script code, F5-debug the console app
@latkin
latkin / NativeMethods.fs
Created February 22, 2016 19:46
F# p/invoke example with structs
namespace Test
open System.Runtime.InteropServices
// F# implementation of http://pinvoke.net/default.aspx/mpr.WNetAddConnection2
module NativeMethods =
type ResourceScope =
| Connected = 0x1u
| GlobalNet = 0x2u
@latkin
latkin / table.md
Last active January 21, 2023 21:29
JNI Object Lifetimes Quick Reference
Yes
JNI Object Use across JNI calls? Use on different thread? Notes
JavaVM
@latkin
latkin / regexinfo.ps1
Last active April 1, 2022 01:43
Regex matching helper
<#
Dumps capture group locations and names/numbers
Example:
> regexinfo 'Jenny: 555-867-5309' '(?<name>\w+):\s+(?<phone>(?:(?<area>\d{3})-)?(\d{3}-\d{4}))'
[Jenny]: [[555]-[867-5309]]
| || |
| || 1
| |area
| phone
@latkin
latkin / code.fsx
Last active November 13, 2019 09:06
Seq perf
open System
open System.Collections
open System.Collections.Generic
open System.Diagnostics
open System.Linq
module Algos =
//
// non-lazy solutions
//
@latkin
latkin / func.ps1
Created October 14, 2017 05:22
PowerShell engine stack overflow
# dot-source this function and try running `f 0`
# It work on Windows in Windows PowerShell and PowerShell Core
# On Mac the powershell process terminates with `Process is terminating due to StackOverflowException. Abort trap: 6`
# programmatically generated by parsing https://www.unicode.org/Public/10.0.0/ucd/LineBreak.txt
function f { param($codepoint)
if(($codepoint -ge 0x0000) -and ($codepoint -le 0x0008)){ 'CM' }
elseif($codepoint -eq 0x0009) { 'BA' }
elseif($codepoint -eq 0x000A) { 'LF' }
elseif(($codepoint -ge 0x000B) -and ($codepoint -le 0x000C)){ 'BK' }
@latkin
latkin / keybase.md
Created September 9, 2017 22:40
keybase.md

Keybase proof

I hereby claim:

  • I am latkin on github.
  • I am latkin (https://keybase.io/latkin) on keybase.
  • I have a public key ASCflg_ClIWLE2q9NWAhQHrj7HkQGqf0na2Msud4uTsV6Ao

To claim this, I am signing this object:

@latkin
latkin / ripgrep-gitgrep.md
Last active July 13, 2017 23:02
Ripgrep v git grep speed comparison

Environment

// OS
OS Name:                   Microsoft Windows 10 Pro
OS Version:                10.0.15063 N/A Build 15063
System Manufacturer:       Apple Inc.
System Model:              MacBookPro11,5
System Type:               x64-based PC
Processor(s):              1 Processor(s) Installed.
@latkin
latkin / benchmark.ps1
Created August 2, 2016 02:58
Benchmark of PowerShell de-duplication cmdlets
#
# Benchmarking code used to produce results from blog post
# http://latkin.org/blog/2016/08/02/curious-behavior-when-de-duplicating-a-collection-in-powershell/
#
# home-grown HashSet-based approach
function hashunique {
param(
[Parameter(Mandatory=$true, ValueFromPipeline = $true)]
[Object[]] $InputObject
@latkin
latkin / extendAPIWithUnits.md
Last active March 31, 2016 21:39
How to extend a 3rd-party API with F# units of measure

Extending a 3rd-party API with F# units of measure

F# units of measure are nice, but what if I'm using a 3rd-party library which doesn't support UOM? I don't want to re-implement the library, but it would be nice to add the extra safety afforded by UOM. Can I somehow annotate the APIs of the 3rd party library with units?

Yes!

How to do it

Say you have some unit-free external library like this, which you can't modify: