Skip to content

Instantly share code, notes, and snippets.

View davidlhw's full-sized avatar
:fishsticks:
NullReferenceException

David Lin davidlhw

:fishsticks:
NullReferenceException
View GitHub Profile
{"name":"main","settings":"{\"settings\":\"{\\r\\n \\\"yaml.schemas\\\": {\\r\\n \\\"file:///Users/dlin/.vscode/extensions/atlassian.atlascode-3.0.1/resources/schemas/pipelines-schema.json\\\": \\\"bitbucket-pipelines.yml\\\"\\r\\n },\\r\\n \\\"typescript.updateImportsOnFileMove.enabled\\\": \\\"always\\\",\\r\\n \\\"editor.defaultFormatter\\\": \\\"esbenp.prettier-vscode\\\",\\r\\n \\\"git.confirmSync\\\": false,\\r\\n \\\"vsicons.dontShowNewVersionMessage\\\": true,\\r\\n \\\"black-formatter.args\\\": [\\\"--line-length\\\", \\\"100\\\"],\\r\\n \\\"[prisma]\\\": {\\r\\n \\\"editor.defaultFormatter\\\": \\\"Prisma.prisma\\\"\\r\\n },\\r\\n \\\"[python]\\\": {\\r\\n \\\"editor.defaultFormatter\\\": \\\"ms-python.black-formatter\\\",\\r\\n \\\"editor.formatOnPaste\\\": false,\\r\\n \\\"editor.formatOnSave\\\": true,\\r\\n \\\"editor.codeActionsOnSave\\\": {\\r\\n \\\"source.organizeImports\\\": \\\"explicit\\\"\\r\\n },\\r\\n \\\"editor.formatOnType\\\": true\\r\\n },\\r
@davidlhw
davidlhw / Phantom_Typing.fs
Last active January 15, 2024 05:04
The idea is that you will have a generic wrapper `Event<'T>` and then use different types for `'T` to represent different types of Events. These types (referring to `'T`) are never actually instantiated, which is why they're called phantom types.
[<Struct>]
type Event<'T> = Event of string
type ClickEvent = interface end
type KeyEvent = interface end
// Now we can create events of different types using the phantom types:
let createClickEvent (data: string) : Event<ClickEvent> = Event(data)
let createKeyEvent (data: string) : Event<KeyEvent> = Event(data)
let s3List i = task {
return [| $"foo%d{i}"; $"bar{i}"; $"baz{i}" |]
}
let s3Download k = task {
return $"data%s{k}"
}
let inline flip f x y = f y x // from FSharpPlus
@davidlhw
davidlhw / IAsyncEnumerable.fs
Created June 13, 2023 08:11
A simple wrapper to handle IAsyncEnumerable in F#
type System.Collections.Generic.IAsyncEnumerable<'T> with
member this.AsTask () = task {
let mutable nxt = true
let output = ResizeArray()
let enumerator = this.GetAsyncEnumerator()
while nxt do
let! next = enumerator.MoveNextAsync()
nxt <- next
if nxt then output.Add enumerator.Current
return output.ToArray()
---
- name: Ping remote server
hosts: remote-server # replace it with the server address that you have ssh credentials to
become: yes # optional to have this line
tasks:
- name: Ping the remote server
ping: