Skip to content

Instantly share code, notes, and snippets.

View panphora's full-sized avatar
👋
Hello

David Miranda panphora

👋
Hello
View GitHub Profile
/*
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
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();
@panphora
panphora / taxes.js
Last active December 2, 2023 00:45
/*
# calculate your taxes in your browser console
## Usage ##
taxes.bracket(0, 22000, .10)
taxes.bracket(22001, 89450, .12);
taxes.bracket(89451, 190750, .22);
/*
# taxes.js - calculate Federal Taxes
## Usage:
taxes.bracket(0, 22000, 0.10)
taxes.bracket(22001, 89450, 0.12);
taxes.bracket(89451, 190750, 0.22);
@panphora
panphora / polite-pop-email-platforms.js
Created April 7, 2023 18:17
How to use AJAX POST or JSONP to send subscribers to ConvertKit, Mailchimp, Mailerlite, SendFox, and EmailOctopus on the front-end
import toastNotification from "./toast-notification";
import {callEventCallbacks} from "./event-callbacks";
let emailPlatforms = [
{
urlIncludes: ".convertkit.com/forms",
subscribeFunction: addSubscriberToConvertKit
},
{
urlIncludes: ".list-manage.com/subscribe",
<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";
/*
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
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"
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";
@panphora
panphora / why-im-building-remake.md
Created January 1, 2022 18:19
Why I'm Building Remake

Why I'm Building Remake

I’m beyond frustrated with modern web development. It feels hyper-inefficient when it could be completely streamlined.

We currently use massively scalable tools from the biggest companies on earth to solve even the most basic problems. We’ve got infinitely nested component with jumbles of state being passed every which way, a new build tool or framework or best practice every week, and then we have to constantly switch contexts between 12+ disparate technologies just to get an app online.

There should be a simpler way for product-focused founders who want to solve user problems instead of spending all their time debugging their monster stack and gluing things back together.

What about the concept of a “web app object”? A dynamic object that looks like an HTML node but contains all the web app capabilities you need across the stack collapsed into a single primitive.