Skip to content

Instantly share code, notes, and snippets.

View pmark's full-sized avatar

P. Mark Anderson pmark

View GitHub Profile
@pmark
pmark / action-over-words.md
Created June 2, 2025 20:01
Forget being right

On Accepting Unfairness Temporarily:

"Sometimes you have to give up being right to get what you want." - Unknown

"The person who cares least about the relationship has the most power in it. The person who cares most has to do the heavy lifting." - Relationship reality

"You can be right, or you can be married." - Common marriage wisdom

"Fairness is a luxury that stable relationships can afford. Unstable relationships require triage." - Adapted from therapy wisdom

@pmark
pmark / parallax-scrolling-grid.tsx
Created August 30, 2024 06:55
Parallax Grid with React and Tailwind
import React, { useState, useEffect, useRef } from 'react';
const ParallaxScrolling = () => {
const [scrollY, setScrollY] = useState(0);
const [contentHeight, setContentHeight] = useState(0);
const containerRef = useRef(null);
const contentRef = useRef(null);
useEffect(() => {
const container = containerRef.current;
@pmark
pmark / claude_3.5_sonnet_artifacts.xml
Created July 16, 2024 23:56 — forked from dedlim/claude_3.5_sonnet_artifacts.xml
Claude 3.5 Sonnet, Full Artifacts System Prompt
<artifacts_info>
The assistant can create and reference artifacts during conversations. Artifacts are for substantial, self-contained content that users might modify or reuse, displayed in a separate UI window for clarity.
# Good artifacts are...
- Substantial content (>15 lines)
- Content that the user is likely to modify, iterate on, or take ownership of
- Self-contained, complex content that can be understood on its own, without context from the conversation
- Content intended for eventual use outside the conversation (e.g., reports, emails, presentations)
- Content likely to be referenced or reused multiple times
@pmark
pmark / RenderCounterModifier.swift
Created May 3, 2023 23:00
RenderCounterModifier
/**
USAGE
someView.renderCounter()
*/
import SwiftUI
struct RenderCounterModifier: ViewModifier {
@State private var renderCount: Int = 0
@pmark
pmark / OnRenderViewModifier
Created May 3, 2023 20:45
SwiftUI .onRender view modifier
/*
USAGE
struct ContentView: View {
var body: some View {
Text("Hello, World!")
.onRender {
print("View rendered or updated")
}
}
@pmark
pmark / DesignTokenDSL.ts
Last active March 8, 2023 06:46
A Figma API client for declaratively automating design token style sync and docs
class FigmaFile {
private fileId: string;
constructor(fileId: string) {
this.fileId = fileId;
}
async getColors(): Promise<FigmaColor[]> {
const response = await fetch(`https://api.figma.com/v1/files/${this.fileId}/`);
const json = await response.json();
@pmark
pmark / Level.swift
Last active March 6, 2023 00:14
OctopusKit 2D game with data driven tile maps
import Foundation
import SpriteKit
class Level {
let tileSet: SKTileSet
let mapSize: CGSize
let tileSize: CGSize
let tileData: [[Int]]
init(jsonData: Data) throws {
@pmark
pmark / water-shader.metal
Created March 5, 2023 17:19
Metal water
// https://twitter.com/zozuar/status/1632160439944478721?s=42&t=kZ3wyx2jn4JBuVn3WNWeYQ
fragment float4 waterShader(const VertexOut vertexOut [[stage_in]],
constant Uniforms& uniforms [[buffer(0)]]) {
float height, iteration, amplitude, waveLength, xCoord, globalWaveHeight;
// Initialize variables
height = vertexOut.position.y;
iteration = 0.0;
@pmark
pmark / design-tokens.d.ts
Created March 2, 2023 01:14
DesignToken theme TS type
const lightThemeTokens = {
colorPrimary: '#007bff',
colorSecondary: '#6c757d',
fontSizeSmall: '12px',
fontSizeMedium: '16px',
};
const darkThemeTokens = {
colorPrimary: '#61dafb',
colorSecondary: '#c9c9c9',
@pmark
pmark / GameWorld.swift
Last active March 2, 2023 16:39
DSL for game world and level declaration
class GameWorld {
var systems: [System] = []
var entities: [Entity] = []
var terrain: Terrain?
var level: Level?
var player: Player?
// Add a system to the game world
func addSystem(_ system: System) {
systems.append(system)