Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@need12648430
need12648430 / example.py
Last active December 2, 2015 21:04
Quarrel: WSGI-style routing for command line tools, in about 50 lines
import sys
from quarrel import Quarrel
@Quarrel("multiply", int, int)
@Quarrel("multiply", int)
def multiply_int(a, b = 2):
print(a * b)
@Quarrel("greet", str)
def greet(name):
@need12648430
need12648430 / example.js
Created August 15, 2016 03:13
Metaview - A tiny, fast, simplified abstraction of JS DataViews (similar to AS3's ByteArray)
// writing
var o = new MetaView();
o.writeInt16(-128);
o.writeUint16(128);
o.writeFloat32(3.141592);
o.writeFloat32([1.5, 1.5]);
o.writeUTF8String("räksmörgås");
// saving
var s = o.finalize();
@need12648430
need12648430 / build-templates.sh
Last active June 2, 2022 03:27
A script to build Godot export templates.
#!/bin/bash
export EMSCRIPTEN_ROOT=[path containing em++, emsdk-portable/emscripten/*]
export ANDROID_HOME=[path to android sdk, usually /home/*/Android/Sdk]
export ANDROID_NDK_ROOT=[path to android ndk, likely $ANDROID_HOME/ndk-bundle]
X11_DEBUG=false
X11_RELEASE=false
WIN_DEBUG=false
WIN_RELEASE=false
@need12648430
need12648430 / l-system.scd
Created October 14, 2019 07:40
L-System in SuperCollider
// Instrument
(
SynthDef(\sine, {
arg freq = 440, amp = 0.5;
Out.ar(0, SinOsc.ar(freq, 0.0, amp * EnvGen.kr(Env.perc(0.01, 0.25), doneAction: 2)) ! 2);
}).add;
)
// Basic Stochastic L-System
(
@need12648430
need12648430 / EventManager.gd
Created January 16, 2021 19:26
A special event manager for keeping persistent game time.
# when loading a save, you'd use this to simulate time since last save
# EventManager.simulate_time_span(LAST_UNIX_TIMESTAMP, THIS_UNIX_TIMESTAMP)
# for example, this will simulate the last 30 seconds before the game opened
# EventManager.simulate_time_span(OS.get_unix_time() - 30, OS.get_unix_time())
# there is an optional third argument to that that specifies a minimum priority
# EventManager.simulate_time_span(LAST_UNIX_TIMESTAMP, THIS_UNIX_TIMESTAMP, Priority.UNSKIPPABLE)
# .. will only run unskippable events
# if the third argument is not specified, both skippable and unskippable events are run