Skip to content

Instantly share code, notes, and snippets.

View jussi-kalliokoski's full-sized avatar

Jussi Kalliokoski jussi-kalliokoski

View GitHub Profile
@jussi-kalliokoski
jussi-kalliokoski / nan.js
Created March 27, 2013 06:39
Some NaN stuff
/*jshint asi:true */
var print = typeof console === 'undefined' ? print : console.log.bind(console)
var whatnan = function (narray) {
return [].map.call(new Uint8Array(narray.buffer), function (n) {
return (n < 16 ? '0' : '') + n.toString(16)
}).join('')
}
var printnan = function (nan) {
@jussi-kalliokoski
jussi-kalliokoski / dispose.js
Created February 25, 2013 20:44
A polyfill for ArrayBuffer#dispose
void function () {
if ( 'dispose' in ArrayBuffer.prototype ) return
var blob = new Blob([''], {
type: 'text/javascript'
})
var url = URL.createObjectURL(blob)
var worker = new Worker(url)
URL.revokeObjectURL(url)
@jussi-kalliokoski
jussi-kalliokoski / git-pick-file.sh
Last active July 11, 2022 10:08
Cherry-picks commits from master that have changes to specified files.
$!/usr/bin/env sh
branch=`git symbolic-ref --short HEAD`
git checkout master
commits=`git log --pretty="%H" --reverse -- $*`
git checkout $branch
for commit in $commits; do
git cherry-pick $commit
done
@jussi-kalliokoski
jussi-kalliokoski / bugzilla-to-github.coffee
Created December 25, 2012 21:54
A script to export bugzilla's bugs to github's issues.
request = require 'request'
Restzilla = require 'restzilla'
BUGZILLA_URL = 'https://www.w3.org/Bugs/Public/'
BURL = 'http://localhost:8000/AudioWG/MIDI%20API/'
GH_USER = 'jussi-kalliokoski'
GH_REPO = 'webmidi-issues'
GH_URL = 'https://api.github.com/repos/' + GH_USER + '/' + GH_REPO + '/issues'
GH_AUTH =
username: 'octocat'
@jussi-kalliokoski
jussi-kalliokoski / demo.html
Created October 8, 2012 17:00
A `position: pointer` demonstration
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<style>
.tooltip {
position: pointer;
left: 10px;
top: 10px;
width: auto;
@jussi-kalliokoski
jussi-kalliokoski / index.html
Created September 24, 2012 12:25
Function#fork parallel shading
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head>
<body>
<script>
Function.prototype.fork = function (cb, thisArg) {
var args = [].slice.call(arguments, 2)
var fn = this
function memcpy (src, srcOffset, dst, dstOffset, length) {
var i
src = src.subarray || src.slice ? src : src.buffer
dst = dst.subarray || dst.slice ? dst : dst.buffer
src = srcOffset ? src.subarray ?
src.subarray(srcOffset, length && srcOffset + length) :
src.slice(srcOffset, length && srcOffset + length) : src
@jussi-kalliokoski
jussi-kalliokoski / after.js
Created July 1, 2012 08:50
The power of JS macros
function wat (
outputBuffer, outputOffset, outputStride,
inputBuffer, inputOffset, inputStride,
a, b, c, d
) {
var o, i, s
i = (inputOffset) || 0
inputStride = inputStride || 1
@jussi-kalliokoski
jussi-kalliokoski / shade.js
Created May 13, 2012 19:08
Parallel fragment shaders in JavaScript using Workers. Not very optimized, but works. Hard to find the perfect SHADER_COUNT for a certain dimension. Usually it's less the shaders the better.
/*jshint asi:true, esnext:true */
void function () {
const SHADER_COUNT = 8
const WIDTH = 800
const HEIGHT = 800
var rAF =
window.requestAnimationFrame ||
window.webkitRequestAnimationFrame ||
@jussi-kalliokoski
jussi-kalliokoski / is-image.js
Created April 20, 2012 07:39
Detects whether an url is an image
function isImage (url, callback) {
function cleanup () {
delete img.onload;
delete img.onerror;
img = null;
}
var img = new Image();
img.onload = function () {