Skip to content

Instantly share code, notes, and snippets.

module IsaacStuff =
type TableRow =
| Empty
| DataRow of string array
type TableSetting =
| Border of TableBorder
| Column of TableColumn
| Row of TableRow
let createTable settings =
settings
let maybeAValue = Some "Test"
let firstVersion = [
"Hello"
"There"
match maybeAValue with // <- explicit match on option and yield only on Some x
| Some v -> v
| None -> ()
]
#r "nuget:Farmer"
open Farmer
open Farmer.Builders
let myFunctions = functions {
name "myFunctions"
}
let template = arm {
@isaacabraham
isaacabraham / 1-nav.html
Last active October 2, 2020 00:20 — forked from CallumVass/nav.fs
<aside class="relative bg-blue-700 lg:self-stretch lg:w-64 w-full shadow-xl flex flex-col">
<div class="p-6 flex justify-between">
<a href="..">
<img class="object-scale-down h-8 lg:h-32" src=".." alt=".. Logo"/>
</a>
<div class="block lg:hidden">
<button id="nav-toggle" class="flex items-center px-3 py-2 border rounded text-white border-white">
<svg class="fill-current h-3 w-3" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg">
<title>Menu</title>
<path d="M0 3h20v2H0V3zm0 6h20v2H0V9zm0 6h20v2H0v-2z"/>
using System;
using System.Collections.Generic;
using System.Linq;
namespace ICantSeeSharp
{
static class DateStream
{
public static IEnumerable<DateTime> AllDates
{
open BenchmarkDotNet
open BenchmarkDotNet.Attributes
open BenchmarkDotNet.Running
let numbers = [ 1 .. 100000 ]
let numbersArray = numbers |> Array.ofList
type Accumulators() =
[<Benchmark>]
member _.ListFold () = List.fold (+) 0 numbers
[<Benchmark>]
// Boilerplate / "Frameworky" code
module Safe =
/// A function which, when given a model, will return a new model and a command, depending on the state of the server call.
type CallHandler<'TModel, 'TMsg> = 'TModel -> 'TModel * Cmd<'TMsg>
/// Represents a message which encapsulates a client / server call and response.
type ServerMessage<'TModel, 'TMsg> = CallHandler<'TModel, 'TMsg> -> 'TMsg
/// Makes a GET to a server endpoint and handles the outgoing request and incoming response.
let inline Get<'TModel, 'TMsg> endpoint onDispatch onSuccess (serverCall:ServerMessage<'TModel,'TMsg>) input =
let onLoaded entity model = onSuccess model entity, Cmd.none
let loadCommand = Cmd.OfPromise.perform (endpoint >> Fetch.get<unit, _>) input (onLoaded >> serverCall)
module rec Program
open Microsoft.EntityFrameworkCore
type BloggingContext =
{ Blogs : DbSet<Blog>
Posts : DbSet<Post> }
let configureDb (optionsBuilder:DbContextOptionsBuilder) =
optionsBuilder.UseSqlServer @"Server=(localdb)\mssqllocaldb;Database=Blogging;Integrated Security=True"
open Giraffe
open Saturn
let myRouter = choose [
route "/api/public" >=> text "Hello"
requiresAuthentication (RequestErrors.UNAUTHORIZED "" "" "admin check") >=> route "/api/admin" >=> text "ADMIN"
requiresAuthentication (RequestErrors.UNAUTHORIZED "" "" "customer check") >=> route "/api/customer" >=> text "CUSTOMER"
]
let a = application {
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"outputs": {},
"parameters": {},
"resources": [
{
"apiVersion": "2020-03-01",
"dependsOn": [
"isaacsupercosmosdb"