Skip to content

Instantly share code, notes, and snippets.

@dwoodgate
dwoodgate / udf_Levenshtein.sql
Created October 5, 2018 18:53
Levenshtein edit distance between two strings
-- =============================================
-- Computes and returns the Levenshtein edit distance between two strings, i.e. the
-- number of insertion, deletion, and sustitution edits required to transform one
-- string to the other, or NULL if @max is exceeded. Comparisons use the case-
-- sensitivity configured in SQL Server (case-insensitive by default).
-- http://blog.softwx.net/2014/12/optimizing-levenshtein-algorithm-in-tsql.html
--
-- See http://en.wikipedia.org/wiki/Levenshtein_distance
-- This is based on Sten Hjelmqvist's "Fast, memory efficient" algorithm, described
-- at http://www.codeproject.com/Articles/13525/Fast-memory-efficient-Levenshtein-algorithm,
@dwoodgate
dwoodgate / mount.iso.psm1
Created August 31, 2017 18:57 — forked from Thermionix/mount.iso.psm1
powershell mount/unmount iso for all versions of windows
# Uses http://www.ltr-data.se/opencode.html/#ImDisk virtual disk driver for windows 7 or less
# Tries to use chocolatey to install imdisk
# Sample use case:
# Import-Module ".\mount.iso.psm1"
# Invoke-IsoExe "C:\test.iso" "setup.exe" "/passive"
function Mount-Iso([string] $isoPath)
{
if ( -not (Test-Path $isoPath)) { throw "$isoPath does not exist" }
@dwoodgate
dwoodgate / Floaters.swift
Last active January 28, 2016 02:58
Swift Floating Point Frustrations...
// Floaters Playground
// Xcode 7.2 (7C68)
// Illustrating Frustration with Swift Floating Point numbers. Especially annoying in the context of CoreData and JSON
import UIKit
import Foundation
//: Lets start with a Float
let float1 : Float = 9.39
print(float1)
#!/bin/bash
# This script automatically sets the version and short version string of
# an Xcode project from the Git repository containing the project.
#
# To use this script in Xcode, add the script's path to a "Run Script" build
# phase for your application target.
set -o errexit
set -o nounset
@dwoodgate
dwoodgate / gist:10d04d0f3900ee4eb84b
Created February 10, 2015 18:56
PowerShell - Decode base64 encoded binary/text.
. C:\ttdata\PowerShell\lib\byteMe.ps1
$bytes = Convert-HexStringToByteArray -String "0x"
$bf = New-Object System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
$ms = New-Object System.IO.MemoryStream -ArgumentList @(,$bytes)
$val = $bf.Deserialize($ms)
$val