Skip to content

Instantly share code, notes, and snippets.

View wiledal's full-sized avatar
πŸ₯ƒ

Hugo Wiledal wiledal

πŸ₯ƒ
View GitHub Profile
@wiledal
wiledal / tools.js
Last active August 3, 2018 13:52
Deployment Tools
#!/usr/bin/env node
const spawn = require('child_process').spawn
const argv = process.argv
const servers = {
internal: [
{
user: 'root',
host: 'your internal setup',
@wiledal
wiledal / process.sh
Created May 4, 2017 14:40
Batch process images
for i in *.png; do ffmpeg -i $i -vf scale=500:500 $i -y; done
@wiledal
wiledal / mixin-scale-value.scss
Last active September 28, 2017 12:12
Creates media rules based on proportional scaling, with clamping to nearest to avoid half-pixels and keep baseline intact
/**
scale-value
Creates @media rules to scale a value between two values based on screen sizes
$value-s will be active on the smallest screen and below
$value-l will be active on the largest screen and above
$clamp-to-nearest determines the steps of scaling
(eg. "1" = round to closest whole value, "4" = round to closest number devisable by 4)
@param $value-name The value that will be changes (eg. 'font-size' or 'padding-bottom')
@wiledal
wiledal / animate-advanced.js
Last active March 19, 2025 05:26
Tiny GSAP-style CSS animation library
/*
Tiny, smart, single-method animation library for CSS animations - TweenMax-style.
Returns a Promise that resolves when the transition has ended.
Usage:
Single element:
AnimationService.animate(element, time, to)
AnimationService.animate(element, time, from, to)
Multiple elements with stagger:
var gulp = require('gulp')
var babel = require('gulp-babel')
var replace = require('gulp-replace')
gulp.task('js', () => {
gulp.src('source/js/**/*.js')
.pipe(replace('html`', '`')) // Replace 'html`' with just '`'
.pipe(babel({
presets: ['es2015']
})
@wiledal
wiledal / template-literals-basics.js
Last active February 4, 2021 18:08
Basic Template literals
var copy = {
title: 'Discovering Template Literals',
subtitle: 'Effortless client-side rendering awaits.',
body: 'You will never want to go back to normal strings again.'
}
var element = document.createElement('section')
element.innerHTML = `
<div class="content">
<h1>${copy.title}</h1>
@wiledal
wiledal / template-literals-2-for-each.js
Last active March 9, 2023 20:57
Template Literals example: for each
/*
Template literals forEach example
Using Array.map(), we can create a forEach within template literals.
*/
var items = [
{ name: 'Teddy' },
{ name: 'Dolores' },
{ name: 'William' },
{ name: 'Bernard' }
@wiledal
wiledal / template-literals-3-for-loops.js
Last active January 1, 2025 06:18
Template Literals example: For loops
/*
Template literals for-loop example
Using `Array(5).join(0).split(0)`, we create an empty array
with 5 items which we can iterate through using `.map()`
*/
var element = document.createElement('div')
element.innerHTML = `
<h1>This element is looping</h1>
${Array(5).join(0).split(0).map((item, i) => `
@wiledal
wiledal / template-literals-1-if-statements.js
Last active May 4, 2022 14:18
Template Literal Examples: if-statement
/*
Template literals if-statement example
Using a single-line conditional, we can create an if-statements within template literals.
*/
function makeHTML(title) {
return `
${title ? `
This element has a title, and it is "${title}"
` : `
@wiledal
wiledal / eventdispatcher.js
Last active May 12, 2016 09:12
The basicest eventdispatcher
function EventDispatcher() {
this._listeners = {};
}
EventDispatcher.prototype.on = function(event, callback) {
if (!this._listeners[event]) this._listeners[event] = [];
this._listeners[event].push(callback);
}
EventDispatcher.prototype.trigger = function(event, data) {
if (!this._listeners[event]) return;
for (var i = 0; i < this._listeners[event].length; i++) {