Skip to content

Instantly share code, notes, and snippets.

View deltaepsilon's full-sized avatar
🥰
Moving to private repos!!!

Chris Esplin deltaepsilon

🥰
Moving to private repos!!!
View GitHub Profile
import localforage from 'localforage';
import { useCallback, useEffect, useState } from 'react';
type Setter = (value: any) => Promise<any>;
/**
* Usage example:
*
* const IS_DEV_KEY = 'is-dev';
*
@deltaepsilon
deltaepsilon / kill-port.sh
Created June 19, 2024 16:21
Shell function to kill processes on a port
killport() {
if [ -z "$1" ]; then
echo "Usage: killport <port>"
return 1
fi
lsof -ti:$1 | xargs kill -9
}
@deltaepsilon
deltaepsilon / dates
Created July 2, 2023 23:26
Pull EXIF Create Date using exiftool and prefix the filename with YYYYMMDD_HHMMSS_*
#!/bin/bash
## Installation: Add to path and call with `dates` or `dates <directory>`
## Bard prompt: "write me a script to use exiftool to prefix mp4 filenames with their timestamps"
if [[ $1 ]]; then
echo "The first argument exists"
current_directory=$(pwd)/$1
else
Get-ChildItem "C:\Users\chris\Downloads" -Filter *.zip |
Foreach-Object {
$name = $_.Name
$folderName = $name.Split('.')[0]
$folderPath = "C:\Users\chris\Downloads\takeout-in\$folderName\"
echo "Processing $folderPath"
New-Item $folderPath -type Directory
@deltaepsilon
deltaepsilon / CODE_GUIDELINES.md
Last active April 28, 2023 18:19
WIP Code Guidelines for React

Code Guidelines for React

Hat tip to Clean Code by Robert C. Martin (Uncle Bob)

Goals

  • Consistency
  • Predictability
  • Maintainability
  • Readability
Run chromaui/action@v1
Chromatic CLI v5.7.0
https://www.chromatic.com/docs/cli

Firebase CI/CD with Google Cloud Build

[[Fireline]]: Firebase Functions + Stripe FTW

Fireline is a recent open source project of mine.

It's a series of drop-in Firebase Functions and React hooks that integrate with Stripe to add SaaS payments to web apps.

steps:
- name: 'gcr.io/cloud-builders/docker'
entrypoint: 'bash'
args: ['-c', 'docker pull us.gcr.io/$PROJECT_ID/flyerr:latest-$BRANCH_NAME || exit 0']
- name: 'gcr.io/cloud-builders/docker'
args:
[
'build',
'-t',
'us.gcr.io/$PROJECT_ID/flyerr:latest-$BRANCH_NAME',
const flatten = require('./flatten');
describe('flatten', () => {
it('should flatten deeply nested arrays of integers', () => {
const arrays = [1, 2, 3, [4, 5, 6, [7, 8, 9], [10, 11, 12]]]
const expected = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12];
expect(flatten(arrays)).toEqual(expected);
});
});
@deltaepsilon
deltaepsilon / authorization-on-create.js
Last active July 23, 2018 12:57
Cloud Function to manage Custom Claims
const getCustomClaimsByEmail = require('../utilities/get-custom-claims-by-email');
const setCustomClaims = require('../utilities/set-custom-claims');
module.exports = ({ admin, environment }) => user => {
const db = admin.firestore();
const usersCollection = db.collection(environment.schema.users);
const customClaimsRef = admin.database().ref(environment.schema.customClaims);
const auth = admin.auth();
const email = extractEmailFromUser(user);