Skip to content

Instantly share code, notes, and snippets.

View etoxin's full-sized avatar

Adam Lusted etoxin

View GitHub Profile
@etoxin
etoxin / random.js
Created May 31, 2016 03:48
Random Functions
// True or False
const trueOrFalse = () =>
Boolean(Math.random() > .5)
// Random Float
const randomFloat = (min, max) =>
Math.random() * (max - min) + min
// Random Number
const randomNumber = (min, max) =>
// Prefix mixins
// -------------
// Example use:
// @include transition(transform 500ms, box-shadow 500ms);
@mixin transition ($values...) {
-webkit-transition: $values;
-ms-transition: $values;
transition: $values;
}
@etoxin
etoxin / getLocation.js
Last active May 16, 2018 11:22
Promise Example
/**
* @example
*
* import {getLocation} from './services/getLocation';
* getLocation().then(res => {
* console.log(res);
* });
*
* @returns {Promise<any>}
*/
@etoxin
etoxin / responsive-video-html
Created June 6, 2016 02:07
Responsive Video
<div class="video-wrapper">
<iframe width="560" height="315" src="https://www.youtube.com/embed/jEnd8JIMii4?rel=0&amp;controls=0&amp;showinfo=0" frameborder="0" allowfullscreen></iframe>
</div>
.parallax-window {
max-height: 30em;
overflow: hidden;
position: relative;
text-align: center;
width: 100%;
}
.parallax-static-content {
color: #9A9A8A;
<h1 class="test">Responsive: </h1>
@etoxin
etoxin / UniqueID.js
Created June 16, 2016 02:03
Make a Unique ID
/**
* @param l {Number} Length of random string.
* @returns {string} String of random numbers
* @constructor
*/
function MakeId(l) {
var text = "",
possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
for (var i = 0; i < l; i++)
text += possible.charAt(Math.floor(Math.random() * possible.length));
function debounce(fn, wait, immediate) {
var timeout;
return function() {
var context = this, args = arguments;
var later = function() {
timeout = null;
if (!immediate) func.apply(context, args);
};
var callNow = immediate && !timeout;
clearTimeout(timeout);
/**
* JS Throttle Function
* @example
$('body').on('mousemove', throttle(function (event) {
console.log('tick');
}, 1000));
*
* @param fn {Function} callback function
* @param threshhold {Number} Threshold in milliseconds
* @param scope {object} Scope to pass into function.
function parallax() {
window.onscroll = function() {
var speed = 5.0;
document.body.style.backgroundPosition = (-window.pageXOffset/speed)+"px "+(-window.pageYOffset/speed)+"px";
}
}