Skip to content

Instantly share code, notes, and snippets.

@hallojoe
hallojoe / isometric-ratio.md
Created February 19, 2022 20:43
Isometric Ratio

Isometric Ratio

1.4142:1 1:0.5773

@hallojoe
hallojoe / status.md
Created February 7, 2022 15:08
REST client is a bitch and Azure pipelines is a man-whore without access to viagra.

Status

The REST client is a bitch and Azure pipelines is a man-whore without access to viagra.

@hallojoe
hallojoe / FluentBuilder.ts
Last active January 29, 2022 05:34
Fluent builder pattern in TypeScript
interface IBuilder<T> {
build(): T
}
interface IValueModel {
name: string
date: Date
}
class FluentValueModelBuilder implements IBuilder<IValueModel> {
@hallojoe
hallojoe / bitwise.md
Last active November 4, 2021 13:03
Bitwise in 1010 seconds.

Bitwise

Bitwise in 1010 seconds.

AND &

Return 1 where both are 1:

   bin   dec

@hallojoe
hallojoe / CharacterClassifications.ts
Created February 24, 2021 15:00
Bitwise flags for classifying characters.
enum CharacterClassifications {
None = 0,
Digit = 1,
Upper = 2,
Lower = 4,
Space = 8,
Control = 16,
SymbolOrPunctuation = Upper | Lower,
AlphaOrDigit = Digit | Upper | Lower | Space
}
@hallojoe
hallojoe / UnicodeMap.ts
Created February 14, 2021 12:21
Unicode character code ranges mapped to category name.
const UnicodeMap = new Map<string, [number, number]>([
["Basic Latin", [32, 127]],
["Latin-1 Supplement", [160, 255]],
["Latin Extended-A", [256, 383]],
["Latin Extended-B", [384, 591]],
["IPA Extensions", [592, 687]],
["Spacing Modifier Letters", [688, 767]],
["Combining Diacritical Marks", [768, 879]],
["Greek and Coptic", [880, 1023]],
["Cyrillic", [1024, 1279]],
@hallojoe
hallojoe / inheritTimeFrom.js
Last active January 20, 2021 11:14
Inherit time from source date time
function inheritTimeFrom(source, target) {
var sourceDateTime = new Date(source)
var targetDateTime = new Date(target)
targetDateTime.setHours(sourceDateTime.getHours())
targetDateTime.setMinutes(sourceDateTime.getMinutes())
targetDateTime.setSeconds(sourceDateTime.getSeconds())
targetDateTime.setSeconds(sourceDateTime.getMilliseconds())
return targetDateTime
}
@hallojoe
hallojoe / File.ts
Created January 14, 2021 09:16
Read files with FileReader
export interface IFile {
name: string
size?: number
type?: string
lastModified?: number
data?: string|ArrayBuffer
}
export enum ReadFileReturnTypes {
Text = "text",
const slug = s => s
.toString() // ensure string
.normalize("NFD") // convert to unicode normalization form using (N)normalization (F)form canonical (D)decomposition
// aka. remove accent and leave base
.replace(/[\u0300-\u036f]/g, "") // remove range combining grave accent to combining lating small letter x
.toLowerCase() // lower chars
.trim() // trim whitespace
.replace(/\s+/g, '-') // replace space(s) with dash
.replace(/[^\w-]+/g, "") // remove things not a-z A-Z 0-9 or -
.replace(/--+/g, '-') // replace double dash with single dash
@hallojoe
hallojoe / checkered-background.css
Last active September 9, 2021 18:13
Color-scheme aware CSS checkered background.
:root {
font-size:24px;
--backgroundColor: rgba(255, 255, 255);
--squareColor: rgba(100, 100, 100, .5);
--squareSize: 2em;
}
@media (prefers-color-scheme: dark) {
:root {
--backgroundColor: rgb(0, 0, 0);