Skip to content

Instantly share code, notes, and snippets.

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

Hugo Wiledal wiledal

πŸ₯ƒ
View GitHub Profile
@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 / 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 / shake.js
Created March 14, 2015 21:56
Simple shake animation for TweenMax (gsap.js). For modern form error feedback.
function shakeAnimation(element){
TweenMax.to(element, .1, {
x: -7,
ease: Quad.easeInOut
});
TweenMax.to(element, .1, {
repeat: 4,
x: 7,
yoyo: true,
delay: .1,
@wiledal
wiledal / webcam-motion.coffee
Last active August 29, 2015 14:05
Webcam Motion Detection
class MotionDetection
@getDataPositionFromCoordinates = (width, x, y) ->
return x * 4 + y * (width * 4)
getCoordinatesFromPosition: (position) ->
return {
x: (position % @camCanvas.width) / @camCanvas.width
y: (Math.floor(position / @camCanvas.width)) / @camCanvas.height
}
@wiledal
wiledal / TransitionController.js
Last active August 29, 2015 14:05
Amazing Transition Controller
(function() {
window.AnimationController = {
enter: function(element, parent, callback) {
parent.append(element);
AnimationController.transition(element, "t-enter", "t-enter-active", function() {
if (callback) callback()
});
},
leave: function(element, callback) {
AnimationController.transition(element, "t-leave", "t-leave-active", function() {
@wiledal
wiledal / blend.js
Created July 29, 2014 17:03
Blend two hexes
function blendHex(hex1, hex2, steps) {
var rgb1 = {
r: parseInt(hex1.slice(1,3), 16),
b: parseInt(hex1.slice(3,5), 16),
g: parseInt(hex1.slice(5,7), 16)
}
var rgb2 = {
r: parseInt(hex2.slice(1,3), 16),
b: parseInt(hex2.slice(3,5), 16),
g: parseInt(hex2.slice(5,7), 16)
@wiledal
wiledal / RandomColor
Last active August 29, 2015 14:04
Random Color
return "#" + ("000000" + (Math.random()*(1<<24)|0).toString(16)).slice(-6)
@wiledal
wiledal / normalizeScroll.js
Created March 6, 2014 15:57
Normalize scroll
// Provide "originalEvent" of DOMMouseScroll and mousewheel
var o = event;
var d = o.detail;
var w = o.wheelDelta || o.deltaY;
var n = 225;
var n1 = n - 1;
var d = (d ? (w && (f = w / d) ? d / f : -d / 1.35) : w / 120);
var d = (d < 1 ? (d < -1 ? (-Math.pow(d, 2) - n1) / n : d) : (Math.pow(d, 2) + n1) / n);
@wiledal
wiledal / nicedatefromtimestamp.js
Created November 8, 2013 10:07
Gives you a nice date sentence from a timestamp
function getNiceDateFromTimestamp(timestamp) {
var splits = {
"second": [60 * 1000, 1000],
"minute": [60 * 60 * 1000, 60 * 1000],
"hour": [24 * 60 * 60 * 1000, 60 * 60 * 1000],
"day": [7 * 24 * 60 * 60 * 1000, 24 * 60 * 60 * 1000],
"week": [4 * 7 * 24 * 60 * 60 * 1000, 7 * 24 * 60 * 60 * 1000],
"month": [12 * 4 * 7 * 24 * 60 * 60 * 1000, 4 * 7 * 24 * 60 * 60 * 1000],
"year": [-1, 12 * 4 * 7 * 24 * 60 * 60 * 1000]
}
@wiledal
wiledal / automountvboxsf.sh
Created September 24, 2013 08:21
Set up auto mount for folders shared in VirtualBox with one command line. Replace <SHARED FOLDER> with the folder which is shared.
sudo touch /etc/init.d/mountdisks.sh; sudo sh -c 'echo "mount -t vboxsf <SHARED FOLDER> /var/www" > /etc/init.d/mountdisks.sh'; sudo chmod +x /etc/init.d/mountdisks.sh; sudo ln -s /etc/init.d/mountdisks.sh /etc/rc5.d/S20mountdisks.sh; sudo ln -s /etc/init.d/mountdisks.sh /etc/rc2.d/S20mountdisks.sh;