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{
https://29a.ch/2010/5/17/path-tracing-a-cornell-box-in-javascript
https://29a.ch/sandbox/2010/cornellbox/worker.js
https://github.com/mateuszroth/raytracejs/blob/master/src/js/partials/raytrace.js
http://www.gabrielgambetta.com/tiny_raytracer_full.js
http://jupiter909.com/mark/jsrt.html
https://mzucker.github.io/2016/08/03/miniray.html
http://lousodrome.net/blog/light/tag/path-tracing/
http://create.stephan-brumme.com/smallpt-js/
http://blog.tojicode.com/2010/09/raytracing-in-javascript.html
https://benedikt-bitterli.me/tantalum/
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]