Skip to content

Instantly share code, notes, and snippets.

View paulcushing's full-sized avatar
:shipit:
The roads are paved with squirrels that couldn't make up their mind.

Paul Cushing paulcushing

:shipit:
The roads are paved with squirrels that couldn't make up their mind.
View GitHub Profile
@paulcushing
paulcushing / do-function-message-to-slack.js
Created July 22, 2022 16:07
A Digital Ocean function that accepts a message and sends it to your Slack channel.
const fetch = require("node-fetch");
let slackToken = process.env.slack_token
function main(args) {
if (!args.name || !args.email || !args.message || !args.site) {
return {"body": "Error - missing arguments"}
}
let name = args.name
let email = args.email
let message = args.message
@paulcushing
paulcushing / form.js
Created April 11, 2022 17:53
Simple React form with validation
import { useState } from "react";
function Form() {
const [name, setName] = useState("");
const [message, setMessage] = useState("");
const [email, setEmail] = useState("");
const [submitClicked, setSubmitClicked] = useState();
const [formError, setFormError] = useState([]);
const submit = () => {
@paulcushing
paulcushing / passparams.js
Last active April 8, 2022 15:28
Parameter Pass-Through
// Catch the incoming params
const incomingQueryString = window.location.search.substring(1); // drops ? from the front;
// Capture all of the link clicks
document.addEventListener(`click`, (e) => {
// if it's an <a> link
if (e.target.closest(`a`) && incomingQueryString.length > 0) {
e.preventDefault();
// if it already has params, combine them, if not, add the new ones
window.location.href =