Skip to content

Instantly share code, notes, and snippets.

View heaversm's full-sized avatar

Mike Heavers heaversm

View GitHub Profile
@heaversm
heaversm / index.html
Last active March 5, 2023 20:54
Create animated transitions between StyleGAN images with P5.js and Runway ML
<html>
<head>
<script src="js/lib/p5.js"></script>
<script src="js/lib/p5.dom.js"></script>
<script src="js/lib/toxiclibs.js"></script>
<script src="data/landscape.js"></script>
<script src="js/stylegan-transition.js"></script>
</head>
<body>
</body>
@heaversm
heaversm / motion-face-selfiecam.js
Last active January 20, 2023 00:00
Face Detection Automatic Selfie Cam using React Native and Expo
import React from 'react';
import { StyleSheet, Text, View } from 'react-native';
import { Camera, Permissions, FaceDetector, DangerZone } from 'expo';
export default class CameraExample extends React.Component {
static defaultProps = {
countDownSeconds: 5,
motionInterval: 500, //ms between each device motion reading
motionTolerance: 1, //allowed variance in acceleration
cameraType: Camera.Constants.Type.front, //front vs rear facing camera
@heaversm
heaversm / twilio-transcription-back.js
Last active January 14, 2023 11:04
Twilio Call Recording Transcriptions With Google Web Speech API
//node vars
const express = require('express')
const twilio = require('twilio')
const request = require('request')
//twilio vars
const accountSid = '###' //your twilio account SID
const authToken = "###" //your twilio auth token
const client = require('twilio')(accountSid, authToken)
const baseURL = 'https://api.twilio.com/2010-04-01/Accounts/[YOUR_ACCOUNT_HERE]/Recordings/'
@heaversm
heaversm / startup-marketing-checklist.md
Created December 28, 2022 17:08
Startup Marketing Checklist

Pre-Launch

Marketing starts long before you launch. Market research, planning, and preparation are critical parts of any marketing strategy.

Competitor Research

I have been up against tough competition all my life. I wouldn't know how to get along without it. - Walt Disney

@heaversm
heaversm / co2fromeventflights.js
Created October 25, 2022 02:50
all-company-trip co2 estimator
let totalPeopleInDirectory = 0;
let peopleWithUnknownLocation = 0;
let numLocations;
const locations = [];
const addPersonToTotal = function () {
totalPeopleInDirectory += 1;
};
const addToPeopleWithUnknownLocation = function () {
@heaversm
heaversm / docker-compose.yml
Created August 30, 2022 16:07
Docker Compose Running Cypress Tests
version: '3'
services:
# the client container, running webpack and the dev server
client:
image: path_to/image
networks:
- allhosts
volumes:
@heaversm
heaversm / regex-wrap-inside-tags.md
Last active August 9, 2022 16:30
regex: wrap all text inside matching tags
  • Find: <p class="italic text-center">(.+?)<\/p>
  • Replace: <p class="italic text-center"><time class="dt-published" datetime="$1">$1</time></p>
  • Example: <p class="italic text-center">03/01/2015</p>
  • Result: <p class="italic text-center"><time class="dt-published" datetime="03/01/2015">03/01/2015</time></p>
@heaversm
heaversm / react_to_google_sheets_form.js
Created July 2, 2019 11:05
Storing form data from a website in Google Spreadsheets using javascript
import { Form, Text } from 'informed'; //https://joepuzzo.github.io/informed/
import React from 'react';
const SPREADSHEET_ID = 'nhlD3E6xsi2lbDQ71HTJ3oQ1Ql5dIkuiK4IoZYjHD'; //from the URL of your blank Google Sheet
const CLIENT_ID = '2d280542491u-3aofp4eFeftog7q0u5a73ro566h8vi.apps.googleusercontent.com'; //from https://console.developers.google.com/apis/credentials
const API_KEY = 'AIzaSyCz5fYFuCORKGXSGu4IwKq4U_HfcdDtB'; //https://console.developers.google.com/apis/credentials
const SCOPE = 'https://www.googleapis.com/auth/spreadsheets';
export default class ContactForm extends React.Component {
@heaversm
heaversm / useful-terminal-commands.sh
Last active January 3, 2021 19:00
Terminal commands, workflows, and utilities
#force remove in powershell and unix
rm -rf [directory]
rm -r -fo [directory]
# download a blob url for a video
#Use the HLS Downloader Google Chrome extension to get the link to the M3U playlist
#Copy that url into the script below
youtube-dl --all-subs -f mp4 -o "file-name-to-save-as.mp4" "[M3U_List_URL]"
#find all videos in a folder and reduce their dimensions and or quality
#-crf lower is higher bitrate (better quality)
# -b 1000000 can be added, where you divide 1 GB by the video length in seconds (e.g. this is a 16m:40s video)
find . -type f -name "*.mp4" -exec bash -c 'FILE="$1"; ffmpeg -i "${FILE}" -crf 20 -s 1280x720 -acodec copy -y "${FILE%.mp4}.shrink.mp4";' _ '{}' \;
#optimize an mp4
ffmpeg -i input.mp4 -vcodec h264 output.mp4
#imagemagick: