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 = () => {
import React from 'react'
import { ReactWidget } from '@jupyterlab/apputils'
import { Provider } from 'react-redux'
import store from '../ducks/store'
export class ReactAppWidget extends ReactWidget {
constructor() {
super()
}
#!/bin/sh
# Replace this with the path to your repository
REPOSITORY_DIR=/Users/davisford/Documents/sample-react-jupyterlab-extension
# Replace with the name of your conda environment
CONDA_ENV=jl-extension-env
# Helper function.
# Opens a new tab and executes a command in iTerm2
@daviseford
daviseford / BootstrapWebmComponent.tsx
Last active October 3, 2019 12:19
React Bootstrap Webm Component with Fallback Image
type TWebmComponent = React.FC<{ videoUrl: string; fallbackUrl: string; description: string; onClick?: (e) =>void }>
const WebmComponent: TWebmComponent = ({ videoUrl, fallbackUrl, description, onClick = () => null }) => {
const supportsWebm = !!document.createElement('video').canPlayType
return (
<>
<figure className="figure">
<a
@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
@daviseford
daviseford / open_browsers.bat
Last active November 8, 2018 17:18
opens multiple browsers. copy paste this text into a .bat file and run it
@echo off
color 0a
echo " _____ ____ ____ _____ "
echo " |_ _| |_ \ / _||_ _| "
echo " | | | \/ | | | "
echo " | | _ | |\ /| | | | "
echo " _| |__/ | _| |_\/_| |_ _| |_ "
echo " |________||_____||_____||_____| "
echo " "
@daviseford
daviseford / commit-msg.sh
Created July 3, 2018 12:25
prepend's your git branch's name to the commit message
#!/bin/sh
NAME=$(git branch | grep '*' | sed 's/* //')
DESCRIPTION=$(git config branch."$NAME".description)
echo "$NAME"': '$(cat "$1") > "$1"
if [ -n "$DESCRIPTION" ]
then
echo "" >> "$1"
echo $DESCRIPTION >> "$1"
fi
@daviseford
daviseford / javascript_whatsapp_regex
Created February 18, 2018 13:56
regex_for_whatsapp_chat_logs
const regex = txt.match(/^\[[\S]+[\s][\S]+[\s]\wM\]\s[\w\s]+:\s/gm)
@daviseford
daviseford / checksum.js
Last active February 17, 2018 00:44
native-javascript-checksum
const checksum = (txt) => txt.split('').reduce((a, s, i) => a + (txt.charCodeAt(i) * (i + 1)), 0x12345678)
@daviseford
daviseford / quick_upload.sh
Last active February 14, 2018 16:41
download the logic, just use config file
#!/bin/bash
# This script does some various utility tasks
# Builds the static site using Jekyll
# And syncs the generated site with S3
# You can run this script with three options
# -i | enable Image processing. Creates thumbnails and quickly compresses images.
# -c | enable maximum Compression for images. Creates thumbnails, thoroughly compresses images, and takes a long time doing it
# -n | No-upload mode. Doesn't upload the build to S3.
# -s | enable Setup mode. Downloads the necessary npm files for compression