Skip to content

Instantly share code, notes, and snippets.

View macro6461's full-sized avatar
🏠
WFH

Matthew Croak macro6461

🏠
WFH
View GitHub Profile
@macro6461
macro6461 / App.css
Last active April 12, 2020 15:58
Code for react scroll arrow
App {
text-align: center;
height: 5000px;
}
.scrollTop {
position: fixed;
width: 100%;
bottom: 20px;
align-items: center;
@macro6461
macro6461 / index.html
Created May 23, 2020 21:14
HTML for Screenshotter
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8'>
<meta http-equiv='X-UA-Compatible' content='IE=edge'>
<title>Grab Audio</title>
<meta name='viewport' content='width=device-width, initial-scale=1'>
<link rel='stylesheet' type='text/css' media='screen' href='main.css'>
<!-- <script src='audio.js'></script> -->
<script src='video.js'></script>
@macro6461
macro6461 / randomnumber.js
Created April 1, 2021 13:10
This is the gist for How to Obtain Random Numbers Within a Range Using JavaScript.
const randomNumber = (a, b) => {
var min = a > b ? b : a
var max = a > b ? a : b
//Use below if final number doesn't need to be whole number
//return Math.random() * (max - min + 1) + min;
return Math.floor(Math.random() * (max - min + 1) + min);
}
import {useState} from 'react';
import Visualization from './Visualization'
import html2canvas from "html2canvas";
const HtmlToCanvas = ({data, saveAs}) =>{
const [time, setTime] = useState(0)
const exportAsPicture = () => {
import {useState} from 'react';
import Visualization from './Visualization'
import * as htmlToImage from 'html-to-image';
const HtmlToImage = ({data, saveAs, }) =>{
const [time, setTime] = useState(null)
const exportAsPicture = () => {
const genWordList = (text) => {
var str = ''
var wordMap = {}
text.replace(/[^A-Za-z0–9\/]+/g, "").split(" ").forEach(word=>{
var keyToCheck = word.toLowerCase()
if (wordMap[keyToCheck]){
wordMap[keyToCheck] += 1
} else {
wordMap[keyToCheck] = 1
}
@macro6461
macro6461 / new_changelog_item.sh
Created April 13, 2022 18:04
This is the gist for `new_changelog_item` bash script
new_changelog_item()
{
while read line; do
if [[ $line == "## [Unreleased]"* ]]; then
newvar=$(<<<"$line" sed 's/[].*[]/\\&/g')
echo $newvar
echo "LINE FOUND IN" CHANGELOG.md
sed -i "" "s/$newvar/## [Unreleased]\n\n## [$version] - $date\n### Added\n - ADD CHANGE HERE!/" CHANGELOG.md
return
fi
@macro6461
macro6461 / popup.html
Created January 17, 2023 16:13
HTML pertaining to blog post about Custom Popup
<!-- reference css styles in header of your HTML file -->
<div class="popup outer">
<div class="popup inner">
<button class="close">x</button>
<!-- add custom popup content below -->
<img src="giphy.gif"/>
<h3>Here is your popop!</h3>
<p>If you liked this tool, please leave a tip or follow me on Medium!</p>
<p>Thanks for using the custom popup!</p>
<a href="https://paypal.me/mattcroak?country.x=US&amp;locale.x=en_US" target="_blank">Paypal</a>
@macro6461
macro6461 / popup.js
Created January 18, 2023 20:31
JavaScript pertaining to popup blog post
const constructPopup = () => {
// propbably not the most efficient solution to hiding the popup
// but the code is here if for whatever reason you might want to use it
document.body.innerHTML += popupString;
}
const popupString = `
<div class="popup outer">
<div class="popup inner">
<button class="close">x</button>
@macro6461
macro6461 / publish_to_npm.py
Created December 4, 2024 21:03
Here is the python script for publishing to NPM in my Github actions
import os
import subprocess
def publish_to_npm():
print("CHECKING NPM TOKEN!!")
npm_token = os.getenv("NPM_TOKEN")
if not npm_token:
print("NPM_TOKEN is not set. Exiting...")
exit(-1)
print(f"NPM_TOKEN: {npm_token}")