Skip to content

Instantly share code, notes, and snippets.

View stephenscaff's full-sized avatar

Stephen Scaff stephenscaff

View GitHub Profile
@stephenscaff
stephenscaff / find.ts
Created August 6, 2023 17:32
find.ts
export default function findInArray<T>(
arr: T[],
callback: (element: T, index: number, array: T[]) => boolean
): T | undefined {
if (typeof callback !== 'function') {
throw new TypeError('callback must be a function')
}
const list = Object(arr)
// Makes sure it always has a positive integer as length.
/**
* isEven
* @param {number}
*/
export function isEven(num) {
return num % 2 === 0;
}
/**
* Count Items
@stephenscaff
stephenscaff / ffmpeg-cmnds.bash
Last active October 24, 2022 23:19
Useful ffmpeg commands
# FFMPEG Cmds
# https://ffmpeg.org/ffmpeg-all.html#Video-Options
# -i input file
# Basic convert mov to mp4
ffmpeg -i input.mov output.mp4
# Simple Compress ( amount by -b 2500k)
# -b: bitrate
@stephenscaff
stephenscaff / search.svg
Created February 9, 2021 21:51
search.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@stephenscaff
stephenscaff / PageTrans.js
Created January 6, 2021 18:49
Too Simple page transitions for Next.js. You can do better though bruv...
import React, { useEffect } from 'react'
import Router, { useRouter } from 'next/router'
function PageTrans(props) {
const router = useRouter()
let transTime = 100
useEffect(() => {
const handleRouteExit = () => {
document.documentElement.classList.remove('page-trans-entered')
@stephenscaff
stephenscaff / git-force-pull.sh
Created December 5, 2020 15:54
Decent Git Pull Flow
#!/bin/bash
# First, run a fetch to update all origin/<branch> refs to latest:
git fetch --all
# Backup your current branch:
git checkout -b backup-master
@stephenscaff
stephenscaff / dope-module-es5.js
Last active August 27, 2020 21:50
JS Module Example
/**
* DopeModule
*/
const DopeModule = (function() {
// Module Constants
const ACTIVE_CLASS_NAME = 'is-active';
// Module Vars
@stephenscaff
stephenscaff / gist:cae4652ab7a88007fdb36eaedfd615ff
Last active March 17, 2020 10:32
Create React Component with Parcel
mkdir component-name && cd component-name
npm init -y && git init
npm install --save react react-dom
npm install --save-dev @babel/core @babel/plugin-proposal-class-properties @babel/preset-env @babel/preset-react parcel-bundler
touch .gitignore
mkdir src
touch src/index.html
atom .
@stephenscaff
stephenscaff / Cursor.js
Created March 16, 2020 19:48
Animated custom cursor in React, using hooks and a functional component.
import React, { useState, useEffect, useRef } from "react";
function Cursor() {
const cursorDotOutline = useRef();
const cursorDot = useRef();
const requestRef = useRef();
const previousTimeRef = useRef();
let [mousePosition, setMousePosition] = useState({ x: 0, y: 0 });
const [width, setWidth] = useState(window.innerWidth);
const [height, setHeight] = useState(window.innerHeight);
import Player from '@vimeo/player';
/**
* ViemoPlaylist
* Class for interacting with the Vimeo API
* to create a continous playlist of vids
* @class
* @requires @vimeo/player
* @param {html element id} el - player element passed to Vimeo's imported Player class.
* @param {object} options - plugin options for api and playlist ids