Skip to content

Instantly share code, notes, and snippets.

View sinejoe's full-sized avatar

Joe Bryan sinejoe

  • sineLABS
  • Charleston, SC
View GitHub Profile
@sinejoe
sinejoe / isPalindrome
Last active August 29, 2015 14:00
Python palindrome function demo for Corridor CodeTalk 04/24/2014
import re
def isPalindrome(txt, printVars=False):
'''
Python function accepting string input and optional
switch to print out the local variables used
in determining True/Flase is string a palindrome.
Usage: 1) isPalindrome('abcba') => True
2) isPalindrome('abcba', True) => True + vars
@sinejoe
sinejoe / Round floating point avg to tenths
Last active August 29, 2015 13:57
Round a floating point average to a single/tenths decimal value in Shopify liquid
{% comment %}Inputs: total and count{% endcomment %}
{% assign total = 51 %}
{% assign count = 11 %}
{% comment %}Get full floating point average (i.e. 4.63636364){% endcomment %}
{% assign avg_full = total | times:1.0 | divided_by:count %}
avg full: {{ avg_full }}<br />
{% comment %}Make string array of full average * 10 splitting at decimal{% endcomment %}
{% assign avg_array = avg_full | times: 10.0 | escape | split:"." %}
@sinejoe
sinejoe / dict_to_querystring
Last active December 20, 2015 09:18
Python dictionary to querystring format without %xx escape. Urllib.urlencode doesn't have an option to skip the escaping.
def dict_to_querystring(_dict):
return u'&'.join([u'{}={}'.format(k, v) for k, v in _dict.items()])
@sinejoe
sinejoe / linkshare_pixel_tracking_shopify.liquid
Created May 22, 2012 19:39
Linkshare Pixel Tracking example code for Shopify stores in Europe and other locations where VAT is already included in variant prices.
{% comment %}
MM.DD.YYYY Created for Linkshare pixel tracking
By Developer Name
Note: Linkshare advises to send all orders received. This code below should go
in the "Additional Content & Scripts" box under "Preferences > Checkout &
Payment" in your Shopify Dashboard.
{% endcomment %}
{% assign mid = 'NNNNNNN' %} <!-- Substitute your store's MID number here //-->
{% assign ord = order_number %}
{% assign skulist = '' %}