Skip to content

Instantly share code, notes, and snippets.

View jwosty's full-sized avatar

John Wostenberg jwosty

View GitHub Profile
open System
open System.Diagnostics
open System.IO
open System.Runtime.ExceptionServices
module ThirdPartyLibrary =
// Represents some low-level async "primitive" which is used in many many places and which may fail. This type of
// method/function is not typically what you're interested in when examining stacktraces.
// Example: a database query function from a thid-party library
let doWorkAsync crash = ExtraTopLevelOperators.async {
@jwosty
jwosty / AsyncFail.fs
Created July 11, 2023 19:16
F# async fail
let f (x: int) =
let y = x / 0
async {
return y
}
let g = async {
let! x = Async.Catch (f 42)
()
}
# Jwosty's powershell profile
Import-Module 'C:\tools\poshgit\dahlbyk-posh-git-9bda399\src\posh-git.psd1'
# Start emacs in no-window mode (CLI mode)
function Private:emacs()
{
& emacs -nw $args
}
@jwosty
jwosty / DragDropPage.fs
Last active January 31, 2021 01:42 — forked from JordanMarr/DragDropPage.fs
Fable bindings for "react-dnd" using HTML5 provider
type Language = {
Name: string
}
let draggableLanguage = FunctionComponent.Of(fun (props: {| lang: Language |}) ->
let dragState, drag, preview = ReactDND.useDrag [
DragSpec.Item { ``type`` = "Language"; dragSrc = props.lang }
DragSpec.Collect (fun mon -> { isDragging = mon.isDragging() })
//DragSpec.End (fun dragItem mon -> printf "DragEnd: %A; Mon.DropTarget: %A" dragItem mon)
]
let sineWaveFadeOutOver500Samples = [|0.000000f; 0.000000f; 0.062523f; 0.062523f; 0.124550f; 0.124550f; 0.185840f; 0.185840f; 0.246153f; 0.246153f; 0.305256f; 0.305256f; 0.362922f; 0.362922f; 0.418928f; 0.418928f; 0.473063f; 0.473063f; 0.525118f; 0.525118f; 0.574899f; 0.574899f; 0.622219f; 0.622219f; 0.666901f; 0.666901f; 0.708779f; 0.708779f; 0.747702f; 0.747702f; 0.783526f; 0.783526f; 0.816125f; 0.816125f; 0.845383f; 0.845383f; 0.871198f; 0.871198f; 0.893483f; 0.893483f; 0.912165f; 0.912165f; 0.927186f; 0.927186f; 0.938501f; 0.938501f; 0.946081f; 0.946081f; 0.949912f; 0.949912f; 0.949994f; 0.949994f; 0.946343f; 0.946343f; 0.938990f; 0.938990f; 0.927978f; 0.927978f; 0.913366f; 0.913366f; 0.895227f; 0.895227f; 0.873647f; 0.873647f; 0.848726f; 0.848726f; 0.820577f; 0.820577f; 0.789324f; 0.789324f; 0.755102f; 0.755102f; 0.718061f; 0.718061f; 0.678357f; 0.678357f; 0.636159f; 0.636159f; 0.591643f; 0.591643f; 0.544995f; 0.544995f; 0.496408f; 0.496408f; 0.446082f; 0.446082f; 0.394222f; 0.394222f; 0.341039f; 0.34103
open System
type private DataGridHelper =
static member inline IsValidRow (this: DataGrid<_,_,_>) row = row < this.rowInfo.Length && row >= 0
static member inline IsValidCol (this: DataGrid<_,_,_>) col = col < this.colInfo.Length && col >= 0
static member inline EnsureValidRow (this: DataGrid<_,_,_>) row = if not (DataGridHelper.IsValidRow this row) then raise (new IndexOutOfRangeException("row")) // TODO: F# vNext nameof(row)
static member inline EnsureValidCol (this: DataGrid<_,_,_>) col = if not (DataGridHelper.IsValidCol this col) then raise (new IndexOutOfRangeException("col")) // TODO: F# vNext nameof(col)
and DataGrid<'TRowInfo, 'TColInfo, 'TElement> =
private { rowInfo: 'TRowInfo[]; colInfo: 'TColInfo[]; elements: Map<int*int, 'TElement> }
# Razer laptop
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDkOGMbkzQz3w1TFJb2+k4W3arOWAIT5tTIScptRaqekNnyXdxPZi68trrwNc16/nty3yyok/vRP2AOO25G44WxPWUwu0g5XJik+QYEITJYkyJC3yCWnVPRg2NnTtU1kQYRsCYO6JsOs5SZpVdFYy37U9OF6uTXy9EC5RBAMfT594lRj5qqhp5vxDaEr+u4zTfvZ/zsnoZpNMYJZOmFAy0Pw13BKZD2ckWwpoWGPyVyynBTNk76DCyCmRNwPv+N/ylCnbt6Sw+594gERd4HrZxq5fA3I2y/Yrfo/7DW82fV7ZreLM6uGeebK2P5ScoflWWKA2UUFsGAQVdVpcSgrStt
open System
open Fable
open Fable.Core
open Fable.React
open Fable.Import
type OnMenuSelectArgs = { key: string; item: Component<obj,obj>; domEvent: Browser.Types.Event; selectedKeys: string[] }
type OnMenuClickArgs = { key: string; item: Component<obj,obj>; domEvent: Browser.Types.Event; keyPath: string[] }
type MenuProps =
<html>
<head>
<meta charset="utf8"/>
<script>
isInterstellar = (typeof(window.interstellarBridge) !== "undefined");
</script>
</head>
<body>
<h1>This webpage is running in <span id="host" /></h1>
<script>
<html>
<head>
<title>Simple html page</title>
<script>if (typeof(xyz) === "undefined") { console.log("head: xyz doesn't exist") } else { console.log("head: xyz exists") }</script>
<script>console.log('head script executed')</script>
</head>
<body>
<h1>This is a &lt;h1&gt; element</h1>
<p>This is a &lt;p&gt; element</p>
<script>if (typeof(xyz) === "undefined") { console.log("body: xyz doesn't exist") } else { console.log("body: xyz exists") }</script>