Skip to content

Instantly share code, notes, and snippets.

View fserb's full-sized avatar

Fernando Serboncini fserb

View GitHub Profile
@fserb
fserb / package.json
Created July 2, 2021 04:18
Build lit into a single javascript file
{
"name": "lit",
"license": "MIT",
"scripts": {
"build": "npm install && rollup -c"
},
"dependencies": {
"@rollup/plugin-node-resolve": "^13.0.0",
"lit": "^2.0.0-rc.2",
"rollup": "^2.52.7"
@fserb
fserb / karplus.strong.js
Created June 16, 2021 17:40
Karplus-Strong with Jaffe-Smith
import {TAU, sampleRate} from "./utils.js";
/*
http://www.music.mcgill.ca/~gary/courses/papers/Karplus-Strong-CMJ-1983.pdf
http://musicweb.ucsd.edu/~trsmyth/papers/KSExtensions.pdf
Simple explanation: http://amid.fish/karplus-strong
+---+ b +---+
x / 0 ------->| B +-+-->| D +--> y
^ +---+ | +---+
@fserb
fserb / chainy.py
Created May 31, 2021 19:37
A blockchain implementation on top of git in 50 lines of Python
#!/usr/bin/env python3
import subprocess, sys, os, tempfile, re
"""
How to use this:
1. create a git repo
2. commit something to it
3. run ./chainy.py <number of zeroes>
@fserb
fserb / spiral.py
Created April 5, 2017 21:57
spiral.py
#!/usr/bin/python
def getSpiral(n):
out = []
for d in range(n+1):
for x in range(-d, d+1):
out.append((x, -d))
if d != 0:
out.append((x, d))
for y in range(-d+1, d):
@fserb
fserb / getimagedata-diff.html
Created March 13, 2017 19:48
Context2D getImageData float hell
<!doctype html>
<style>
body {
font-family: verdana;
}
p {
width: 750px;
}
h3 {
margin-bottom: 0;
@fserb
fserb / polygon.hx
Created March 24, 2014 22:25
SAT for Polygon intersection in 50 lines of Haxe
// Given a Vec2 vector class...
function hitPolygonAxis(points: Array<Vec2>, ret: Array<Float>) {
for (i in 0...points.length) {
var a = points[i];
var b = points[(i+1) % points.length];
var v = Vec2.make(b.x - a.x, b.y - a.y).normal();
// we should be able to only use half circunference.
ret.push(v.angle());
}
}
@fserb
fserb / macro.hx
Created November 8, 2013 20:43
Macro example
class MyClass {
/*
usage:
function x() {
var c = new MyClass();
var x = c.func(10);
}
*/
macro public function func(ethis: Expr, block: Expr): Expr {
hello you fool
@fserb
fserb / install.log
Created May 29, 2012 22:22
brew install -v netpbm --use-llvm 2>&1 | pbcopy
==> Downloading http://sourceforge.net/projects/netpbm/files/super_stable/10.35.82/netpbm-10.35.82.tgz
Already downloaded: /Users/fserb/Library/Caches/Homebrew/netpbm-10.35.82.tgz
/usr/bin/tar xf /Users/fserb/Library/Caches/Homebrew/netpbm-10.35.82.tgz
==> cp Makefile.config.in Makefile.config
cp Makefile.config.in Makefile.config
==> make
make
/private/tmp/homebrew-netpbm-10.35.82-4686/netpbm-10.35.82/Makefile.common:551: Makefile.depend: No such file or directory
cat /dev/null >Makefile.depend
make -C /private/tmp/homebrew-netpbm-10.35.82-4686/netpbm-10.35.82/buildtools/ -f /private/tmp/homebrew-netpbm-10.35.82-4686/netpbm-10.35.82/buildtools/Makefile \
@fserb
fserb / config.log
Created May 28, 2012 18:38
config.log
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
It was created by glib configure 2.32.1, which was
generated by GNU Autoconf 2.68. Invocation command line was
$ ./configure --disable-maintainer-mode --disable-dependency-tracking --prefix=/usr/local/Cellar/glib/2.32.1
## --------- ##
## Platform. ##