Skip to content

Instantly share code, notes, and snippets.

View crevulus's full-sized avatar
🎭
Dazzling audiences @SpotlightUK

Christopher Evans crevulus

🎭
Dazzling audiences @SpotlightUK
View GitHub Profile
@crevulus
crevulus / useEffectDebugger.tsx
Last active September 13, 2022 11:05
useEffect debugger to see which array deps changed.
const usePrevious = (value: any, initialValue: any) => {
const ref = useRef(initialValue);
useEffect(() => {
ref.current = value;
});
return ref.current;
};
export const useEffectDebugger = (effectHook: any, dependencies: any, dependencyNames = []) => {
const previousDeps = usePrevious(dependencies, []);
@crevulus
crevulus / App.tsx
Last active August 16, 2022 20:12
A react-three-fiber cube that rotates idly, and spins back to position on hover using react-spring.
import { Canvas } from "@react-three/fiber";
import { Box } from "./components/Box";
import "./styles.css";
import React from "react";
export const LightSource = () => {
return (
<>
<ambientLight intensity={0.1} />
@crevulus
crevulus / App.tsx
Last active June 8, 2022 02:04
Basic Page Transition with Framer
import {
AnimatePresence,
m,
LazyMotion,
domAnimation,
domMax
} from "framer-motion";
import type { CSSProperties } from "react";
import { Link, Route, Routes, useLocation } from "react-router-dom";
import "./styles.css";
@crevulus
crevulus / takeMultipleScreenshots.js
Last active October 27, 2023 15:06
A small script using puppeteer to get screenshots of multiple browser pages.
const puppeteer = require("puppeteer");
const pages = require("./webPages.json");
async function takeMultipleScreenshots() {
try {
const browser = await puppeteer.launch();
const page = await browser.newPage();
for (const { id, name, url } of pages) {
@crevulus
crevulus / getGithubProfile.js
Created March 4, 2021 11:31
A small script using puppeteer to grab select profile data from any GitHub profile.
const puppeteer = require("puppeteer");
const crevulus = {};
async function getProfile(username) {
const browser = await puppeteer.launch({
// headless: false,
defaultViewport: null,
});
@crevulus
crevulus / getImages.js
Last active August 16, 2022 20:10
A small script that uses puppeteer to scrape craigslist and return images for a search term
const puppeteer = require("puppeteer");
async function getImages(searchTerm) {
const browser = await puppeteer.launch({
// headless: false,
defaultViewport: null,
});
const page = await browser.newPage();