Skip to content

Instantly share code, notes, and snippets.

View zeropaper's full-sized avatar
💅
I may be slow to respond.

Valentin Vago zeropaper

💅
I may be slow to respond.
View GitHub Profile
@zeropaper
zeropaper / index.html
Last active January 12, 2017 16:10
Visual Fiha canvas layer boilerplate
<canvas id="canvas" width="400" height="300"></canvas>
{
"layers": [
{
"active": true,
"mixBlendMode": "normal",
"name": "no-signal",
"opacity": 100,
"rotateX": 0,
"rotateY": 0,
"rotateZ": 0,
{
"layers": [
{
"name": "canvas",
"type": "canvas",
"canvasLayers": [
{
"props": {
"active": {
"type": "boolean",
function sharedStart(array) {
var A= array.concat().sort(),
a1= A[0], a2= A[A.length-1], L= a1.length, i= 0;
while(i<L && a1.charAt(i)=== a2.charAt(i)) i++;
return a1.substring(0, i);
}
@zeropaper
zeropaper / sparkline.js
Created August 9, 2016 06:37
A very tiny sparkline chart
/**
* var sparkline = new Sparkline([10,20,45,12], 120, 30, '#000', 'red');
* document.body.appendChild(sprakline.render().canvas);
*/
function Sparkline(data, width, height, lineColor, dotColor) {
this.canvas = document.createElement('canvas');
this.canvas.width = width;
this.canvas.height = height;
this.lineColor = lineColor;
@zeropaper
zeropaper / ie-detection.js
Created October 27, 2014 13:03
The sales guys at MS pretend it's not needed anymore they probably never wrote a line of CSS... :(
// Inspired by http://jsfiddle.net/evildonald/jLuF5/
function detectIE() {
var $ = window.$ || window.jQuery || angular.element;
var s = document.body.style;
var version;
if (s.msTextCombineHorizontal !== undefined) {
version = 11;
}
else if (s.msFlexOrder !== undefined) {
@zeropaper
zeropaper / asyncSeries
Created September 9, 2014 10:53
the async.series function, unleashed
// borrowed from async.js because I dislike promises (very much)
// https://github.com/caolan/async/blob/master/lib/async.js
function _eachSeries(arr, iterator, callback) {
callback = callback || function () {};
if (!arr.length) {
return callback();
}
var completed = 0;
var iterate = function () {
@zeropaper
zeropaper / camunda-webapp.sublime-project
Last active August 29, 2015 14:03
SublimeText project for working on camunda BPM webapp (clone the repositories in the same folder as this file)
{
"folders":
[
{
"name": "SDK",
"path": "camunda-bpm-sdk-js",
"folder_exclude_patterns": [
"dist",
"example",
"doc",
@zeropaper
zeropaper / paginator.js
Created August 14, 2013 12:42
Quickly improved paginator (for Backbone PageableCollection). The active page stays the one in the middle of the pages list. The relevant part is the "makeHandles" method
/*jslint indent: 2*/
/*global define*/
'use strict';
define([
'backbone',
'underscore',
'backgrid-paginator'
], function(Backbone, _){
var ISIE = $('html').hasClass('lt-ie9');
@zeropaper
zeropaper / console.js
Created July 23, 2013 10:06
Ensure a console object with the following methods: - info - log - error - debug - trace - group - groupEnd - warn
var console = {};
var methods = 'info log error debug trace group groupEnd warn'.split(' ');
for (var m in methods) {
if (typeof console[methods[m]] !== 'function') {
console[methods[m]] = function(){};
}
}
window.console = console;