Skip to content

Instantly share code, notes, and snippets.

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

Hugo Wiledal wiledal

πŸ₯ƒ
View GitHub Profile
@wiledal
wiledal / TinySlider.js
Created June 10, 2015 19:05
tinyslider wip
function TinySlider(element) {
this.element = element;
this.currentSlide = 0;
this.slides = element.querySelectorAll(".slide");
this.slidesContainer = document.createElement("div");
this.applyStyles(this.slidesContainer, {
position: "absolute",
top: 0,
@wiledal
wiledal / __flightplan_deployments.md
Last active December 21, 2017 16:46
Set up your local machine and remote machine for quick deployments with Flightplan

Deploying

For easy deployments we're using flightplan, install with npm install -g flightplan.

Before deploying you need to make your computer a friend to the server.
You only need to do these steps once per machine.

We are going to be adding your public key to the remote server for passwordless SSH.
Then we are going to set up your SSH to allow for Agent Forwarding, so that your git commands are tunneled to the server.

When a step says Locally it means you should execute the command on your local machine.

@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++) {
@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 / 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-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-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>
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 / 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:
@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')