Skip to content

Instantly share code, notes, and snippets.

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
View index.html
<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
View motion-face-selfiecam.js
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
View twilio-transcription-back.js
//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
View startup-marketing-checklist.md

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 / openCV-portait-camera-android.java
Last active November 6, 2022 01:21
Renders openCV's camera in portrait mode on android - to be placed in `CameraBridgeViewBase.java`
View openCV-portait-camera-android.java
private final Matrix mMatrix = new Matrix();
private void updateMatrix() {
float mw = this.getWidth();
float mh = this.getHeight();
float hw = this.getWidth() / 2.0f;
float hh = this.getHeight() / 2.0f;
float cw = (float)Resources.getSystem().getDisplayMetrics().widthPixels; //Make sure to import Resources package
@heaversm
heaversm / co2fromeventflights.js
Created October 25, 2022 02:50
all-company-trip co2 estimator
View co2fromeventflights.js
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
View docker-compose.yml
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
View regex-wrap-inside-tags.md
  • 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-express-heroku-quickstart.md
Last active June 1, 2022 17:57
Easy up and running Create React App with Express backend running on Heroku with auto-deploys
View react-express-heroku-quickstart.md

React Express Heroku Quickstart

npm init -y

Backend

create folder server and file index.js inside, with contents:

const express = require("express");
@heaversm
heaversm / datgui-build.js
Last active May 24, 2022 15:06
Automatically build a dat gui from a javascript object
View datgui-build.js
config = { //SAMPLE OBJECT - replace this with your data object
stroke: 2, //svg stroke value
opacity: 0.3, //0-1
offsetX: 120, //px
offsetY: 80,
fontWeight: 400, //css font-weight
fontSize: 12, //in px
changePositive: '\u25B4', //unicode character for up arrow
changeNegative: '\u25BE', //unicode character for down arrow
colorBlue: '#1190A3', //all hex colors will automatically use the addColor dat gui function