This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { useState } from 'react'; | |
const useEditable = (initialText) => { | |
const [text, setText] = useState(initialText); | |
const [isEditingDraft, setIsEditingDraft] = useState(false); | |
const [draftText, setDraftText] = useState(text); | |
const enableEditingDraft = () => { | |
setDraftText(text); | |
setIsEditingDraft(true); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Files in directories in "ephemeral" will be deleted | |
when they're older than the name specified by the directory | |
For example: | |
- Files in directory "min5" won't be older than 5 minutes | |
- Files in directory "min15" won't be older than 15 minutes | |
- Files in directory "day30" won't be older than 30 days |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function animateFavicon () { | |
const frameDelay = 10; | |
const angleChange = .5; | |
let angle = 0; | |
let lastFrameTime = 0; | |
const favicon = document.querySelector("[rel='icon']"); | |
const canvas = document.createElement('canvas'); | |
const ctx = canvas.getContext('2d'); | |
const img = new Image(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
# calculate your taxes in your browser console | |
## Usage ## | |
taxes.bracket(0, 22000, .10) | |
taxes.bracket(22001, 89450, .12); | |
taxes.bracket(89451, 190750, .22); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
# taxes.js - calculate Federal Taxes | |
## Usage: | |
taxes.bracket(0, 22000, 0.10) | |
taxes.bracket(22001, 89450, 0.12); | |
taxes.bracket(89451, 190750, 0.22); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import toastNotification from "./toast-notification"; | |
import {callEventCallbacks} from "./event-callbacks"; | |
let emailPlatforms = [ | |
{ | |
urlIncludes: ".convertkit.com/forms", | |
subscribeFunction: addSubscriberToConvertKit | |
}, | |
{ | |
urlIncludes: ".list-manage.com/subscribe", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<style> | |
/* never show exit intent pop: */ | |
.polite-pop__pop--exit-intent { | |
display: none !important; | |
} | |
</style> | |
<script> | |
let politeScript = document.createElement("script"); | |
politeScript.src = "https://cdn.politepop.com/polite-pop-v1.5.0/polite-pop.min.js"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
DON'T ALLOW THESE USERNAMES IN YOUR APP | |
if you want to allow www.yourapp.com/{username} | |
here are the words you wouldn't want people to use | |
as their username | |
words followed by star (*) mean you don't want to |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function addSubscriberToConvertKit ({firstName, email, formAction, onSuccess, onError}) { | |
fetch(formAction, { | |
method: "POST", | |
body: JSON.stringify({ | |
"first_name": firstName, | |
"email_address": email | |
}), | |
headers: { | |
"Accept": "application/json", | |
"Content-Type": "application/json" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function addSubscriberToMailChimp ({email, firstName, formAction, onSuccess, onError}) { | |
// Get url for mailchimp | |
let url = (formAction || "").replace('/post?', '/post-json?'); | |
// add email and first name | |
url += `&EMAIL=${encodeURIComponent(email)}&FNAME=${encodeURIComponent(firstName)}`; | |
// Create & add post script to the DOM | |
let script = document.createElement('script'); | |
script.src = url + "&c=mailchimpCallback"; |
NewerOlder