Skip to content

Instantly share code, notes, and snippets.

View NatElkins's full-sized avatar

Nat Elkins NatElkins

View GitHub Profile
# SSH Agent Functions
# Mark Embling (http://www.markembling.info/)
#
# How to use:
# - Place this file into %USERPROFILE%\Documents\WindowsPowershell (or location of choice)
# - Import into your profile.ps1:
# e.g. ". (Resolve-Path ~/Documents/WindowsPowershell/ssh-agent-utils.ps1)" [without quotes]
# - Enjoy
#
# Note: ensure you have ssh and ssh-agent available on your path, from Git's Unix tools or Cygwin.
@ninjarobot
ninjarobot / strace-netcore.md
Last active December 3, 2024 12:36
Trace .NET Core Applications on Linux with `strace`

Trace .NET Core Applications on Linux with strace

Troubleshooting a running application can be difficult, usually it starts around checking log output and then following through the likely code paths to get an idea of where a failure may occur. In a development environment, you might attach a debugger a step through source, but troubleshooting isn't always that convenient. There are several helpful tools that can assist, but one that gives the most comprehensive view of a running application is strace. With strace you are able to see all of the system calls an application makes to get a detailed understanding of what is going on "under the hood" in order to troubleshoot an issue.

Take a simple "hello world" F# application, the kind you get from dotnet new console -lang F# -n strace-sample". Build it with dotnet build and then launch it with strace to get a trace of all the system calls in a file called trace.log(adjusting for your build output path if on a different framework vers

[<Erase>]
type IProp<'comp when 'comp : not struct> = | Prop of string * obj
with
static member inline Create (value: string * obj) = Prop value
static member inline Build(props: IProp<'comp> seq) = props |> unbox<(string * obj) seq> |> createObj |> unbox<'comp>
let inline (!<) x = IProp.Build x
module Interop =
let inline mkProperty<'Component when 'Component : not struct> (key:string) (value:obj) : IProp<'Component> =
module Operators
open Feliz
let inline (+@) (tag: IReactProperty list -> ReactElement) (className: string) (props: IReactProperty list) =
tag (props @ [ prop.className className ])
let inline (++) (tag: IReactProperty list -> ReactElement) (prop: IReactProperty) (props: IReactProperty list) =
tag [prop; yield! props ]
[<Interface>]
type HTMLAttributes<'element when 'element :> Element and 'element :> EventTarget> =
inherit AriaAttributes
inherit DOMAttributes<'element>
abstract member defaultChecked: bool option with get, set
[<Interface>]
type HTMLAttributesFactory<'Property, 'element when
'Property :> HTMLAttributes<'element> and
@neon-sunset
neon-sunset / README.md
Last active December 15, 2024 21:10
Quick workflow for using F# interactive to build small native console applications
  1. Get .NET SDK with sudo apt install dotnet9 (or dotnet-sdk-9.0), brew install dotnet for macOS
  2. Get FSharpPacker tool with dotnet tool install -g --allow-roll-forward FSharpPacker
  3. Make an F# interactive script file (e.g. copy the phash.fsx below)
  4. Compile it with fspack {your-script.fsx} -f net9.0 -o {destination} --aot
    (in this example: fspack phash.fsx -f net9.0 -o . --aot), note that it will take some time to do so for the first time - .NET needs to fetch IL AOT Compiler from Nuget
  5. Profit! You have compiled an F# script to a native binary
  6. (Optional) If you add fspk.fish, the process is simplified to fspk {my-script}.fsx!

Note 1: if you are not using macOS or FreeBSD, give https://github.com/ieviev/fflat a try which can produce even smaller binaries

@NatElkins
NatElkins / cloud-init.yaml
Created March 8, 2025 22:09
cloud-init script for VPS
#cloud-config
# Enable automatic package updates and upgrades during cloud-init execution
package_update: true
package_upgrade: true
packages:
# Security and Hardening
- ufw
- fail2ban