Skip to content

Instantly share code, notes, and snippets.

View rickydazla's full-sized avatar

Rick Davies rickydazla

View GitHub Profile
{% if template contains 'collection' and collection.all_tags.size > 1 %}
<!-- A recursive loop to catch and filter out the different tag categories -->
{% assign c = 0 %}
{% for t in collection.all_tags %}
{% capture cat %}{{ cat }}{% capture temp_cat %}{% if t contains '_' %}{% assign cat_grp = t | split: '_' %}{{ cat_grp.first }}{% endif %}{% endcapture %}{% unless cat contains temp_cat %}{% if t contains '_' %}{% assign new_cat_grp = t | split: '_' %}{{ new_cat_grp.first }}{% endif %}{% unless forloop.last %}+{% endunless %}{% assign c = c | plus: 1 %}{% endunless %}{% endcapture %}
{% endfor %}
<!-- create array of tag categories -->
{% assign cat_array = cat | split: '+' %}
@rickydazla
rickydazla / hack.html
Last active August 29, 2015 14:02
Shazam content on load
<!-- immediately after opening <body> -->
<script type="text/javascript">document.body.className+=' hidden'</script>
<!-- before closing <body> immediately after jQuery -->
<script type="text/javascript">
$(window).load(function() {
$('body').removeClass('hidden');
});
</script>
@rickydazla
rickydazla / target-webkit.css
Created July 8, 2014 18:27
media query to target webkit
@media screen and (-webkit-min-device-pixel-ratio:0) {
/* address inconsistencies here */
}
@rickydazla
rickydazla / Gift Card Checker
Last active August 29, 2015 14:04
Check for Gift Card in Shopify Email Notification
{% for transaction in order.transactions %}
{% if transaction.gateway == 'gift_card' %}
# cannot assign anything so this is where you do it
{% endif %}
{% endfor %}
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript">
var f_page = "wvumountaineers"; // the page name for your fan page, e.g. the 'wvumountaineers' part of http://facebook.com/wvumountaineers
var t_page = "westvirginiau"; // the account name for your main twitter account
function add_commas(number) {
if (number.length > 3) {
var mod = number.length % 3;
@rickydazla
rickydazla / slider.liquid
Last active August 29, 2015 14:06
Re-order module for settings [wip]
{% assign order = settings.order %}{% comment %}e.g. in desired case '3,1,2'{% endcomment %}
{% capture slides %}{{ order | split:',' }}{% endcapture %}
{% for i in (1..3) %}{% comment %}... rest of code?{% endcomment %}
@rickydazla
rickydazla / switcheroo
Created February 25, 2015 03:00
simple-image-switch
$('.thumb img').click(function(){
$('img#featured').attr('src',$(this).attr('src').replace('compact','1024x1024'));
$(this).parents('li').addClass('active').siblings('li').removeClass('active');
});
@rickydazla
rickydazla / integer-or-string
Created March 19, 2015 14:45
What is this Liquid variable?
{% assign return = false %}
{% assign variable = your_variable %}
{% assign variable-to-string = variable | strip %}
{% assign variable-to-integer = variable | plus: 0 %}
{% if variable-to-string == variable %}
{% assign return = "string" %}
{% elsif variable-to-integer == variable %}
{% assign return = "integer" %}
{% else %}
{% assign return = "undefined" %}
@rickydazla
rickydazla / responsive-videos.js
Last active August 29, 2015 14:22
Responsive Videos
$(document).ready(function(){
$('iframe[src*="youtube.com/embed"]').wrap('<div class="video-wrapper"></div>');
$('iframe[src*="player.vimeo"]').wrap('<div class="video-wrapper"></div>');
});
@rickydazla
rickydazla / zurb-buttons.css
Created March 30, 2012 18:05
Athleti.ca's Awesome Buttons
/* =============================================================================
Awesome Buttons http://www.zurb.com/article/266/super-awesome-buttons-with-css3-and-rgba
========================================================================== */
.awesome { background-color: #333 !important; color: #fff !important; }
.awesome.red { background-color: #c43422 !important; color: #fff !important; }
.awesome { padding:10px 15px 11px !important; font-size: 13px !important; }
.awesome:active { padding:10px 15px 11px !important; }