Skip to content

Instantly share code, notes, and snippets.

Avatar

Davis Ford daviseford

View GitHub Profile
View App.tsx
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()
}
View jupyterlab_dev.sh
#!/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 Oct 3, 2019
React Bootstrap Webm Component with Fallback Image
View BootstrapWebmComponent.tsx
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 / asyncStripeProvider.tsx
Last active Nov 22, 2020
React Hooks - Async Stripe Provider
View asyncStripeProvider.tsx
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 = () => {
@daviseford
daviseford / multi_table_merge.bas
Last active Jan 11, 2019
Table Merge VBA Script
View multi_table_merge.bas
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 Nov 8, 2018
opens multiple browsers. copy paste this text into a .bat file and run it
View open_browsers.bat
@echo off
color 0a
echo " _____ ____ ____ _____ "
echo " |_ _| |_ \ / _||_ _| "
echo " | | | \/ | | | "
echo " | | _ | |\ /| | | | "
echo " _| |__/ | _| |_\/_| |_ _| |_ "
echo " |________||_____||_____||_____| "
echo " "
@daviseford
daviseford / commit-msg.sh
Created Jul 3, 2018
prepend's your git branch's name to the commit message
View commit-msg.sh
#!/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 Feb 18, 2018
regex_for_whatsapp_chat_logs
View javascript_whatsapp_regex
const regex = txt.match(/^\[[\S]+[\s][\S]+[\s]\wM\]\s[\w\s]+:\s/gm)
@daviseford
daviseford / checksum.js
Last active Feb 17, 2018
native-javascript-checksum
View checksum.js
const checksum = (txt) => txt.split('').reduce((a, s, i) => a + (txt.charCodeAt(i) * (i + 1)), 0x12345678)
@daviseford
daviseford / quick_upload.sh
Last active Feb 14, 2018
download the logic, just use config file
View quick_upload.sh
#!/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