Skip to content

Instantly share code, notes, and snippets.

@hunterloftis
hunterloftis / decksetup.sh
Last active August 14, 2022 17:41
steam deck custom setup for development
#!/usr/bin/env bash
set -euxo pipefail
# Idempotent deck setup script
# Expects to live with other dotfiles:
# - ~/.bashrc
# - ~/.flat/docker
# - ~/.flat/docker-compose
# ref: https://askubuntu.com/a/30157/8698
import { ReactiveController, LitElement } from 'Lit';
/*
class Component extends LitElement {
bounds = new BoundsControllerBasic(this);
render() {
// use this.bounds.width, this.bounds.height
}
// node clobber.mjs -> demonstrate common filesystem anti-pattern that creates race conditions
// node clobber.mjs safe -> demonstrate safe filesystem manipulation
import cluster from 'cluster';
import process from 'process';
import fs from 'fs';
import path from 'path';
import { fileURLToPath } from 'url';
const __dirname = path.dirname(fileURLToPath(import.meta.url));
Format: JSON
Protocol: HTTP
Type: Post (always Post, or just for transactions? Can I GET a query as well?)
Concept: Query
---
Protocol Method
(Concept)
---
HTTP Post
(Query)

3 Ways to design the lightmap API

The purpose of the module is to create and update path-traced 2D lightmaps. For example, to create interesting dynamic top-down lighting in a 2D game.

Option 1: Trace on lightmap

lm := lightmap.New(image.Rect(0, 0, 100, 100))
light := lightmap.Light{
for (let i = 1; i <= 100; i++) {
const match = []
if (i % 3 === 0) match.push('fizz')
if (i % 5 === 0) match.push('buzz')
if (match.length === 0) match.push(i)
console.log(match.join(''))
}
// Start starts rendering based on CLI parameters
func (c Cli) Start() {
out := flag.String("out", "render.png", "Output png filename.")
concurrency := flag.Int("frames", runtime.NumCPU(), "Number of frames to combine.")
samples := flag.Float64("samples", math.Inf(1), "Average per pixel samples to take.")
heat := flag.String("heat", "", "Heatmap png filename.")
flag.Parse()
running := make(chan struct{})
ch := make(chan os.Signal, 2)
func main() {
scene := trace.Scene{}
camera := trace.Camera{Width: 960, Height: 540}
sampler := trace.NewSampler(&camera, &scene, 10)
renderer := trace.NewRenderer(&camera)
light := trace.NewLight(1000, 1000, 1000)
redPlastic := trace.NewPlastic(1, 0, 0, 1)
bluePlastic := trace.NewPlastic(0, 0, 1, 1)
whitePlastic := trace.NewPlastic(1, 1, 1, 0)
silver := trace.NewMetal(0.972, 0.960, 0.915, 1)
package main
import "fmt"
// fibonacci is a function that returns
// a function that returns an int.
func fibonacci() func() int {
prev := [2]int{0, 1}
return func() int {
n := prev[0]
<!doctype html>
<html>
<head>
<title>JS Paint</title>
<style>
* { margin: 0; padding: 0; box-sizing: border-box; font-family: arial, sans-serif; }
body { background: #eee; }
#wrap { position: relative; margin: 50px auto 0 auto; width: 800px; }
#canvas { width: 800px; height: 600px; background: #fff; box-shadow: 1px 1px 32px #ddd; cursor: crosshair; }
#tools { position: absolute; width: 150px; top: 0; left: -150px; font-size: 18px; }