Skip to content

Instantly share code, notes, and snippets.

@Kuzcoo
Kuzcoo / LICENSE.txt
Last active February 13, 2017 17:20 — forked from 140bytes/LICENSE.txt
140byt.es -- Click ↑↑ fork ↑↑ to play!
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2015 Thomas Gérard <YOUR_URL_HERE>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
@Kuzcoo
Kuzcoo / README.md
Last active December 11, 2015 16:27
Snippets to play with

Snippet

On this site, on the music part you can listen a track maintaining your click on it. Below some snippets to play with this opportunity. :-)

edit : actually it may not be intended, it works with Safari.

@Kuzcoo
Kuzcoo / iframes.js
Created March 3, 2016 20:34
Full width iframes (for example, videos)
(function () {
let ratios = [];
let resizeIframes = function (iframes, ratio) {
let winW = window.innerWidth;
iframes.forEach( (iframe,i) => {
let [w, h] = [iframe.clientWidth, iframe.clientHeight],
_ratio = ratio && ratio[i] || h/w;
// set iframe size
iframe.style.height = winW*_ratio+'px';
let debounce = function (eventName, time, fn) {
// locker
let locker = function () {
let isLocked = false;
let unlock = function (boolLock, fn) {
setTimeout(function () {
isLocked = false;
fn();
},time);
};
(function () {
[].slice.call(document.querySelectorAll('span.read-more'))
.forEach(function (el, i) {
el.onclick = function (e) {
if (e.target.classList.contains('read-less')) { return; }
var content = this.querySelector('span.read-more-content');
var text = this.childNodes[0];
text.textContent = '';
@Kuzcoo
Kuzcoo / vector.js
Last active November 18, 2016 14:20
class Vector {
constructor(x,y) {
this.x = x;
this.y = y;
}
static add (v1,v2) {
return new Vector(v1.xv2.x,v1.y+v2.y);
}
@Kuzcoo
Kuzcoo / z.js
Created December 4, 2016 21:29
let setSize = function (w,h=w) {
this.width = w;
this.height = h;
};
let createCanvas = (w,h) => {
let canvas = document.createElement('canvas');
if (w) {
setSize.call(canvas,w,h);
}
Array.prototype.findHalf = function () {
return Math.floor(this.length/2);
};
Array.prototype.isEmpty = function () {
return this.length === 0;
};
Array.prototype.first = function () {
return this[0];
@Kuzcoo
Kuzcoo / 99lisp.clj
Last active December 11, 2016 20:04
(defn my-last [a]
"P01 - find the last box of a list"
((fn my-last-recur [b c]
(if (empty? c)
b
(my-last-recur (first c) (rest c))
))
(first a)
(rest a))
)
@Kuzcoo
Kuzcoo / haiku.js
Last active December 14, 2016 20:21
Array.prototype.pickRand = function () {
return this[Math.floor(Math.random()*this.length)];
};
// grammar from Daniel Howe
// http://rednoise.org/rita/examples/p5js/HaikuGrammar/#source2
let grammar = {
"start": "<5L> <7L> <5L>",
"<5L>": "<1> <4>|<1> <3> <1>|<1> <1> <3>|<1> <2> <2>|<1> <2> <1> <1>|<1> <1> <2> <1>|<1> <1> <1> <2>|<1> <1> <1> <1> <1>|<2> <3>|<2> <2> <1>|<2> <1> <2>|<2> <1> <1> <1>|<3> <2>|<3> <1> <1>|<4> <1>|<5>",