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 24, 2024 14:23
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.

Background

On March 29th, 2024, a backdoor was discovered in xz-utils, a suite of software that

@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)
@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 19, 2024 10:18
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'
@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>;
@JeremyRH
JeremyRH / event-delegation-performance.md
Last active April 2, 2024 18:43
Does event delegation actually improve performance?

Does event delegation actually improve performance?

Event delegation works by attaching a single event listener to a parent element to catch events bubbling up from the children. Many people believe this is more performant than attaching event listeners to each child. I am not convinced this is always true.

Let's start with a common example of event delegation. Here we have a list of elements:

<ul id="item-list">
  <li data-cost="12">Item 1</li>
  <li data-cost="18">Item 2</li>
  <li data-cost="6">Item 3</li>
 ...
variables:
GIT_SSL_NO_VERIFY: "1"
USE_DOCKER: "1"
image: <KKBOX_DOCKER_IMAGE_NAME>
stages:
- e2e-test
e2e-test: