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 / 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 / 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;
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);
}
{
"layers": [
{
"name": "canvas",
"type": "canvas",
"canvasLayers": [
{
"props": {
"active": {
"type": "boolean",
{
"layers": [
{
"active": true,
"mixBlendMode": "normal",
"name": "no-signal",
"opacity": 100,
"rotateX": 0,
"rotateY": 0,
"rotateZ": 0,
@zeropaper
zeropaper / index.html
Last active January 12, 2017 16:10
Visual Fiha canvas layer boilerplate
<canvas id="canvas" width="400" height="300"></canvas>
signals:
colorA:
type: hsla
defaultValue: 1
input: null
hue: 180
saturation: 50
lightness: 50
alpha: 100
beatA:
signals:
colorA:
type: hsla
defaultValue: '180,50%,50%,1'
input: null
hue: 180
saturation: 50
lightness: 50
alpha: 100
beatA:
signals:
colorA:
type: hsla
defaultValue: '180,50%,50%,1'
input: null
hue: 180
saturation: 50
lightness: 50
alpha: 100
beatA:
@zeropaper
zeropaper / snippet.php
Created March 19, 2018 08:21
Drupal 8 generate style derivative image
// can be runned from the Devel execute PHP page
use Drupal\image\Entity\ImageStyle;
$path = 'public://2018-03/26756519_10155441271337695_6783993404862700965_o.jpg';
$thumbnail = ImageStyle::load('article');
dpm($thumbnail->buildUrl($path));
$dest = $thumbnail->buildUri($path);
dpm($dest);
$created = $thumbnail->createDerivative($path, $dest);