Skip to content

Instantly share code, notes, and snippets.

View kylefox's full-sized avatar
🥊
programming

Kyle Fox kylefox

🥊
programming
View GitHub Profile
@kylefox
kylefox / snippet.js
Created December 22, 2017 18:01
Google Analytics Ecommerce Tracking for Podia
// https://developers.google.com/analytics/devguides/collection/analyticsjs/ecommerce
ga('tutorTracker.require', 'ecommerce');
var price = (Coach.Conversion.revenue_cents/100).toFixed(2);
var txID = Coach.Conversion.object.order_id.toString();
ga('tutorTracker.ecommerce:addTransaction', {
'id': txID,
'affiliation':
'Podia Storefront',
@kylefox
kylefox / .profile.sh
Last active October 17, 2017 15:13
Dracula terminal prompt. Screenshot: http://drops.kylefox.ca/F18fuY
####################################################################################
# Dracula themed prompt
# https://github.com/dracula/terminal.app/issues/2#issuecomment-254878940
# Colors
black="\[$(tput setaf 0)\]"
red="\[$(tput setaf 1)\]"
green="\[$(tput setaf 2)\]"
yellow="\[$(tput setaf 3)\]"
blue="\[$(tput setaf 4)\]"
@kylefox
kylefox / stripe_subscription_coupons.rb
Created June 8, 2017 19:24
Inconsistent behavior between previewing subscription changes and saving subscription changes when removing subscription coupons.
# == Let's work with a subscription that has an existing coupon ==
subscription = Stripe::Subscription.retrieve('sub_ABC123')
subscription.discount.coupon.id # => "early-upgrade"
# Preview invoice keeps the coupon, as expected.
Stripe::Invoice.upcoming(
customer: subscription.customer,
subscription: subscription.id
).discount.coupon.id # => "early-upgrade"
$spacing-scale: (
0,
0.3125rem,
0.625rem,
0.9375rem,
1.25rem,
1.5625rem,
3.125rem,
4.688rem,
6.25rem,
@kylefox
kylefox / __init__.py
Last active July 1, 2021 12:12
Connecting Django Signals using the AppConfig ready handler: https://docs.djangoproject.com/en/1.10/ref/applications/#django.apps.AppConfig.ready
default_app_config = 'cn.apps.users.config.UsersAppConfig'
$(document).on('click', '.modal button.yes', function() {
console.log('You clicked yes!');
$.modal.close();
});
$(document).on('click', '.modal button.no', function() {
console.log('You clicked no!');
$.modal.close();
});
@kylefox
kylefox / post_compile.sh
Last active October 23, 2020 08:42
Run Django database migrations after deploy to Heroku. This file must live at `bin/post_compile` within your root project directory.
# !/usr/bin/env bash
# File path should be ./bin/post_compile
# (.sh extension added in Gist just to enable shell syntax highlighting.
# https://discussion.heroku.com/t/django-automaticlly-run-syncdb-and-migrations-after-heroku-deploy-with-a-buildpack-or-otherwise/466/7
echo "=> Performing database migrations..."
python manage.py migrate
<!-- in head -->
<style>
body.clicked {
background: #7f1d26;
}
.smiley {
position: fixed;
top: 1rem;
right: 1rem;
width: 1rem;
from rest_framework_jwt.serializers import JSONWebTokenSerializer
from rest_framework.serializers import ValidationError
from rest_framework.authtoken.serializers import AuthTokenSerializer
from .models import LoginLockout
class LockableTokenSerializer(object):
"""
In addition to the normal token auth validation,
@kylefox
kylefox / external.vanilla-forEach.js
Last active February 6, 2016 16:33 — forked from bastianallgeier/external.js
For those "external links should open in new tabs" clients…
// Array.forEach potentially faster than loop
// http://jsperf.com/testing-foreach-vs-for-loop
var links = document.querySelectorAll('a[href*="//' + window.location.host +'"]');
[].slice.call(links).forEach(function(a) {
a.target = '_blank';
});