Skip to content

Instantly share code, notes, and snippets.

View aspnetde's full-sized avatar

Thomas Bandt aspnetde

View GitHub Profile
@aspnetde
aspnetde / useLocalStorage.ts
Created September 28, 2020 10:03
A Local Storage React Hook
export function useLocalStorage<T>(key: string, initialValue: T) {
const [storedValue, setStoredValue] = useState(() => {
try {
const item = window.localStorage.getItem(key);
return item ? (JSON.parse(item) as T) : initialValue;
} catch (error) {
console.log(error);
return initialValue;
}
});
@aspnetde
aspnetde / compile-times.md
Last active April 6, 2021 07:34
F# vs. C# Compile Times
namespace Foo
open System.Text.Encodings.Web
open System.Text.Json
open System.Text.Json.Serialization
[<RequireQualifiedAccess>]
module JsonSerializer =
let private setupOptions (options: JsonSerializerOptions) =
options.PropertyNamingPolicy <- JsonNamingPolicy.CamelCase
namespace Infrastructure
open System.Text.Encodings.Web
open System.Text.Json
open System.Text.Json.Serialization
[<RequireQualifiedAccess>]
module JsonSerializer =
let private setupOptions (options: JsonSerializerOptions) =
options.PropertyNamingPolicy <- JsonNamingPolicy.CamelCase
@aspnetde
aspnetde / webcrypto-examples.md
Created February 28, 2023 21:27 — forked from pedrouid/webcrypto-examples.md
Web Cryptography API Examples