Skip to content

Instantly share code, notes, and snippets.

@t-mw
t-mw / static_server.js
Last active March 11, 2016 09:13 — forked from ryanflorence/static_server.js
Node.JS static file web server. Put it in your path to fire up servers in any directory, takes an optional port argument.
var http = require("http"),
url = require("url"),
path = require("path"),
fs = require("fs")
port = process.argv[2] || 8888;
http.createServer(function(request, response) {
var uri = url.parse(request.url).pathname
, filename = path.join(process.cwd(), uri);
@t-mw
t-mw / interact.bash
Last active April 16, 2016 15:08
interact.bash
# make commands interactive, essentially a bash version of http://thorstenball.com/fzz/.
# to use, copy to ~/.bash_profile or similar. requires ncurses.
# e.g. for an interactive `git grep`:
# interact git grep {{}} | ...
interact() {
# for printing ui create fd pointing to tty,
# in case stdout is redirected
exec 3> /dev/tty
@t-mw
t-mw / nginx-cors.conf
Created April 24, 2016 10:34 — forked from algal/nginx-cors.conf
nginx configuration for CORS (Cross-Origin Resource Sharing), with an origin whitelist, and HTTP Basic Access authentication allowed
#
# A CORS (Cross-Origin Resouce Sharing) config for nginx
#
# == Purpose
#
# This nginx configuration enables CORS requests in the following way:
# - enables CORS just for origins on a whitelist specified by a regular expression
# - CORS preflight request (OPTIONS) are responded immediately
# - Access-Control-Allow-Credentials=true for GET and POST requests
@t-mw
t-mw / app.js
Created May 16, 2016 12:11 — forked from mjackson/app.js
Using webpack with pixi.js
var PIXI = require('pixi.js')
console.log(PIXI)
@t-mw
t-mw / ErlangEUnit.sublime-snippet
Last active July 17, 2016 09:33
Sublime snippets
<snippet>
<content><![CDATA[${1:test_name}_(${2:_State}) ->
{"${3:description}",
fun() ->
${4:ok}
end}.]]></content>
<tabTrigger>eunit</tabTrigger>
<scope>source.erlang</scope>
<description>EUnit Test Case</description>
</snippet>
@t-mw
t-mw / reload.bash
Created January 26, 2018 18:36
pico-8 live reload
while sleep 1; do
file='test';
lead='__lua__';
tail='__gfx__';
gsed -i -e "/$lead/,/$tail/{ /$lead/{p; r $file.lua
}; /$tail/p; d }" $file.p8;
done
#!/bin/bash
# see https://github.com/porglezomp-misc/live-reloading-rs/issues/1
set -e
name="libreloadable"
extension="dylib"
dir="./target/debug"
path="${dir}/${name}.${extension}"
@t-mw
t-mw / rust-ul-test.rs
Created October 5, 2019 08:41
rust-ul-test.rs
fn main() {
let config = ul::Config::new();
let mut ul_app = ul::UltralightApp::new(Some(config));
ul_app.window(1024u32, 1024u32, false, false, true, true, false);
let mut ul = ul::Ultralight::new(None, Some(ul_app.get_renderer()));
ul.set_view(ul_app.get_view().unwrap());
#!/bin/bash
# see https://github.com/porglezomp-misc/live-reloading-rs/issues/1
set -e
name="libreloadable"
extension="so"
dir="./target/debug"
path="${dir}/${name}.${extension}"
@t-mw
t-mw / script.gd
Last active May 4, 2020 17:52
Godot Engine AtlasTexture billboard shader
# NB: assumes an orthogonal camera and quad mesh geometry
fn _process(_delta) {
# set this to an instance of AtlasTexture
var atlas_tex = ...
# set this to an instance of Material
var material = ...
# optionally center the sprite around a point relative to the top-left corner
var center = Vector2(0, 0)