Skip to content

Instantly share code, notes, and snippets.

View aspnetde's full-sized avatar

Thomas Bandt aspnetde

View GitHub Profile
@aspnetde
aspnetde / webcrypto-examples.md
Created February 28, 2023 21:27 — forked from pedrouid/webcrypto-examples.md
Web Cryptography API Examples
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
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
@aspnetde
aspnetde / compile-times.md
Last active April 6, 2021 07:34
F# vs. C# Compile Times
@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 / mvu.tsx
Created September 6, 2020 22:23
Pragmatic MVU With React And TypeScript
import React, { useReducer } from "react";
interface State {
userName: string;
password: string;
isValid: boolean;
}
const initialState: State = {
userName: "",

Constraints:

  • Production = Google Play + Apple AppStore.
  • AppStore requires a manual review by Apple which can last between a couple of hours and a couple of days. It is not guaranteed to succeed, releases can be rejected.
  • It is not possible to put multiple releases in a queue – it is only possible to have one in review at Apple at a time.
  • There is no roll-back possible.
  • There will always be multiple release versions in use in parallel.

Goals:

@aspnetde
aspnetde / App.fs
Last active February 13, 2022 21:33
Feliz – MVU with React Function Components
module App
open Elmish
type State =
{ CurrentUser: string option }
type Msg =
| SignIn of string
| SignOut
@aspnetde
aspnetde / foo.md
Last active November 2, 2020 16:11
Setting a fucking environment variable on macOS

Setting a fucking environment variable on macOS

  1. Open Vim (vi ~/.zshrc)

  2. Add the entry (i)

  3. Exit (Esc + :wq)

  4. Refresh (source ~/.zshrc)

<?xml version="1.0" encoding="UTF-8"?>
<settings>
<hitlist>
<connectionString>" &amp; Session("defaultConnectionString") &amp; "</connectionString>
<hitlistDataSource>ViewAcciadoAdminHitlistArticles</hitlistDataSource>
<hitlistDataSourceOrphaned>ViewAcciadoAdminArticlesWithoutReferences</hitlistDataSourceOrphaned>
<recordsPerPage>25</recordsPerPage>