Instantly share code, notes, and snippets.

View Vimeo embed
<iframe src="https://player.vimeo.com/video/200746983?autoplay=1&loop=1&autopause=0&muted=1" width="640" height="360" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>
View html
<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
View shopify-money.js
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);
View recipient.json
{
"id": "xxxxxxxxxx",
"email": "mcclard@footcardigan.com",
"first_name": "Matt",
"last_name": "McClard",
"recharge_customer_id": "xxxxxxxxxx",
"shopify_customer_id": "xxxxxxxxxx",
"default_address_id": {
"id": "xxxxxxxxxx",
"first_name": "matt",
View Google-Sheet-Form-Post.md

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

View whatWidth.js
// =========================================
// 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 ) {
View futures_wait.js
// server/server.js
var Future = Npm.require('fibers/future');
Meteor.methods ({
testFutures: function(array) {
// var future = new Future;
// setTimeout(function() {
View find.js
var coupon = Coupons.findOne({
codes: { $in: [coupon_code] },
valid: true,
redeem_by: { $lte: now },
$or: [
{ end_date: { $gte: now } },
{ end_date: null }
]
});
View throwError.js
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 {
View indexedArray.js
/**
* 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;
});
}