Skip to content

Instantly share code, notes, and snippets.

View markmals's full-sized avatar

Mark Malstrom markmals

View GitHub Profile
transcodeHEVCAll() {
for file in "$1"/**/*(.); do
transcodeHEVC "$file"
done
}
transcodeHEVC() {
file="$1"
ext="${file##*.}"
base=$(basename $file $ext)
import { Suspense, use } from "react";
import { ErrorBoundary } from "react-error-boundary";
import type { Route } from "./+types.ts";
export async function loader() {
// not awaited
const reviews = getReviews();
// awaited (blocks the transition)
const book = await fetch("/api/book").then(res => res.json());
@markmals
markmals / signal-helpers.ts
Last active November 8, 2024 22:10
Helper functions missing from Angular's Signal implementation
import { signal, computed } from '@angular/core'
function writable<T>(fn: () => T) {
const c = computed(() => signal(fn()))
const w = () => c()()
Object.assign(w, { set: value => c().set(value) })
return w
}
function derived<T>(value: T, fn: (previous: T) => T) {
@markmals
markmals / *Pointer.swift
Last active November 12, 2024 16:44
An approximation of Rust & C++ smart pointers in Swift with non-copyable types
public protocol Pointer<Pointee>: ~Copyable {
associatedtype Pointee
var pointee: Pointee { get nonmutating set }
}
public struct UniquePointer<Pointee>: ~Copyable, Pointer {
private let memory: UnsafeMutablePointer<Pointee>
public var pointee: Pointee {
get { memory.pointee }
@markmals
markmals / effect-stream.ts
Created December 4, 2023 16:48
Create an async iterable stream of values from a Solid.js signal effect
import { createMemo, createEffect } from 'solid-js';
export async function* createEffectStream<T>(fn: () => T) {
let promises: Promise<T>[] = [];
let resolve: (value: T) => void;
promises.push(
new Promise(r => {
resolve = r;
}),
);
@markmals
markmals / Emulator.md
Last active October 10, 2023 16:36
Guides for setting up a Linux computer to play video games in emulators
@markmals
markmals / Wiggle.swift
Last active November 6, 2025 14:50
The iOS Home Screen wiggle animation, in SwiftUI
import SwiftUI
extension View {
func wiggling() -> some View {
modifier(WiggleModifier())
}
}
struct WiggleModifier: ViewModifier {
@State private var isWiggling = false
extension Array {
func combine(_ numberOfElements: Int) -> [[Element]] {
guard numberOfElements > 0 else { return [.init()] }
guard let first = first else { return [] }
return Array(dropFirst())
.combine(numberOfElements - 1)
.map { [first] + $0 } +
Array(dropFirst())
.combine(numberOfElements)
import tweepy # pip3 install tweepy
import json
from datetime import datetime, timedelta, timezone
CONSUMER_KEY = "**********"
CONSUMER_SECRET = "**********"
def oauthLogin(consumerKey, consumerSecret):
auth = tweepy.OAuthHandler(consumerKey, consumerSecret)
authURL = auth.get_authorization_url()
@markmals
markmals / Swift Wish List.md
Last active June 9, 2026 01:37
Features I would like to see from Swift and its core ecosystem

Swift Wish List

Features I would like to see from Swift and its core ecosystem, to make it a robust and ergonomic language for all use cases.

  • ❌ = Unimplemented / no accepted design
  • 📜 = Manifesto / vision
  • ⚾️ = Pitch / discussion
  • 💍 = Proposal
  • ⛔️ = Partially implemented / preview / gated / awaiting fuller implementation
  • ⚠️ = In active review