Skip to content

Instantly share code, notes, and snippets.

View daviseford's full-sized avatar

Davis Ford daviseford

View GitHub Profile
@daviseford
daviseford / asyncStripeProvider.tsx
Last active November 22, 2020 21:18
React Hooks - Async Stripe Provider
import React, { useState, useEffect, useRef } from 'react'
import { StripeProvider } from 'react-stripe-elements'
type TProvider = React.FC<{ apiKey: string }>
const AsyncStripeProvider: TProvider = props => {
const { apiKey, children } = props
const [stripe, setStripe] = useState<stripe.Stripe | null>(null)
const isMounted = useRef(false)
const unmountFn = () => {
@mrcoles
mrcoles / AsyncStripeProvider.js
Last active December 8, 2020 14:28
A react provider abstraction for loading the stripe.js file asynchronously to use with Stripe Elements
import PropTypes from 'prop-types';
import React, { Component } from 'react';
import { StripeProvider } from 'react-stripe-elements';
export default class AsyncStripeProvider extends Component {
static propTypes = {
apiKey: PropTypes.string.isRequired
};
// constructor
@daviseford
daviseford / multi_table_merge.bas
Last active January 11, 2019 14:01
Table Merge VBA Script
Sub CreateMasterSheet(masterSheetName As String)
' This subroutine creates the Master sheet if we don't have one
Application.ScreenUpdating = False
Dim wrk As Workbook
Dim sheet As Worksheet
Dim masterSheet As Worksheet
Dim masterSheetExists As Boolean
masterSheetExists = False
@vktr
vktr / rule.js
Created February 10, 2018 18:54
Add Stripe Customer Id to Auth0 via custom rule
function (user, context, callback) {
user.app_metadata = user.app_metadata || {};
if ('stripe_customer_id' in user.app_metadata) {
context.idToken['https://example.com/stripe_customer_id'] = user.app_metadata.stripe_customer_id;
return callback(null, user, context);
}
var stripe = require('stripe')('sk_....');
var customer = {
@vdaubry
vdaubry / gist:69f089affeff3b6ca627
Last active August 24, 2018 00:59
Facebook meta tags for jekyll
<!-- facebook Open Graph Metadatas -->
<meta content="your_facebook_app_id" property="fb:app_id">
<meta content="{{ site.title }}" property="og:site_name">
{% if page.title %}
<meta content="{{ page.title }}" property="og:title">
{% else %}
<meta content="{{ site.title }}" property="og:title">
{% endif %}
{% if page.title %}
<meta content="article" property="og:type">
@nealrs
nealrs / giphy.js
Created May 5, 2014 21:32
use the giphy api to search for & add an animated gif to a webpage.
// on page load, search for & display a random gif matching your search term using the Giphy API.
// usage:
// include giphy.js in your <head>
// set q to your search term (e.g. "brunch")
// add <span id = "giphyme"></span> wherever you want to display the image. -- FYI, it will be centered.
// big ups to the Giphy crew (giphy.com)
// 2014 - Neal Shyam [@nealrs | nealshyam.com]
document.addEventListener('DOMContentLoaded', function () {
q = "finger guns"; // search query