Skip to content

Instantly share code, notes, and snippets.

View etoxin's full-sized avatar

Adam Lusted etoxin

View GitHub Profile
@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>
@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>}
*/
// Prefix mixins
// -------------
// Example use:
// @include transition(transform 500ms, box-shadow 500ms);
@mixin transition ($values...) {
-webkit-transition: $values;
-ms-transition: $values;
transition: $values;
}
@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) =>
@etoxin
etoxin / Cache Images Then Callback
Created May 24, 2016 07:02
cacheImagesThenCallback
/**
* Pass an Array of image urls and it will run `callback` once they are cached.
*
* @example
cacheImagesThenCallback([image.jpg, picture.png], function() {
...
});
* @alias CORE.cacheImagesThenCallback
* @constructor
* @param imageSrcArray {array} Array of image urls.
@etoxin
etoxin / Apply.js
Last active May 10, 2016 00:24
Call, Apply, Bind
/**
* Using apply and built-in functions
*
* Clever usage of apply allows you to use built-ins functions for some tasks that otherwise probably would have been written by looping over the array values. As an example here we are going to use Math.max/Math.min to find out the maximum/minimum value in an array.
*/
// min/max number in an array
var numbers = [5, 6, 2, 3, 7];
// using Math.min/Math.max apply
@etoxin
etoxin / exampleModule.js
Last active June 24, 2016 06:52
Revealing Namespace Module Loader
/**
* project.exampleModule
* @namespace project.exampleModule
*/
(function (window, project, undefined) {
/**
* @constructor
* @public
* @memberof project.exampleModule
@etoxin
etoxin / http.js
Created February 24, 2016 00:41
json, ajax, xhr, http on node.js
var http = require("http");
http.get(weatherApi, function(res) {
var body = '';
// get chunks of data and add it to body
res.on('data', function(chunk){
body += chunk;
});
@etoxin
etoxin / val.js
Created February 22, 2016 02:18
Salesforce Password validation.
$.validator.addMethod("passwordCheck", function (value, element) {
return this.optional(element) || /((?=.*[a-z])(?=.*[A-Z])(?=.*[@#$%-_=+<>]).{8,30})/g.test(value);
}, "Field must contain only letters, numbers, or dashes.");
$.validator.addMethod("passwordCheck", function (value, element) {
return this.optional(element) || /((?=.*[a-z])(?=.*[A-Z])(?=.*[@#$%-_=+<>]).{8,30})/g.test(value);
}, "Field must contain only letters, numbers, or dashes.");