Skip to content

Instantly share code, notes, and snippets.

View ourmaninamsterdam's full-sized avatar

Justin Perry ourmaninamsterdam

View GitHub Profile
@ourmaninamsterdam
ourmaninamsterdam / check.js
Last active August 29, 2015 14:08
Check if element is within viewport
Popover.prototype.isOverlappingViewport = function($el) {
return this.getElementBoundaries($el).top < 0? true : false ||
this.getElementBoundaries($el).bottom > $('body').height()? true : false ||
this.getElementBoundaries($el).left < 0? true : false ||
this.getElementBoundaries($el).right > $('body').width()? true : false;
};
def is_active?(path)
!!request.url.match(option[:path]) ? " is-active" : ""
end
@ourmaninamsterdam
ourmaninamsterdam / SassMeister-input.scss
Last active August 29, 2015 14:11
Generated by SassMeister.com.
// ----
// Sass (v3.4.9)
// Compass (v1.0.1)
// ----
@mixin property($property, $multiple) {
@supports($property: 1rem){
#{$property}: ($multiple / $base-font-size) * 1rem;
};
#{$property}: $multiple * 1px;
function getFunctionName (fn) {
return fn.toString().substr(0, fn.toString().indexOf('(')).replace('function ', '');
}
@ourmaninamsterdam
ourmaninamsterdam / 1-cms_components.md
Last active August 29, 2015 14:16
Overview of CMS components

CMS Components

JavaScript

Displays characters remaining from a given total. Used with form inputs. Adds classes when active/above/below/equal the total character allowance.

Tests [y] Accessibility tested [n]

@ourmaninamsterdam
ourmaninamsterdam / gist:4555503
Last active December 11, 2015 05:58
Finds and removes item from array
/**
* remove_from_array()
* Based on str param supplied, finds and removes matching item from array
* @param {Array} array Array to query
* @param {String} str String to look for
* @return {Bool} returns true after item is found and remove from array
*/
function remove_from_array(array, str) {
var i;
for(i = 0; i < array.length; i++){
@ourmaninamsterdam
ourmaninamsterdam / gist:4555610
Created January 17, 2013 12:27
Returns an array of values from a JSON array
/**
* get_keys()
* @param {Array} data JSON array
* @param {String} label Value to return
* @return {Array} array of matched property
*/
function get_keys(data, label) {
var key, values = [];
for(key in data){
values.push(data[key][label]);
@ourmaninamsterdam
ourmaninamsterdam / index.html
Last active December 11, 2015 07:09
**BETA**. jQuery plugin to independently animate elements using their data attributes used for animation properties.
<!DOCTYPE html>
<html lang="en-gb">
<head>
<title>Animator</title>
<meta charset="utf-8" />
<style>
.block{
background: #ccc;
box-sizing: border-box;
height: 100px;
@ourmaninamsterdam
ourmaninamsterdam / gist:5232000
Created March 24, 2013 13:37
Get computed style of elements and pseudo elements
function getComputedStyle(elem, property, pseudoelem){
return window.getComputedStyle(elem, (pseudoelem || null)).getPropertyValue(property);
};
getComputedStyle(myElem, "height").width;
getComputedStyle(myElem, "height", ":after").width;
@ourmaninamsterdam
ourmaninamsterdam / gist:5319295
Created April 5, 2013 13:32
Dustin Diaz object string supplanter
function substitute(s, o){
return s.replace( /{([^{}]*)}/g ,
function (a, b) {
var r = o[b];
return typeof r === 'string' || typeof r === 'number' ? r : a;
}
);
}
substitute("My name is {name} and I work at {workplace}",{
name: "Justin Perry",