Skip to content

Instantly share code, notes, and snippets.

View cambiata's full-sized avatar

Jonas Nyström cambiata

View GitHub Profile
@memononen
memononen / easing.c
Last active October 7, 2020 21:37
Cheap Fake Cubic Easing Curve
//
// Copyright (c) 2013 Mikko Mononen memon@inside.org
//
// This software is provided 'as-is', without any express or implied
// warranty. In no event will the authors be held liable for any damages
// arising from the use of this software.
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it
// freely, subject to the following restrictions:
// 1. The origin of this software must not be misrepresented; you must not
@smhanov
smhanov / OpenType.ts
Last active July 20, 2024 11:37
Here is my implementation of a TrueType font reader in Typescript. You can read a font directly from an ArrayBuffer, and then call drawText() to draw it. See my article http://stevehanov.ca/blog/index.php?id=143. The second file, OpenType.ts is the same thing but it handles more TrueType files. It is also more coplex
// To see this run, you first stub out these imports. Then put the file in a Uint8Array.
// let slice = new Slice(array);
// let font = new OTFFont(slice);
// Then you can call methods like font.drawText(canvasContext, )
//
//
import { ICanvasContext } from "./ICanvasContext"
import { log as Log } from "./log"
const log = Log.create("OPENTYPE");
@monsieuroeuf
monsieuroeuf / python-api.md
Last active November 16, 2023 07:11
DaVinci Resolve API
@flpvsk
flpvsk / recorderWorkletProcessor.js
Last active March 22, 2024 06:28
An example of a recorder based on AudioWorklet API.
/*
A worklet for recording in sync with AudioContext.currentTime.
More info about the API:
https://developers.google.com/web/updates/2017/12/audio-worklet
How to use:
1. Serve this file from your server (e.g. put it in the "public" folder) as is.
@nadako
nadako / 1 Main.hx
Last active October 16, 2021 04:38
ocaml-like `with` for Haxe
using WithMacro;
typedef Player = {
final name:String;
final level:Int;
}
class Main {
static function main() {
var player = {name: "Dan", level: 15};
@kmcnellis
kmcnellis / firebaseImportUsersMD5.js
Created September 15, 2017 20:03
How to import users in Firebase using MD5 Hashing
var crypto = require('crypto');
var fs = require('fs');
var exec = require('child_process').exec;
var uploadCommand = "firebase auth:import users.json --hash-algo=MD5 --rounds=0";
var stringToBase64 = function(plaintext){
return new Buffer(plaintext).toString('base64');
}
var users = [
import haxe.ds.Either;
class Main {
static function main() {
trace("HI");
var t : WildMap = ["a" => 1, "b"=> 2];
var f = function(x : Map<Int,String>){
trace(x);
for (k in x.keys()){
trace(k);
}
@RealyUniqueName
RealyUniqueName / KeyValueIterator.hx
Last active October 14, 2016 10:35
Key-value map iterator
class KeyValueIterator<K,V> {
var map:Map<K,V>;
var keys:Iterator<K>;
static public inline function pairs<K,V>(map:Map<K,V>) return new KeyValueIterator(map);
public inline function new(map:Map<K,V>) {
this.map = map;
this.keys = map.keys();
}
@francescoagati
francescoagati / Main.hx
Created June 14, 2016 19:09
haxe nested structInit
@:structInit
class A {
var x:Int;
var y:Int;
}
@:structInit
class B {
var a:A;
var k:Int;
@nadako
nadako / Main.hx
Created June 24, 2015 19:36
Haxe + SDL = native love \o/
class Main {
static function main() {
Sdl.init(Sdl.INIT_EVERYTHING);
var win = Sdl.createWindow("Hello", 100, 100, 800, 600, Sdl.WINDOW_OPENGL);
var ren = Sdl.createRenderer(win, -1, Sdl.RENDERER_ACCELERATED);
var bmp = Sdl.loadBMP("test.bmp");
var tex = Sdl.createTextureFromSurface(ren, bmp);
Sdl.freeSurface(bmp);
for (i in 0...3) {