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
const src = `data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADYAAAAHCAAAAABmCOEJAAAACXBIWXMAAAsTAAALEwEAmpwYAAADGGlDQ1BQaG90b3Nob3AgSUNDIHByb2ZpbGUAAHjaY2BgnuDo4uTKJMDAUFBUUuQe5BgZERmlwH6egY2BmYGBgYGBITG5uMAxIMCHgYGBIS8/L5UBFTAyMHy7xsDIwMDAcFnX0cXJlYE0wJpcUFTCwMBwgIGBwSgltTiZgYHhCwMDQ3p5SUEJAwNjDAMDg0hSdkEJAwNjAQMDg0h2SJAzAwNjCwMDE09JakUJAwMDg3N+QWVRZnpGiYKhpaWlgmNKflKqQnBlcUlqbrGCZ15yflFBflFiSWoKAwMD1A4GBgYGXpf8EgX3xMw8BSMDVQYqg4jIKAUICxE+CDEESC4tKoMHJQODAIMCgwGDA0MAQyJDPcMChqMMbxjFGV0YSxlXMN5jEmMKYprAdIFZmDmSeSHzGxZLlg6WW6x6rK2s99gs2aaxfWMPZ9/NocTRxfGFM5HzApcj1xZuTe4FPFI8U3mFeCfxCfNN45fhXyygI7BD0FXwilCq0A/hXhEVkb2i4aJfxCaJG4lfkaiQlJM8JpUvLS19QqZMVl32llyfvIv8H4WtioVKekpvldeqFKiaqP5UO6jepRGqqaT5QeuA9iSdVF0rPUG9V/pHDBYY1hrFGNuayJsym740u2C+02KJ5QSrOutcmzjbQDtXe2sHY0cdJzVnJRcFV3k3BXdlD3VPXS8Tbxsfd99gvwT//ID6wIlBS4N3hVwMfRnOFCEXaRUVEV0RMzN2T9yDBLZE3aSw5IaUNak30zkyLDIzs+ZmX8xlz7PPryjYVPiuWLskq3RV2ZsK/cqSql01jLVedVPrHzbqNdU0n22VaytsP9op3VXUfbpXta+x/+5Em0mzJ/+dGj/t8AyNmf2zvs9JmHt6vvmCpYtEFrcu+bYsc/m9lSGrTq9xWbtvveW
function r() {
let mediaRecorder;
let recordedBlobs;
let startTime = 0;
function handleDataAvailable(event) {
console.log('on data available')
if (event.data && event.data.size > 0) {
recordedBlobs.push(event.data);
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<style>
.Easter {
egg: #17;
}
html, body {
background:#cccccc url(/wallpapers/cn.jpg) repeat left top;
background-size: 100%;
font: normal 12px tahoma, arial, verdana, sans-serif;
margin: 0;
@spite
spite / gist:12e458ea49be527e0691ed32bdc6d2b9
Created March 1, 2018 18:18
Capture canvas and download as WebP with quality
canvas.toBlob( e => {
const url = URL.createObjectURL(e);
const link = document.createElement('a');
link.setAttribute('href',url);
link.setAttribute('download','image.webp');
link.click();
console.log(url);},
'image/webp',
document.body.addEventListener('click', async e => {
if(e.srcElement && e.srcElement.classList.contains('irc_mi')) {
const downloadBtn = document.createElement( 'a' );
downloadBtn.setAttribute( 'target', '_blank' );
downloadBtn.setAttribute( 'href', e.srcElement.src );
downloadBtn.click();
e.preventDefault();
@spite
spite / Grid
Created January 17, 2017 02:12
function Block( x, y, w, h, d ) {
this.x = x;
this.y = y;
this.w = w;
this.h = h;
this.d = d;
this.children = [];
@spite
spite / gist:90e3dbf8e117660f6788a5748ae06cad
Last active December 30, 2016 09:20
Go to https://lines.chromeexperiments.com/drag/, start the experience and run this code in the console
document.getElementById( 'loading' ).style.display = 'none';
var speed = .001; // changes the rate of rotation
var distance = 4; // changes the distance the point travels
function _update() {
bAmDrawing = true;
lastMouseX = 0; lastMouseY = 0;
var a = speed * performance.now();
var x = distance * Math.cos( a );
var y = distance * Math.sin( a );
stage.mousemove( { data: { global : { x: x, y: y } } } )
var canvas = document.createElement( 'canvas' );
!! ( window.WebGLRenderingContext && ( canvas.getContext( 'webgl' ) || canvas.getContext( 'experimental-webgl' ) ) );
<html>
<head>
<title>Page Title</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script src="CCapture.all.min.js">
</script>
</head>
<body>
<div id="elementToShare" class="elementToShare">
@spite
spite / gist:00b3f17734810168093eb92a12815df3
Created May 13, 2016 14:16
Standard UV map (equirectangular 2:1) to mercator (1:1)
var geometry = new THREE.IcosahedronGeometry( 2, 5 );
for ( var i = 0, l = geometry.faceVertexUvs[ 0 ].length; i < l; i ++ ) {
for ( var j = 0, jl = geometry.faceVertexUvs[ 0 ][ i ].length; j < jl; j ++ ) {
var uv = geometry.faceVertexUvs[ 0 ][ i ][ j ];
var a = uv.y * Math.PI - Math.PI / 2;
a = Math.sin(a);