Skip to content

Instantly share code, notes, and snippets.

@mvasilkov
mvasilkov / bash jmp
Created February 21, 2015 15:30
Bash jmp script
function jmp { cd -P "$JMP_PATH/$1" 2>/dev/null || echo Not found; }
function setjmp { ln -s "`pwd`" "$JMP_PATH/$1"; }
function deljmp { rm -i "$JMP_PATH/$1"; }
export JMP_PATH="$HOME/.jmp"
import os
import sys
import io
import tarfile
import urllib.request
ARCHIVE_URL = 'http://d.pr/f/YqS5+'
# Tests for antialiasing a high-frequency image in various ways
# Nathan Reed, July 2014
# Written for Python 3.4; requires numpy and Pillow to be installed
import concurrent.futures
import math
import multiprocessing
import numpy as np
import optparse
import random
Collection of oneliner music formulas. Version 2011-10-18
I've tried to collect all the formulas in the related threads etc.
(excluding those that clearly sound like random first experiments or total
crap; when several variants are available, i've chosen the shortest one)
If you think I've missed something that should be here, please let me know.
====== 1ST ITERATION ======
@mvasilkov
mvasilkov / load.js
Created August 28, 2014 22:31
Image loader for canvas, suitable for JS13K
function load(images, done) {
var toLoad = images.length
var res = Array(toLoad)
var loaded = 0
images.forEach(function (url, i) {
var image = new Image
image.onload = function () {
res[i] = this
if (++loaded == toLoad)
@mvasilkov
mvasilkov / _sin.sjs
Created August 19, 2014 09:01
Math.sin macro
macro _sin {
case { _($x:lit) } =>
{
var res = Math.sin(unwrapSyntax(#{ $x }))
return [makeValue(res, #{ $x })]
}
case { _($x) } =>
{
return #{ Math.sin($x) }
function foo() {
this.a = function () { return 96 }
this.b = function () { return this.a() * 10101 }
}
function bar() {}
bar.prototype = new foo
b = new bar
b.a() // 96
# _ = empty
# X = solid ground
# S = sand
_________________
_____SSSSSS______
___SSSXXXXSSS____
____SSSXXXXSSS___
______SSSSSS_____
@mvasilkov
mvasilkov / remove_lines
Created November 18, 2013 05:12
Remove empty lines at the end of file.
#!/bin/bash
last_non_blank_ln=$(grep -En ^. $1 |tail -n 1 |sed 's/:.*//')
head -n $((last_non_blank_ln + 1)) $1 > _xxx
mv _xxx $1
(box2d-html5) -> git commit
[master e170981] There are two sides to every issue: one side is right and the other is wrong, but the middle is always evil.
120 files changed, 125 insertions(+), 125 deletions(-)
rename contrib/{Enhancements/Controllers/b2BuoyancyController.js => enhancements/controllers/buoyancycontroller.js} (100%)
rename contrib/{Enhancements/Controllers/b2ConstantAccelController.js => enhancements/controllers/constantaccelcontroller.js} (100%)
rename contrib/{Enhancements/Controllers/b2ConstantForceController.js => enhancements/controllers/constantforcecontroller.js} (100%)
rename contrib/{Enhancements/Controllers/b2Controller.js => enhancements/controllers/controller.js} (100%)
rename contrib/{Enhancements/Controllers/b2GravityController.js => enhancements/controllers/gravitycontroller.js} (100%)
rename contrib/{Enhancements/Controllers/b2TensorDampingController.js => enhancements/controllers/tensordampingcontroller.js} (100%)
rewrite contrib/paths.json (99%)