Skip to content

Instantly share code, notes, and snippets.

View davidglassborow's full-sized avatar

David Glassborow davidglassborow

View GitHub Profile
@davidglassborow
davidglassborow / Rinkeby.md
Created January 16, 2018 11:11 — forked from learner-long-life/Rinkeby.md
How to get on Rinkeby Testnet in less than 10 minutes

How to get on Rinkeby Testnet in less than 10 minutes

Following instructions from the excellent https://www.rinkeby.io/

Synchronizing a Full Node

A full node lets you access all state. There is a light node (state-on-demand) and wallet-only (no state) instructions as well,

@davidglassborow
davidglassborow / Deploy.md
Created February 6, 2018 10:46 — forked from alfonsogarciacaro/Deploy.md
Deploying an F# ASP.NET Core app (Giraffe) to Azure

Deploying an F# ASP.NET Core app to Azure

Last week I spent a lot of time trying to deploy an F# ASP.NET Core app (a Giraffe app, specifically) to Azure because the information to complete all the steps was scattered in several places. So I'm writing this hopefully it will save the pain to others :)

Preparation

The following steps are mostly taken from this guide and it's only necessary to do them once:

  1. Create an account in Azure (or use an existing one)
  2. Create a resource group (or use an existing one)

Homebrew Permissions Denied Issues Solution

Installing and fixing node.JS


brew install node

@davidglassborow
davidglassborow / sql.fs
Created May 15, 2018 10:00 — forked from yawaramin/sql.fs
Type-safe SQL query using phantom types to model query parts as state transitions
(*
An incomplete implementation of a type-safe SQL query in F#.
The idea is that a query is built up clause by clause, by representing
each additional clause being added on to the query as a state transition
between different types of queries. We capture these different types as
phantom types to make sure that only valid transitions (query clause
additions) as defined by us can be carried out.
The final result is a 'total query' that can be converted to a string,
let ParallelThrottledIgnore (startOnCallingThread:bool) (parallelism:int) (xs:seq<Async<_>>) = async {
let! ct = Async.CancellationToken
let sm = new SemaphoreSlim(parallelism)
let count = ref 1
let res = TaskCompletionSource<_>()
let tryWait () =
try sm.Wait () ; true
with _ -> false
let tryComplete () =
if Interlocked.Decrement count = 0 then
// From https://github.com/jet/kafunk/blob/master/src/kafunk/Utility/BoundedMb.fs
[<AutoOpen>]
module internal Kafunk.BoundedMb
// TODO: https://github.com/fsprojects/FSharpx.Async
open System
open System.Collections.Generic
@davidglassborow
davidglassborow / Async.Timeout.fs
Created June 28, 2018 12:26 — forked from eulerfx/Async.Timeout.fs
F# Async Timeout
let timeoutNone (timeoutMs:int) (a:Async<'a>) : Async<'a option> = async {
let! ct = Async.CancellationToken
let res = TaskCompletionSource<_>()
use cts = CancellationTokenSource.CreateLinkedTokenSource ct
res.Task.ContinueWith (fun _ -> cts.Cancel ()) |> ignore
use timer = new Timer((fun _ -> res.TrySetResult None |> ignore), null, timeoutMs, Timeout.Infinite)
Async.StartThreadPoolWithContinuations (
a,
(fun a -> res.TrySetResult (Some a) |> ignore),
(fun e -> res.TrySetException e |> ignore),
@davidglassborow
davidglassborow / tutorial.md
Created July 19, 2018 11:11 — forked from swalkinshaw/tutorial.md
Designing a GraphQL API

Tutorial: Designing a GraphQL API

This tutorial was created by Shopify for internal purposes. We've created a public version of it since we think it's useful to anyone creating a GraphQL API.

It's based on lessons learned from creating and evolving production schemas at Shopify over almost 3 years. The tutorial has evolved and will continue to change in the future so nothing is set in stone.

@davidglassborow
davidglassborow / phantom.fs
Last active October 6, 2019 19:29
Use of phantom types for static validation of list length
// Phantom types - http://web.archive.org/web/20100615031841/http://blog.matthewdoig.com/?p=138
// Rather than DUs, just use simple marker interfaces
type Zero = interface end
type Succ<'length> = interface end
type Phantom<'a,'length> = Phantom of 'a list
let toList (Phantom l) = l
let nil = Phantom [] : Phantom<_,Zero>
@davidglassborow
davidglassborow / Windows Defender Exclusions VS 2017.ps1
Last active November 29, 2018 16:33 — forked from dknoodle/Windows Defender Exclusions VS 2017.ps1
Adds Windows Defender exclusions for Visual Studio 2017
$userPath = $env:USERPROFILE
$pathExclusions = New-Object System.Collections.ArrayList
$processExclusions = New-Object System.Collections.ArrayList
$pathExclusions.Add('C:\Windows\Microsoft.NET') > $null
$pathExclusions.Add('C:\Windows\assembly') > $null
$pathExclusions.Add($userPath + '\AppData\Local\Microsoft\VisualStudio') > $null
$pathExclusions.Add('C:\ProgramData\Microsoft\VisualStudio\Packages') > $null
$pathExclusions.Add('C:\Program Files (x86)\MSBuild') > $null
$pathExclusions.Add('C:\Program Files (x86)\Microsoft Visual Studio 14.0') > $null