Skip to content

Instantly share code, notes, and snippets.

View chrisjpatty's full-sized avatar
🎨
2 parts design. 2 parts Javascript

Christopher Patty chrisjpatty

🎨
2 parts design. 2 parts Javascript
View GitHub Profile
@chrisjpatty
chrisjpatty / ps5bot.js
Last active May 19, 2021 19:02
Gamestop PS5 Stock Check Bot
(async () => {
Notification.requestPermission().then(async function(result) {
const getTime = (min, max) => {
min = Math.ceil(min);
max = Math.floor(max);
return Math.floor(Math.random() * (max - min) + min);
}
const notify = (message) => {
new Notification('PS5 Bot', { body: message });
}
@chrisjpatty
chrisjpatty / Announcer.css
Last active May 26, 2020 19:26
A React component for announcing messages to a screen reader that are visually hidden from users. This component comes with development warnings for invalid usages. As these messages are unnecessary in production, I recommend using a Webpack or Rollup plugin that will exclude the warnings from production builds such as https://www.npmjs.com/pack…
.visually-hidden {
position: absolute;
left: -10000px;
top: auto;
width: 1px;
height: 1px;
overflow: hidden;
color: transparent;
opacity: .01;
}
@chrisjpatty
chrisjpatty / Covid-19-Slack-Bot.js
Created March 11, 2020 22:18
A Slack bot for tracking Covid-19 cases and deaths in your state.
const puppeteer = require("puppeteer");
const axios = require("axios");
let lastSeenStats = { cases: 0, deaths: 0 };
const STATE = "Utah" // Change this to the state you want to test for
const sendSlack = stats => {
axios.post(
"YOUR_SLACK_WEBHOOK_URL HERE",
{
@chrisjpatty
chrisjpatty / getFirstFocusableElementByScope.js
Last active October 31, 2019 19:20
This is a handy utility function for getting the first focusable element within a certain scope.
const getFirstFocusableElementByScope = (scope = '') => {
const focusableSelectors = [
'button',
'[href]',
'input',
'select',
'textarea',
'[tabindex]:not([tabindex="-1"])'
]
.map(x => `${scope} ` + x)
@chrisjpatty
chrisjpatty / shakespeare.json
Created May 5, 2019 19:14
A selection of quotes from William Shakespeare
[
"Shall I compare thee to a summer's day?\nThou art more lovely and more temperate:\nRough winds do shake the darling buds of May,\nAnd summer's lease hath all too short a date",
"To be, or not to be: that is the question",
"Neither a borrower nor a lender be; For loan oft loses both itself and friend, and borrowing dulls the edge of husbandry",
"This above all: to thine own self be true",
"Though this be madness, yet there is method in 't.",
"That it should come to this!",
"There is nothing either good or bad, but thinking makes it so",
"What a piece of work is man! how noble in reason! how infinite in faculty! in form and moving how express and admirable! in action how like an angel! in apprehension how like a god! the beauty of the world, the paragon of animals! ",
"The lady doth protest too much, methinks",
@chrisjpatty
chrisjpatty / maskDate.js
Last active April 6, 2024 15:27
Javascript date Input mask MM/DD/YYYY
const maskDate = value => {
let v = value.replace(/\D/g,'').slice(0, 10);
if (v.length >= 5) {
return `${v.slice(0,2)}/${v.slice(2,4)}/${v.slice(4)}`;
}
else if (v.length >= 3) {
return `${v.slice(0,2)}/${v.slice(2)}`;
}
return v
}