Skip to content

Instantly share code, notes, and snippets.

View isaksky's full-sized avatar

Isak Sky isaksky

View GitHub Profile
@isaksky
isaksky / gist:5906464
Created July 2, 2013 02:52
core.match example
(defn interactive-content?
"Check if an html element (in hiccup form) is interactive content. See http://www.w3.org/html/wg/drafts/html/master/dom.html#interactive-content-0"
[node]
(match node
[(:or :a :button :details :embed :iframe :keygen :label :select :textarea :video) & _] true
[(:or :audio :video) {:controls _} & _] true
[ (:or :img :object) {:usemap _} & _] true
[:input attrs & _ ] (not (= "hidden"(:type attrs)))
:else false))
@isaksky
isaksky / stack_pls.ex
Created July 11, 2016 00:53
iex - Missing stacktrace
defmodule StackPls do
@behaviour :gen_statem
def callback_mode(), do: :state_functions
def start_link(opts) do
:gen_statem.start_link(__MODULE__, opts, [])
end
# Mandatory callback functions
@isaksky
isaksky / Program.fs
Created August 12, 2016 05:17
Json type generator
open Newtonsoft.Json
open Newtonsoft.Json.Linq
open System.Collections.Generic
open System
open System.IO
open System.Text
type TypeNodeMut =
{ fieldname: string
children : Dictionary<string, TypeNodeMut>
@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
@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 / 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 / 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 / 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 / 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
type Base() =
member x.Method() = "base method";
type Derived() =
inherit Base()
member x.Method() = "derived method"
type Base with
member x.Extension() = "base extension"