Skip to content

Instantly share code, notes, and snippets.

Kyle Fox kylefox

Block or report user

Report or block kylefox

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@kylefox
kylefox / stripe_subscription_coupons.rb
Created Jun 8, 2017
Inconsistent behavior between previewing subscription changes and saving subscription changes when removing subscription coupons.
View stripe_subscription_coupons.rb
# == 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"
View spacing-scale.scss
$spacing-scale: (
0,
0.3125rem,
0.625rem,
0.9375rem,
1.25rem,
1.5625rem,
3.125rem,
4.688rem,
6.25rem,
View __init__.py
default_app_config = 'cn.apps.users.config.UsersAppConfig'
View confirm.js
$(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 Oct 20, 2018
Run Django database migrations after deploy to Heroku. This file must live at `bin/post_compile` within your root project directory.
View post_compile.sh
# !/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
View smiley.html
<!-- in head -->
<style>
body.clicked {
background: #7f1d26;
}
.smiley {
position: fixed;
top: 1rem;
right: 1rem;
width: 1rem;
View serializers.py
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 Feb 6, 2016 — forked from bastianallgeier/external.js
For those "external links should open in new tabs" clients…
View external.vanilla-forEach.js
// 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';
});
View environments.md

A proposal for a framework-agnostic way of building Javascript configuration objects based on different environments.

This proposal focuses on the conventions that will allow for the creation of a plain old JavaScript object. For example:

var environment = new Environment("development");
environment.name; // "development"
environment.config.API_ROOT; // "http://localhost:3000/"
@kylefox
kylefox / gulpfile.js
Created Jan 15, 2016
I moved bower dependencies in my Ionic app from `./www/lib` to `./bower_modules` in order to slim down the resulting "www" package. Here are the gulp settings/tasks I use to compile/concatenate everything into `./www/js/libs.js`
View gulpfile.js
var paths = {
// Manually specify the bower resources we actually need.
// This way our index simply has: <script src="js/libs.js"></script>
bower: {
scripts: [
"./bower_modules/ionic/js/ionic.bundle.js",
"./bower_modules/angular-resource/angular-resource.js",
],
fonts: [
"./bower_modules/ionic/fonts/**.*",
You can’t perform that action at this time.