Skip to content

Instantly share code, notes, and snippets.

View usefulthink's full-sized avatar

Martin Schuhfuss usefulthink

  • Hamburg / Germany
  • 14:02 (UTC +02:00)
View GitHub Profile
@usefulthink
usefulthink / cache.js
Created August 16, 2013 11:14
an async general-purpose caching implementation that can be wrapped around arbitrary async functions.
module.exports = cache;
/**
* creates a cache around the given async function.
*
* @example
* function waitAndResolve(time, value, callback) {
* setTimeout(function() {
* callback(null, value);
* }, time);
var fs=require('fs'),
Canvas = require('Canvas');
/**
* algorithm impudently stolen from http://www.noisetexturegenerator.com/
*/
var generateNoise = function(width, height, opacity, density) {
var canvas = new Canvas(width, height),
ctx = canvas.getContext('2d');
@usefulthink
usefulthink / minimal-webaudio.js
Created March 11, 2013 21:30
simplistic demo for using the audioContext of the webaudio-api
var audioContext = new webkitAudioContext(),
osc1 = audioContext.createOscillator(),
osc2 = audioContext.createOscillator();
osc1.frequency.value = 440; // Hz
osc2.frequency.value = 220; // one octave down
osc1.connect(audioContext.destination);
osc2.connect(audioContext.destination);
@usefulthink
usefulthink / carousel.html
Created March 9, 2013 15:48
A really simple carousel built without using javascript for animations… The according Javascript only needs to reassign the classes accordingly (NOTE: this code should just demonstrate how one could built such a carousel, the code itself isn't tested)
@usefulthink
usefulthink / example1.js
Created March 9, 2013 15:19
Code-Sample for workshops on rendering performance
// DISCLAIMER: errors and worst-practice examples are fully intentional
// our starting-point
(function($, window) {
'use strict';
$(document).on('mousemove', function(ev) {
$('.follow').css('left', ev.pageX - $('.follow').width()/2);
$('.follow').css('top', ev.pageY - $('.follow').height()/2);
});
// ==UserScript==
// @id ingress-intel-total-conversion@breunigs
// @name intel map total conversion
// @version 0.6-2013-02-21-171155
// @namespace https://github.com/breunigs/ingress-intel-total-conversion
// @updateURL https://raw.github.com/breunigs/ingress-intel-total-conversion/gh-pages/dist/total-conversion-build.user.js
// @downloadURL https://raw.github.com/breunigs/ingress-intel-total-conversion/gh-pages/dist/total-conversion-build.user.js
// @description total conversion for the ingress intel map.
// @include http://www.ingress.com/intel*
// @match http://www.ingress.com/intel*
.slide-container {
@include transform-style(preserve-3d);
@include perspective(2000px);
.slide {
opacity: 0;
@include transition(transform 800ms, opacity 800ms);
&.current { opacity: 1; @include transform(rotateY(0deg)); }
&.left { @include transform(rotateY(-90deg) translateZ(800px)); }
@usefulthink
usefulthink / dabblet.css
Created October 27, 2012 21:50
content-box shadows part II
/**
* content-box shadows part II
*/
body {
background-color: #666; }
.container {
width: 80%; height: 800px;
border-radius: 20px;
box-shadow: 0 0 20px 0 black;
@usefulthink
usefulthink / dabblet.css
Created October 27, 2012 15:16
content-box shadows part II
/**
* content-box shadows part II
*/
body {
background-color: #666; }
.container {
width: 80%; height: 800px;
border-radius: 20px;
box-shadow: 0 0 20px 0 black;
@usefulthink
usefulthink / dabblet.css
Created October 27, 2012 15:15
content-box shadows part I
/**
* content-box shadows part I
*/
body {
background-color: #666; }
.container {
width: 80%; height: 800px;
border-radius: 50px;
overflow: hidden;