Skip to content

Instantly share code, notes, and snippets.

View julianbenegas's full-sized avatar

Julian Benegas julianbenegas

View GitHub Profile
@julianbenegas
julianbenegas / get-tween-times.ts
Created May 9, 2023 20:06 — forked from justkahdri/get-tween-times.ts
Get partial tween start and end marks for the @bsmnt/scrollytelling Animation component
const getTweenTimes = (
totalStart: number,
totalEnd: number,
partialStart: number,
partialEnd: number
) => {
const start = (totalEnd - totalStart) * (partialStart / 100) + totalStart
const end = Math.min(
(totalEnd - totalStart) * (partialEnd / 100) + totalStart,
100
import React, { useEffect } from 'react'
export const AdsScript = () => {
if (window?.adsbygoogle?.loaded) return ''
return (
<>
<script
data-ad-client="ca-pub-5511922838842099"
async
import { useState, createContext, useEffect } from 'react'
import firebase from 'firebase/app'
import 'firebase/auth'
import 'firebase/firestore'
import 'firebase/storage'
import 'firebase/analytics'
// Put your credentials
import clientCredentials from '../credentials/client'
@julianbenegas
julianbenegas / uid.js
Last active September 27, 2020 22:29
// A "casual" uid generator.
// The magic here is done in .toString(36), that converts an integer into a 12 digit string.
function getRandomString(length = 7) {
return Math.random().toString(36).substr(2, length) // Remove first two characters because one includes a dot
}
function casualUid(length = 7, result = getRandomString(length)): string {
if (length > 200) throw 'Max length is 200'
if (result.length < length) {