Skip to content

Instantly share code, notes, and snippets.

View isaksky's full-sized avatar

Isak Sky isaksky

View GitHub Profile
type Base() =
member x.Method() = "base method";
type Derived() =
inherit Base()
member x.Method() = "derived method"
type Base with
member x.Extension() = "base extension"
@isaksky
isaksky / Output.txt
Created April 2, 2018 19:58
Gjallarhorn
Creating signal...
A dependency has changed. Called from thread ID 1
Setting m1...
Sleeping 200 ms
A dependency has changed. Called from thread ID 3
Signal value is now 4. thread ID: 3
Signal value is now 4. thread ID: 4
Thread awake again
Setting m2...
Finished
@isaksky
isaksky / re-frame-helper.cljs
Created January 9, 2018 03:51
reframe - Request Effect
(def req-counter (atom 0))
;; Not battle tested - adapted from an existing codebase
(rf/reg-fx
:request-giving-id
(fn [[request-id {:keys [on-complete resp-body-formatter request-args]
:or {on-complete identity
resp-body-formatter identity}
:as args}]]
@isaksky
isaksky / sq.ps1
Created May 5, 2017 02:00
Powershell Query SQL
function sq
{
param([string]$Query)
$SQLServer = "ISAK-NEW\SQLEXPRESS"
$SQLDBName = "AdventureWorks2014"
$SqlConnection = New-Object System.Data.SqlClient.SqlConnection
$SqlConnection.ConnectionString = "Server = $SQLServer; Database = $SQLDBName; Integrated Security = True;"
$SqlCmd = New-Object System.Data.SqlClient.SqlCommand
$SqlCmd.CommandText = $Query
$SqlCmd.Connection = $SqlConnection
@isaksky
isaksky / gist:ceceeb64a5d7cf666c4a18991403f97a
Last active April 19, 2017 06:05
Things I'd like to see in a .NET (F#) web framework

Some things I'd like to see in a F# web framework, inspired from experience using Phoenix in Elixir.

  • Top knotch integrated i18n support, on par with gettext in Elixir.
    • Not sure if this is possible in F#, because of the lack of metaprogramming features. The Elixir solution is based on macros, so that one can extract .pot translation files at compile time.
  • Standard way to talk to databases suitable for most apps (Elixir example: Ecto)
  • Standard way to do database migrations suitable for most apps (Elixir example: Ecto)

This is more ecosystem related, but I'll include them anyway, because I think they are important to overall productivity:

  • Standardized, extensible project build/scripting tool already on my path. Examples:
@isaksky
isaksky / reframe-helper.cljs
Last active September 15, 2020 14:56
Register delayed subscription
(ns foo
(:require [re-frame.core :as rf]
[re-frame.db]
[reagent.ratom :as ra :refer [reaction]])
(:import goog.async.Debouncer))
(defn reg-sub-delayed
"Similar to reg-sub, except the computation is debounced.
It can be called like this:
@isaksky
isaksky / Html.fs
Created January 18, 2017 20:41
Html Dsl
module Html =
type Tag(name:string) =
let mutable _safeContent = false
member val className = "" with get, set
member val content = "" with get, set
// For ease of use, support children in both list and resize array
member val childrenL : Tag list = [] with get, set
member val childrenR = ResizeArray<Tag>() with get, set
member this.name with get() = name
@isaksky
isaksky / Working-with-SQL-syntax-trees-in-F.md
Last active June 25, 2021 19:21
Working with SQL syntax trees in F#

Working with SQL syntax trees in F#

Update 12/15/2016 - Added Sql generation

Welcome to my blog post for #FsAdvent 2016.

If you're using a relational database, as your application grows in size, at some point you may find yourself looking for an SQL parser. This can give you lots of leverage, for example allowing you to:

  • Do permission checks on queries before executing them
  • Rewrite incorrect or inefficient queries
@isaksky
isaksky / TransactSqlWrapping.fs
Last active July 24, 2021 14:07
F# Generated wrapper for Microsoft.SqlServer.TransactSql
module Foo
open System
open Microsoft.SqlServer.TransactSql
type [<RequireQualifiedAccess>] TSqlFragment =
| AdHocDataSource of InitString:StringLiteral option * ProviderName:StringLiteral option
| AddFileSpec of File:ScalarExpression option * FileName:Literal option
| AlterAvailabilityGroupAction of AlterAvailabilityGroupAction
| AlterAvailabilityGroupFailoverOption of OptionKind:ScriptDom.FailoverActionOptionKind * Value:Literal option
| AlterDatabaseTermination of ImmediateRollback:bool * NoWait:bool * RollbackAfter:Literal option
@isaksky
isaksky / Program.fs
Created August 23, 2016 22:32
Benchmark various ways to read N rows async
open Hopac
open BenchmarkDotNet
open BenchmarkDotNet.Attributes
open BenchmarkDotNet.Running
open System
open System.Data
open System.Data.SqlClient
open System.Threading.Tasks
open BenchmarkDotNet.Configs
open BenchmarkDotNet.Diagnostics.Windows