Skip to content

Instantly share code, notes, and snippets.

David Parker boldfacedesign

Block or report user

Report or block boldfacedesign

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@boldfacedesign
boldfacedesign / Sublime wrap multiple lines.txt
Last active Aug 29, 2015
wrap multiple lines in tag Sublime text
View Sublime wrap multiple lines.txt
Use "Selection/Split into Lines" (Ctrl+Shift+L on Windows and Linux, Cmd+Shift+L on OS X)
(Shift+Alt+W) wrap lines in tag
@boldfacedesign
boldfacedesign / C# 2 digit number
Created Mar 17, 2014
C# make sure number has minimum of 2 didgits
View C# 2 digit number
n.ToString("D2")
http://msdn.microsoft.com/en-us/library/dwhawy9k.aspx
View shopify collection loop
{% if c.handle contains collection.handle and c.handle != collection.handle %}
<li class="{{ forloop.index }}">
<a href="{{ c.url }}" title="{{ c.title }}">
<span class="product-border"></span>
<div class="img-wrap">
<span class="img-wrap__inner">
<img src="{{ c.image.src | collection_img_url: 'medium' }}">
</span>
</div>
View fix Array.indexOf()
if (!Array.prototype.indexOf) {
Array.prototype.indexOf = function(obj, start) {
for (var i = (start || 0), j = this.length; i < j; i++) {
if (this[i] === obj) { return i; }
}
return -1;
}
}
View Placeholder polyfil
//POLYFILL PLACEHOLDERS IN IE8/9
if (document.createElement("input").placeholder == undefined) {
//GET ALL TEXT INPUTS
var inp = document.querySelectorAll('input[type=text]');
//LOOP THROUGH AND USE PLACEHOLDER AS VALUE
for (i=0;i<inp.length;i++) {
var plhTxt = inp[i].getAttribute('placeholder');
inp[i].setAttribute('value',plhTxt);
//SET VALUE TO BLANK ON FOCUS IF VALUE = PLACEHOLDER
inp[i].onfocus=function(){
View touch optimized mega-menus
//Touch optimization for mega-menus
if ($('html').hasClass('touch')) {
$('#page').on('click', function(e){
if ($('.region-navigation .menu-name-menu-main-navigation > ul > li').hasClass('open')) {
e.stopPropagation();
e.preventDefault();
$('.region-navigation .menu-name-menu-main-navigation > ul > li').removeClass('open');
}
});
@boldfacedesign
boldfacedesign / Compass sprite cleaner
Created Apr 8, 2014
Compass sprite cleaner function (Ruby)
View Compass sprite cleaner
module Compass::SassExtensions::Functions::Sprites
def sprite_url(map)
verify_map(map, "sprite-url")
map.generate
generated_image_url(Sass::Script::String.new(map.name_and_hash))
end
end
module Compass::SassExtensions::Sprites::SpriteMethods
def name_and_hash
@boldfacedesign
boldfacedesign / TEST FOR SUPPORT OF MIN-HEIGHT ON DISPLAY TABLE ELEMENTS
Created Apr 8, 2014
TEST FOR SUPPORT OF MIN-HEIGHT ON DISPLAY TABLE ELEMENTS
View TEST FOR SUPPORT OF MIN-HEIGHT ON DISPLAY TABLE ELEMENTS
//TEST FOR SUPPORT OF MIN-HEIGHT ON DISPLAY TABLE ELEMENTS
(function() {
//CREATE ELEMENT IN DOM
var elem = document.createElement('div');
//ADD STYLES
elem.style.display = 'table';
elem.style.minHeight = '2px';
//APPEND TO DOM
document.body.appendChild(elem);
//MEASURE HEIGHT
View URL parts.txt
Property Description
hash Returns anchor portion of the URL, including the leading hash. (“#results”)
host Returns the hostname and port (if available) of a URL. (“www.example.com” or “www.example.com:80″)
hostname Returns the hostname portion of the URL (“www.example.com”)
href Returns the entire URL. (“http://www.example.com:80/example.php?x=1&y=2#results”)
pathname Returns the path name of the URL (“/example.php”)
port Returns the port portion of the URL (“80″ within the host “www.example.com:80″)
protocol Returns the protocol portion of the URL, including the trailing colon (“http:”, “https:”, “ftp”, etc)
search Returns the query portion of the URL, including the question mark (“?x=1&y=2″)
@boldfacedesign
boldfacedesign / Shopify sitemap collection urls
Created Apr 27, 2014
Shopify get all collection urls from sitemap
View Shopify sitemap collection urls
function loadXMLDoc(filename) {
if (window.XMLHttpRequest) {
xhttp=new XMLHttpRequest();
}
else {
xhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xhttp.open("GET",filename,false);
xhttp.send();
return xhttp.responseXML;
You can’t perform that action at this time.