Skip to content

Instantly share code, notes, and snippets.

@adtac
adtac / Dockerfile
Last active April 13, 2024 22:33
#!/usr/bin/env docker run
#!/usr/bin/env -S bash -c "docker run -p 8080:8080 -it --rm \$(docker build --progress plain -f \$0 . 2>&1 | tee /dev/stderr | grep -oP 'sha256:[0-9a-f]*')"
# syntax = docker/dockerfile:1.4.0
FROM node:20
WORKDIR /root
RUN npm install sqlite3
@retrogradeorbit
retrogradeorbit / Makefile
Last active July 20, 2023 01:10
Hot loading C wasm into the browser while preserving the state of the heap
CLANG_DIR = $(HOME)/clang+llvm-13.0.1-x86_64-linux-gnu-ubuntu-18.04
CLANG = $(CLANG_DIR)/bin/clang
LLC = $(CLANG_DIR)/bin/llc
LD = $(CLANG_DIR)/bin/wasm-ld
C_SRC := $(wildcard src/c/*.c)
OBJ_SRC := $(patsubst %.c, %.o, $(C_SRC))
%.o: %.c # delete competing implicit rule
@bobbicodes
bobbicodes / example.cljs
Created December 3, 2021 10:02
Use Web Audio API with nbb
(ns example
(:require ["fs" :as fs]
["web-audio-api$default" :as wa]))
(def ^:dynamic context (wa/AudioContext.))
(set! (.-outStream context) (.-stdout js/process))
(fs/readFile "outfoxing.mp3"
(fn [err buffer]
(when err (throw err))
@borkdude
borkdude / runner.cljs
Created November 9, 2021 13:37
Nbb browser test runner @ Nextjournal
(ns com.nextjournal.tests.browser.runner
(:require [clojure.string :as str]
[clojure.test :as t :refer [test-vars]]
[com.nextjournal.tests.browser.article-test-nbb :as article-test]))
(defmethod t/report [:cljs.test/default :begin-test-var] [m]
(println "===" (-> m :var meta :name))
(println))
(defn print-summary []
// Made with Amplify Shader Editor
// Available at the Unity Asset Store - http://u3d.as/y3X
Shader "Unlit/Directional Tint"
{
Properties
{
_MainTex("MainTex", 2D) = "white" {}
_Color("Color", Color) = (1,1,1,1)
_ColorA("ColorA", Color) = (1,1,1,1)
_ColorB("ColorB", Color) = (1,1,1,1)
@pesterhazy
pesterhazy / indexeddb-problems.md
Last active May 11, 2024 09:57
The pain and anguish of using IndexedDB: problems, bugs and oddities

This gist lists challenges you run into when building offline-first applications based on IndexedDB, including open-source libraries like Firebase, pouchdb and AWS amplify (more).

Note that some of the following issues affect only Safari. Out of the major browsers, Chrome's IndexedDB implementation is the best.

Backing file on disk (WAL file) keeps growing (Safari)

When this bug occurs, every time you use the indexeddb, the WAL file grows. Garbage collection doesn't seem to be working, so after a while, you end up with gigabytes of data.

Random exceptions when working with a large number of indexeddb databases (Safari)

@JoeyBurzynski
JoeyBurzynski / 55-bytes-of-css.md
Last active May 8, 2024 21:42
58 bytes of css to look great nearly everywhere

58 bytes of CSS to look great nearly everywhere

When making this website, i wanted a simple, reasonable way to make it look good on most displays. Not counting any minimization techniques, the following 58 bytes worked well for me:

main {
  max-width: 38rem;
  padding: 2rem;
  margin: auto;
}
"""
Django ORM Optimization Tips
Caveats:
* Only use optimizations that obfuscate the code if you need to.
* Not all of these tips are hard and fast rules.
* Use your judgement to determine what improvements are appropriate for your code.
"""
# ---------------------------------------------------------------------------
@sivartravis
sivartravis / a-wysiwyg-rich-text-editor-with-contenteditable-attribute.markdown
Created March 10, 2017 16:00
A WYSIWYG Rich Text Editor with contentEditable attribute
@markusfisch
markusfisch / README.md
Last active October 8, 2022 06:21
Generate an annual commit report

Generate an annual commit report

Prints something like this:

In 2018 you made 2488 commits in 134 projects.
The average length of a commit message was 62 characters.

Commits per weekday
    Monday     334 ******************************************