Skip to content

Instantly share code, notes, and snippets.

View ourmaninamsterdam's full-sized avatar

Justin Perry ourmaninamsterdam

View GitHub Profile
@ourmaninamsterdam
ourmaninamsterdam / gist:5388493
Last active December 16, 2015 05:59
Lookup table-like mixin for retrieving data from a linked list. Ideal for including predefined font stacks and media queries, by name. Great way to avoid lengthy conditional statements when you require multiple outcomes from a mixin.
@function get-item-by-name( $name, $names-list, $items ){
@return #{ nth( $items, index( $names-list, $name ) ) };
}
$font-stack-ids: proxima-light, proxima-regular, proxima-semibold
$font-stacks: "'Proxima Nova Light', Tahoma, Arial, Helvetica, sans-serif",
"'Proxima Nova Regular', Tahoma, Arial, Helvetica, sans-serif",
"'Proxima Nova Semibold', Tahoma, Arial, Helvetica, sans-serif";
@function font-stack( $name ){
@ourmaninamsterdam
ourmaninamsterdam / gist:5823736
Created June 20, 2013 15:26
Gets the href from anchor tag regardless of positon of href attr. Sort of. Needs some work to exclude last part of string
<a[^>]*? (href=\")(.*)(")
@ourmaninamsterdam
ourmaninamsterdam / gist:5964521
Created July 10, 2013 08:39
Converts a HEX to RGB and vice versa. Takes a 6 character HEX or a single R/G/B value.
/**
* convert_color()
* Converts a HEX to RGB and vice versa
* @param {String or Integer} color Takes a full 6 character HEX "ff5500" / RGB colour value 167 (< 255)
* @return {str} returns a HEX or RGB (space delimited), depending on input
*
*/
function convert_color(color) {
var tmp = "";
@ourmaninamsterdam
ourmaninamsterdam / gist:6074635
Created July 24, 2013 21:17
RegEx to get the value from an MS CSS filter
^filter:.[a-z]+=\([^)]+\);
@ourmaninamsterdam
ourmaninamsterdam / gist:6074735
Created July 24, 2013 21:27
RegEx for filtering href attr
(^<[^a-z]+|)+(href=\".+?")
Returns href attr from...
<a href="http://www.google.com">Google</a>
<a class="myclass" href="http://www.bbc.co.uk">BBC</a>
<a id="myid" href="http://www.yahoo.com" class="myclass">Yahoo</a>
<div><a href="http://www.google.com">Google</a></div>
@ourmaninamsterdam
ourmaninamsterdam / gist:6074841
Created July 24, 2013 21:43
In progress. Gets innerText from any tag
(^<[a-z]+.)[a-z\"=\s:/.\<]+[>]+([^\<]+)
<a href="http://www.google.com">Google</a>
<a class="myclass" href="http://www.bbc.co.uk">BBC</a>
<a id="myid" href="http://www.yahoo.com" class="myclass">Yahoo</a>
<div><a href="http://www.google.com">Google</a></div>
@ourmaninamsterdam
ourmaninamsterdam / gist:6074905
Created July 24, 2013 21:50
RegEx - Gets any Link that contains the word Yahoo. Needs some work
(^<[a-z]+.[a-z\"=\s:/.\<]+[>])+(?=[^\<])(?=Yahoo).+?$
@ourmaninamsterdam
ourmaninamsterdam / gist:6079009
Created July 25, 2013 12:01
jQuery waypoints
Setup waypoints for each block
$('.js-block').each(function(){
addWaypoint( $(this), 'down' );
addWaypoint( $(this), 'up' );
});
function addWaypoint( $elem, direction ){
var thisID = that.formatID( $elem.attr('id') ),
nextID = $elem.next('.js-block').attr('id') || null;
@ourmaninamsterdam
ourmaninamsterdam / index.html
Created August 8, 2013 10:31
A CodePen by Justin Perry.
<div class="flex">
<!--div*6>table>tr*8>tr*8>td*7>{Eius facere reprehenderit esse praesentium eligendi.}-->
<div>
<table>
<col style="width: auto" />
<col style="width: 20%" />
<col style="width: 30%" />
<col style="width: 20%" />
<col style="width: 10%" />
<col style="width: 10%" />