Skip to content

Instantly share code, notes, and snippets.

💭
Pixelated

Devon Burriss dburriss

View GitHub Profile
@dburriss
dburriss / Hyde.fsx
Created Jan 13, 2019
[WIP] Script to generate a static site/blog
View Hyde.fsx
#r "packages/Antlr4.Runtime/lib/net45/Antlr4.Runtime.dll"
#r "packages/Liquid.NET/lib/net452/Liquid.NET.dll"
#r "packages/YamlDotNet/lib/net45/YamlDotNet.dll"
namespace Hyde
type FrontMatter = Map<string,obj>
type ContentItem = {
FrontMatter:FrontMatter
ContentText:string
}
@dburriss
dburriss / Install-Paket.ps1
Last active Jan 13, 2019
A Powershell script to install Paket dependency manager in current folder (sub-folder .paket)
View Install-Paket.ps1
New-Item -ItemType directory -Path ".paket"
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
$tag = (Invoke-WebRequest -Uri https://api.github.com/repos/fsprojects/Paket/releases | ConvertFrom-Json)[0].tag_name
$uri = " https://github.com/fsprojects/Paket/releases/download/" + $tag + "/paket.bootstrapper.exe"
Invoke-WebRequest $uri -OutFile .paket/paket.exe
@dburriss
dburriss / CanopyHelpers.fsx
Created Oct 15, 2018
Examples of using F# Canopy with fsx script files
View CanopyHelpers.fsx
#r "packages/NETStandard.Library/build/netstandard2.0/ref/netstandard.dll"
open canopy.csharp
#r "packages/Selenium.WebDriver/lib/netstandard2.0/WebDriver.dll"
#r "packages/canopy/lib/netstandard2.0/canopy.dll"
open System
open canopy.classic
open OpenQA.Selenium
///////////////////////////////////////
@dburriss
dburriss / Install-ADR-to-gitbash.ps1
Last active Sep 28, 2018
Installs ADR tools into git bash directory
View Install-ADR-to-gitbash.ps1
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
# $tag = (Invoke-WebRequest -Uri https://api.github.com/repos/npryce/adr-tools/releases | ConvertFrom-Json)[0].tag_name
# Set explicit version due to https://github.com/npryce/adr-tools/issues/71
$tag = "2.1.0"
$uri = " https://github.com/npryce/adr-tools/archive/" + $tag + ".zip"
Invoke-WebRequest $uri -OutFile C:\Temp\adr.zip
Expand-Archive "C:\Temp\adr.zip" -Force -DestinationPath "C:\Temp\"
$src = "C:\Temp\adr-tools-" + $tag + "\src\*"
Copy-Item -Force -Recurse -Verbose $src -Destination "C:\Program Files\Git\usr\bin\"
@dburriss
dburriss / Install adr-tools on Windows Ubuntu bash
Created Sep 25, 2018
Installs adr-tools on Windows Ubuntu Bash
View Install adr-tools on Windows Ubuntu bash
wget https://github.com/npryce/adr-tools/archive/3.0.0.tar.gz
tar -xf 3.0.0.tar.gz
export PATH="$PATH:~/adr-tools-3.0.0/src/"
source ~/.profile
@dburriss
dburriss / Result.cs
Last active Aug 28, 2018
A safeish `Result` type. It throws if `IsSuccess` has not been called before accessing `Value`.
View Result.cs
using System;
using System.Collections.Generic;
using System.Linq;
namespace X
{
public class Result
{
public static Result Success() => new Result();
public static Result Fail(params Exception[] exceptions) => new Result(exceptions);
@dburriss
dburriss / download_vsbuildtoold.ps1
Created Aug 16, 2018
Downloads the Visual Studio 2017 build tools command line installer
View download_vsbuildtoold.ps1
$buildToolsUrl = "https://aka.ms/vs/15/release/vs_buildtools.exe"
$installLocation = "C:\TEMP\vs_buildtools.exe"
(New-Object System.Net.WebClient).DownloadFile($buildToolsUrl, $installLocation)
@dburriss
dburriss / Keypress.fs
Created Aug 2, 2018
Console app that listens for keypress events even in the packground
View Keypress.fs
namespace Native
type HookProc = delegate of int * nativeint * nativeint -> nativeint
module User32 =
open System.Runtime.InteropServices
[<DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)>]
extern nativeint SetWindowsHookEx(int idHook, HookProc lpfn, nativeint hMod, uint32 dwThreadId)
@dburriss
dburriss / Pdf.fsx
Created Jul 25, 2018
Helper F# script file for extracting text from a PDF file
View Pdf.fsx
#r "packages/PdfSharp/lib/net20/PdfSharp.dll"
open PdfSharp.Pdf.IO
open System.Text
open PdfSharp.Pdf.Content.Objects
open PdfSharp.Pdf.Content
let rec extractText(content:CObject, sb:StringBuilder) =
match content with
| :? CArray as xs -> for x in xs do extractText(x, sb)
@dburriss
dburriss / Csv.fsx
Created Jul 25, 2018
Helper F# script file for working with csv files
View Csv.fsx
open System.IO
open Microsoft.FSharp.Reflection
open System
type Array =
static member join delimiter xs =
xs
|> Array.map (fun x -> x.ToString())
|> String.concat delimiter
You can’t perform that action at this time.