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 / heroku-16.txt
Created February 20, 2020 23:10
ImageMagick capabilities: iMac vs heroku-16 vs heroku18
Format Module Mode Description
-------------------------------------------------------------------------------
3FR DNG r-- Hasselblad CFV/H3D39II
AAI* AAI rw+ AAI Dune image
AI PDF rw- Adobe Illustrator CS2
ART* ART rw- PFS: 1st Publisher Clip Art
ARW DNG r-- Sony Alpha Raw Image Format
AVI MPEG r-- Microsoft Audio/Visual Interleaved
AVS* AVS rw+ AVS X image
BGR* BGR rw+ Raw blue, green, and red samples
@kylefox
kylefox / currency.js
Created January 14, 2011 19:13
Format currency with JavaScript
// Takes a Number and returns a US/CAN currency string.
function toCurrency(amount) {
return "$" + amount.toFixed(2);
};
// Adds a .toCurrency() method to Numbers.
Number.prototype.toCurrency = function() {
return toCurrency(this);
};
{
"object": {
"id": "sub_Ees5zGujQ85DxG",
"object": "subscription",
"application_fee_percent": null,
"billing": "charge_automatically",
"billing_cycle_anchor": 1554603702,
"billing_thresholds": null,
"cancel_at": null,
"cancel_at_period_end": false,
@kylefox
kylefox / .gitignore
Created December 9, 2018 02:33 — forked from jbergler/.gitignore
Acestream on Mac
.vagrant
import { Controller } from "stimulus"
class PageSectionFormController extends Controller {
initialize() {
this.sectionID = parseInt(this.element.getAttribute("data-page-section-id"))
this.preview = this.application.getControllerForElementAndIdentifier(
document.querySelector(`[data-controller="rich-text-preview"][data-page-section-id="${this.sectionID}"]`),
'rich-text-preview',
);
import Customer from 'Customer';
import API from 'API';
import Spies from 'Spies';
beforeEach(() => {
Spies.start();
});
afterEach(() => {
Spies.stop();
@kylefox
kylefox / validate_join_model.rb
Last active February 7, 2018 21:53
When two models (Project, Employee) belong to a parent (Company) and are joined through a join model (ProjectEmployee), what's the best way to ensure that the two instances being joined belong to the same parent? Ex: how do you ensure the joined project and employee belong to the same company?
class Company < ApplicationRecord
has_many :employees
has_many :projects
end
class Project < ApplicationRecord
belongs_to :company
has_many :project_employees
@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"