Skip to content

Instantly share code, notes, and snippets.

View heaversm's full-sized avatar

Mike Heavers heaversm

View GitHub Profile
@heaversm
heaversm / podquest-scraper-final.js
Created December 20, 2023 01:02
Puppeteer Scraper for Podquest
//import puppeteer
import puppeteer from 'puppeteer';
async function muiSelectOption(page, buttonSelector, optionValue) {
let liComponent;
let selectorSubstr = buttonSelector.substring(1); // Remove the leading '#' or '.'
if (optionValue) {
liComponent = `li[data-value="${optionValue}"]`;
} else {
liComponent = 'li:first-child';
@heaversm
heaversm / podquest-scraper-initial.js
Created December 20, 2023 01:04
chatGPT generated puppeteer scraper code
const puppeteer = require('puppeteer');
async function fillForm(data) {
const browser = await puppeteer.launch({ headless: true });
const page = await browser.newPage();
for (const item of data) {
await page.goto('YOUR_WEBPAGE_URL'); // Replace with your webpage URL
// Click the first "Select" button
@heaversm
heaversm / openCV-portait-camera-android.java
Last active March 29, 2024 18:30
Renders openCV's camera in portrait mode on android - to be placed in `CameraBridgeViewBase.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 / react-express-heroku-quickstart.md
Last active March 27, 2024 13:01
Easy up and running Create React App with Express backend running on Heroku with auto-deploys

React Express Heroku Quickstart

npm init -y

Backend

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

const express = require("express");
@heaversm
heaversm / scp-server-local.md
Created February 16, 2024 16:06
SCP Copy between server and local computer

COPY FILES BETWEEN YOUR SERVER AND LOCAL COMPUTER

In terminal, on local machine, run:

FROM REMOTE TO LOCAL

scp -r ssh_user@ssh_host_ip:/var/www/foldername ~/Desktop/foldername

FROM LOCAL TO REMOTE

@heaversm
heaversm / datgui-build.js
Last active February 6, 2024 03:52
Automatically build a dat gui from a javascript object
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
@heaversm
heaversm / ragfusion-node.js
Last active February 2, 2024 02:10
RAGFusion Node / Javascript Implementation
//RRF App Backend
//import node / express dependencies
import express from "express";
import path from "path";
//you'll need a '.dotenv' file in the root with the following variable:
//OPENAI_API_KEY="[YOUR_OPENAI_API_KEY_HERE]"
import dotenv from "dotenv";
@heaversm
heaversm / chatbot-ai-debate-explainer.md
Created January 24, 2024 20:57
Chatbot AI Debate Explainer
@heaversm
heaversm / scraping-google-with-langchain-agents.js
Last active January 5, 2024 22:16
Run a langchain agent that scrapes google
import { OpenAI } from 'langchain/llms';
import { initializeAgentExecutorWithOptions } from 'langchain/agents';
import { SerpAPI } from 'langchain/tools';
const tools = [
new SerpAPI(
'[YOUR_API_KEY]'
),
];
@heaversm
heaversm / trimet-next-arrival.ino
Created December 14, 2018 00:47
Getting the arrival API data for a specific stop on the Portland Trimet bus network, and lighting up an LED strip with the number of minutes before a bus arrives
#include <ESP8266WiFi.h>
#include <WiFiClientSecure.h>
#include <TimeLib.h>
#include <NTPClient.h>
#include <WiFiUdp.h>
#include <Adafruit_NeoPixel.h>
//WIFI
const char* ssid = "[MY_SSID]";