Skip to content

Instantly share code, notes, and snippets.

View btoo's full-sized avatar
🅱️
2️⃣

btoo

🅱️
2️⃣
View GitHub Profile
@thesamesam
thesamesam / xz-backdoor.md
Last active July 8, 2025 19:40
xz-utils backdoor situation (CVE-2024-3094)

FAQ on the xz-utils backdoor (CVE-2024-3094)

This is a living document. Everything in this document is made in good faith of being accurate, but like I just said; we don't yet know everything about what's going on.

Update: I've disabled comments as of 2025-01-26 to avoid everyone having notifications for something a year on if someone wants to suggest a correction. Folks are free to email to suggest corrections still, of course.

Background

@schwa
schwa / ImmersiveSpaceHelper.swift
Created October 16, 2023 18:05
SwiftUI helpers to make dealing with ImmsersiveSpaces less annoying.
/// Create an ``ImmersiveSpaceState`` in your view, wrap it with `@State` and modify your view content with ``immersiveSpaceHelper()``.
/// Example:
/// ```swift
/// struct MyView: View {
/// @State
/// var immersiveSpaceState = ImmersiveSpaceState(id: "my-immersive-space-id")
///
/// var body: some View {
/// Toggle("Show/Hide Immersive Space", isOn: $immersiveSpaceState.show)
/// .immersiveSpaceHelper($immersiveSpaceState)
@ssalbdivad
ssalbdivad / ArkTypeVsZod.md
Last active July 21, 2025 15:15
ArkType/Zod Comparison

Here's a comparison between how the same simple user definition would be defined using ArkType and Zod:

image

ArkType's definition syntax is more concise (definitions are about 50% shorter on average) as well as making it more visually obvious what the inferred TypeScript type will be. The ability to infer TypeScript definitions directly is the same, but ArkType's syntax is again more concise by allowing you to use typeof on a property of arkUser directly instead of using an extra "infer" helper.

In general, we also have taken significant steps to optimize and clarify our type hints when hovering over validators. For example, in the case above, this is what you see when you mouse over "zodUser":

image

@rbuckton
rbuckton / ts-proposal-range-types.md
Last active June 20, 2024 05:26
Proposal: Range Types for TypeScript

Range Types (T[X:Y]) for TypeScript

A Range Type is a type that produces a new tuple or array type that derives from T by dropping the excess ordered elements of T outside of the range starting at offset X (inclusive) through offset Y (exclusive).

A Range Type is denoted using a : operator in what would otherwise be an Indexed Access Type:

type T = [1, 2, 3][0:2];
@laughinghan
laughinghan / Every possible TypeScript type.md
Last active June 22, 2025 15:21
Diagram of every possible TypeScript type

Hasse diagram of every possible TypeScript type

  • any: magic, ill-behaved type that acts like a combination of never (the proper [bottom type]) and unknown (the proper [top type])
    • Anything except never is assignable to any, and any is assignable to anything at all.
    • Identities: any & AnyTypeExpression = any, any | AnyTypeExpression = any
    • Key TypeScript feature that allows for [gradual typing].
  • unknown: proper, well-behaved [top type]
    • Anything at all is assignable to unknown. unknown is only assignable to itself (unknown) and any.
    • Identities: unknown & AnyTypeExpression = AnyTypeExpression, unknown | AnyTypeExpression = unknown
  • Prefer over any whenever possible. Anywhere in well-typed code you're tempted to use any, you probably want unknown.
@kasperpeulen
kasperpeulen / algebraic-data-type.ts
Last active December 14, 2019 18:13
What is algebraic about algebraic data types?
type TastyFruit = { fruit: 'blueberry' | 'raspberry' } & { portion: 3 | 5 | 7 | 11 } & { tasty: true };
type SomeTimesTasty = { fruit: 'orange' | 'banana' } & { portion: 1 | 2 } & { tasty: boolean };
type NastyFruit = { fruit: 'lemon' } & { portion?: 1 } & { tasty: false };
type Fruit = TastyFruit | SomeTimesTasty | NastyFruit;
const numberOfUniqueInstances = (2 * 4 * 1) + (2 * 2 * 2) + (1 * 2 * 1);
@ruizb
ruizb / advanced-example.md
Last active September 26, 2023 20:21
Reader monad example using fp-ts

The following section is not part of monet.js documentation, but I think it's worth showing how we can compose readers using fp-ts.

Reader composition

Let's say we have the following piece of code:

interface Dependencies {
  logger: { log: (message: string) => void }
 env: 'development' | 'production'
@acutmore
acutmore / README.md
Last active February 27, 2025 19:55
Emulating a 4-Bit Virtual Machine in (TypeScript\JavaScript) (just Types no Script)

A compile-time 4-Bit Virtual Machine implemented in TypeScript's type system. Capable of running a sample 'FizzBuzz' program.

Syntax emits zero JavaScript.

type RESULT = VM<
  [
    ["push", N_1],         // 1
    ["push", False],       // 2
 ["peek", _], // 3
@DimitryDushkin
DimitryDushkin / configs.js
Created October 2, 2018 14:19
React Native 0.57 + Babel 7 + Typescript + Jest
// babel.config.js
module.exports = {
"presets": [
"module:metro-react-native-babel-preset",
],
"plugins": [
["module-resolver", {
"root": ["./src"],
"extensions": [".js", ".ts", ".tsx", ".ios.js", ".android.js"]
}],
@WorldSEnder
WorldSEnder / higher-kinded.ts
Last active January 9, 2023 21:37
Higher kinded types in typescript
// The two main components are the interfaces
// Generic<T, Context> and GenericArg<"identifier">
// Generic basically structurally replaces types in T that are GenericArg<S>
// for some `S extends keyof Context` with `Context[S]`
// See the test cases for specific uses.
// ====== TESTING
// Pass through for trivial types
type Test00 = Generic<number>;