Skip to content

Instantly share code, notes, and snippets.

View yankeyhotel's full-sized avatar
👾

Matt McClard yankeyhotel

👾
  • Habitat
  • United States
View GitHub Profile
@yankeyhotel
yankeyhotel / Diamond Inside of a Square LESS Mixin
Last active August 29, 2015 14:11
A LESS Mixin to mask a square image into a diamond shape (aka 45deg square).
.diamond-inside-square (@square: 100px; @background-img) {
.square(@square);
.rotate(-45deg);
margin: @square/4;
overflow: hidden;
&:after {
.square(@square*1.5);
.rotate(45deg);
background: url(@background-img);
display: block;
@yankeyhotel
yankeyhotel / Jquery Ajax call
Created April 10, 2015 20:26
FoxyCart API - Ajax to PHP and back for customer info
$.ajax({
url: '../assets/php/get_customer_id.php',
data: { email: "email@email.com" },
type: 'post',
success: function(data) {
var xmlDoc = $.parseXML(data),
$xml = $(xmlDoc);
console.log($xml.find("customer_id").text());
},
error: function(jqXHR, textStatus, errorThrown) {
@yankeyhotel
yankeyhotel / indexedArray.js
Created July 27, 2015 17:11
Add an index to #each loop
/**
* Add an index to each loop
*/
UI.registerHelper('indexedArray', function(context, options) {
if (context) {
return context.map(function(item, index) {
item._index = index + 1;
return item;
});
}
@yankeyhotel
yankeyhotel / throwError.js
Created July 28, 2015 22:22
How to throw an error in a Meteor method
Meteor.methods({
test: function() {
throw new Meteor.Error("name of the error", "Here is the reason");
}
});
Meteor.call('test', function(error, response){
if (error) {
console.log("error", error);
} else {
@yankeyhotel
yankeyhotel / find.js
Created August 12, 2015 21:21
Find a value of greater than or null in Mongo Collection
var coupon = Coupons.findOne({
codes: { $in: [coupon_code] },
valid: true,
redeem_by: { $lte: now },
$or: [
{ end_date: { $gte: now } },
{ end_date: null }
]
});
@yankeyhotel
yankeyhotel / futures_wait.js
Created April 19, 2016 15:45 — forked from deanrad/futures_wait.js
Wait on Array of Futures
// server/server.js
var Future = Npm.require('fibers/future');
Meteor.methods ({
testFutures: function(array) {
// var future = new Future;
// setTimeout(function() {
@yankeyhotel
yankeyhotel / whatWidth.js
Created September 16, 2016 16:11
Create a div that shows the pixel dimensions for developing responsive sites
// =========================================
// NOTE: whatWidth for Dev only
// =========================================
(function() {
window.addEventListener("resize", resizeThrottler, false);
var resizeTimeout;
function resizeThrottler() {
// ignore resize events as long as an actualResizeHandler execution is in the queue
if ( !resizeTimeout ) {
@yankeyhotel
yankeyhotel / Google-Sheet-Form-Post.md
Created October 15, 2016 16:43 — forked from willpatera/Google-Sheet-Form-Post.md
Post to google spreadsheet from html form

Overview

This collection of files serves as a simple static demonstration of how to post to a google spreadsheet from an external html <form> following the example by Martin Hawksey

Run example

You should be able to just open index.html in your browser and test locally.

However if there are some permissions errors you can make a quick html server with python. Open terminal and cd to the directory where the gist files are located and enter python -m SimpleHTTPServer. By default this creates a local server at localhost:8000

@yankeyhotel
yankeyhotel / shopify-money.js
Created July 24, 2018 20:14 — forked from stewartknapman/shopify-money.js
The Shopify.formatMoney method extracted from option_selection.js for stand-alone purposes.
var Shopify = Shopify || {};
// ---------------------------------------------------------------------------
// Money format handler
// ---------------------------------------------------------------------------
Shopify.money_format = "${{amount}}";
Shopify.formatMoney = function(cents, format) {
if (typeof cents == 'string') { cents = cents.replace('.',''); }
var value = '';
var placeholderRegex = /\{\{\s*(\w+)\s*\}\}/;
var formatString = (format || this.money_format);
@yankeyhotel
yankeyhotel / html
Created September 19, 2018 19:23
youtube embed w/ mute and autoplay and loop
<iframe width="560" height="315" src="https://www.youtube.com/embed/ZHiVC_51KkI?rel=0&controls=0" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen=""></iframe>
<div id="muteYouTubeVideoPlayer"></div>
<script async="" src="https://www.youtube.com/iframe_api"></script>
<script>
function onYouTubeIframeAPIReady() {
var player;
player = new YT.Player('muteYouTubeVideoPlayer', {
videoId: 'ZHiVC_51KkI', // YouTube Video ID