Skip to content

Instantly share code, notes, and snippets.

View spite's full-sized avatar
📦
i'm a smaller box

Jaume Sanchez spite

📦
i'm a smaller box
View GitHub Profile
@spite
spite / gist:8835249
Last active August 29, 2015 13:56
AudioContext playback without preloading
/*
Demo here: http://www.clicktorelease.com/tmp/fastload/
The MP3 file is 5.2MB
*/
/*
For some reason, probably because the spec has changed since the article
"Getting Started with Web Audio API" in http://www.html5rocks.com/en/tutorials/webaudio/intro/
was published, the most common way of loading a file sound is something like:
*/
@spite
spite / 0_reuse_code.js
Created February 11, 2014 14:40
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
<!doctype html>
<html lang="en">
<head>
<title>Wagner - Minefield!</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
<style>
body {
color: #ffffff;
font-family: 'roboto condensed', tahoma;
function exportZipToSketchfab( zip ) {
setLoadingText( 'Uploading...' );
showLoading( true );
var fd = new FormData();
fd.append('token', settings.sketchfabToken );
fd.append('fileModel', zip );
@spite
spite / gist:11328874
Last active August 29, 2015 14:00
Will You Drown: The Movie (http://game.notch.net/drowning/#)
function f() { var a = [].slice.apply( document.querySelectorAll( 'a' ) ); a.forEach( function( e ) { e.click(); } ) }
var s = setInterval( f, 100 )
var ctx1 = document.getElementById( 'color-1' ).getContext( '2d' ),
ctx2 = document.getElementById( 'color-2' ).getContext( '2d' );
function simulateClick( target ) {
var evt = document.createEvent("Events");
evt.initEvent("click", true, true);
target.dispatchEvent(evt);
}
setInterval( function() {
@spite
spite / gist:c5527fcc07429ca0b044
Created October 26, 2014 17:49
THREE.DecalGeometry loading OBJ file
<!doctype html>
<html lang="en">
<head>
<title>Decal Splatter</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
<style>
*{ box-sizing: border-box; margin: 0; padding: 0 }
body {
color: #888;
@spite
spite / sugarifyNew
Last active August 29, 2015 14:15
Makes creating canvas, audio, video and other HTML elements less verbose
( function() {
function sugarifyNew( id ) {
var name = id + '';
var fnName = name.charAt( 0 ).toUpperCase() + name.substr( 1 );
window[ fnName ] = function() {
return document.createElement( id );
}
@spite
spite / gist:044e89f7f42ddfaaab65
Created April 2, 2015 09:12
Like tears in the rain
(function() {
var b = document.body;
document.addEventListener(
'touchstart', function(evt) {
var o = parseFloat( getComputedStyle( b, null ).getPropertyValue( 'opacity' ) );
b.style.opacity = o - .005;
}
);
} )();
@spite
spite / gist:10ff99d4f85a87abad7f
Last active August 29, 2015 14:19
Converting a video captured with Quicktime to GIF (for posting to twitter)
ffmpeg -i input2.mov -vf "setpts=(1/2)*PTS" output.mov
ffmpeg -ss 00:00:00.000 -i output.mov -pix_fmt rgb24 -vf scale=506:-1 -r 10 output.gif