Skip to content

Instantly share code, notes, and snippets.

Avatar
🤘

Stewart Knapman stewartknapman

🤘
View GitHub Profile
@stewartknapman
stewartknapman / lib.js
Last active Mar 14, 2019
Commonly reused functions in JS
View lib.js
module.exports = {
/*
Array Functions
*/
// For each item in Array
each: function (arr, callback, ctx) {
var r;
for (var i = 0; i < arr.length; i++) {
ctx = ctx || arr[i];
r = callback.apply(ctx, [arr[i], i]);
@kyleaparker
kyleaparker / gist:8851659
Created Feb 6, 2014
Shopify: Map all collection tags (avoid 50 product limit)
View gist:8851659
{% assign collection_tags = collection | map: 'tags' %}
{% for tag in collection_tags %}
<a href="/collections/{% if collection.handle != blank %}{{ collection.handle }}{% else %}all{% endif %}/{{ tag | handleize }}" title="{{ tag | escape }}">{{ tag }}</a>
{% endfor %}
@sskylar
sskylar / harmony.export.tpl
Last active Dec 30, 2015
WXR dump for Harmony CMS
View harmony.export.tpl
<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:dsq="http://www.disqus.com/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:wp="http://wordpress.org/export/1.0/"
>
<channel>
<title>{{ blog.title }}</title>
<link>{{ blog.url }}</link>
@cobyism
cobyism / gh-pages-deploy.md
Last active Jun 14, 2021
Deploy to `gh-pages` from a `dist` folder on the master branch. Useful for use with [yeoman](http://yeoman.io).
View gh-pages-deploy.md

Deploying a subfolder to GitHub Pages

Sometimes you want to have a subdirectory on the master branch be the root directory of a repository’s gh-pages branch. This is useful for things like sites developed with Yeoman, or if you have a Jekyll site contained in the master branch alongside the rest of your code.

For the sake of this example, let’s pretend the subfolder containing your site is named dist.

Step 1

Remove the dist directory from the project’s .gitignore file (it’s ignored by default by Yeoman).

@kyamaguchi
kyamaguchi / oneline_detailed_logging.rb
Created Dec 7, 2012 — forked from troy/oneline_detailed_logging.rb
One-line detailed logging for Rails 3 (ActiveSupport::Notifications) and later
View oneline_detailed_logging.rb
# Outputs this at warn log level:
# 1.2.3.4 GET /path 200 OK BlahController#action HTML 938.2 (DB 11.8, View 719.7) {params} {optional params from flash[:log]}
#
# Save as config/initializers/oneline_detailed_logging.rb. Consider
# decreasing the log level from "info" to "warn" (in production.rb) so
# the one-line log message replaces the standard request logs.
# override process_action to add 2 things to the payload:
# - remote IP
@resistorsoftware
resistorsoftware / gist:1487854
Created Dec 16, 2011
Update Fulfillment with Order ID
View gist:1487854
f = ShopifyAPI::Fulfillment.find(:first, :params => {:order_id => order_id})
if f.nil?
fulfillment = ShopifyAPI::Fulfillment.new({:order_id => order_id, :notify_customer => true, :tracking_number => "123456"})
fulfillment.save
else
f.tracking_number = '123456'
f.notify_customer = true
f.save
end