Skip to content

Instantly share code, notes, and snippets.

View gitdagray's full-sized avatar
👋
☕ 💻 Coffee and Code

Dave Gray gitdagray

👋
☕ 💻 Coffee and Code
View GitHub Profile
@gitdagray
gitdagray / index.html
Created January 4, 2021 07:25
Basic HTML
<!DOCTYPE html>
<html lang="en">
<head>
<title>My First Page</title>
<style>
body { min-height: 300vh;}
</style>
</head>
<body>
<header>
@gitdagray
gitdagray / rps_v3.js
Created October 8, 2020 18:31
Rock_Paper_Scissors_v3
// Rock, Paper, Scissors: Refactored with Functions
const initGame = () => {
const startGame = confirm("Shall we play rock, paper, or scissors?");
startGame ? playGame() : alert("Ok, maybe next time.");
};
// Game flow function
const playGame = () => {
while (true) {
let playerChoice = getPlayerChoice();
@gitdagray
gitdagray / rps_v2.js
Created October 8, 2020 18:29
Rock_Paper_Scissors_v2
// Rock, Paper, Scissors: Refactored with While Loop and an Array
let playGame = confirm("Shall we play rock, paper, or scissors?");
if (playGame) {
//play
while (playGame) {
const playerChoice = prompt("Please enter rock, paper, or scissors.");
if (playerChoice || playerChoice === "") {
const playerOne = playerChoice.trim().toLowerCase();
if (
playerOne === "rock" ||
@gitdagray
gitdagray / rps_v1.js
Last active March 21, 2025 15:15
Rock_Paper_Scissors_v1
// Your First Interactive Game
let playGame = confirm("Shall we play rock, paper, or scissors?");
if (playGame) {
//play
let playerChoice = prompt("Please enter rock, paper, or scissors.");
if (playerChoice) {
let playerOne = playerChoice.trim().toLowerCase();
if (
playerOne === "rock" ||
playerOne === "paper" ||
@gitdagray
gitdagray / checkOnlineStatus.js
Created July 29, 2020 20:16
checkOnlineStatus function
const checkOnlineStatus = async () => {
try {
const online = await fetch("/1pixel.png");
return online.status >= 200 && online.status < 300; // either true or false
} catch (err) {
return false; // definintely offline
}
};
@gitdagray
gitdagray / navigator_online.js
Created July 29, 2020 20:05
navigator.onLine with offline and online event listeners
window.addEventListener("load", (event) => {
const statusDisplay = document.getElementById("status");
statusDisplay.textContent = navigator.onLine ? "Online" : "Offline";
});
window.addEventListener("offline", (event) => {
const statusDisplay = document.getElementById("status");
statusDisplay.textContent = "OFFline";
});
@gitdagray
gitdagray / navigator_online_at_page_load.js
Last active July 29, 2020 20:03
navigator.onLine at page load
window.addEventListener("load", (event) => {
const statusDisplay = document.getElementById("status");
statusDisplay.textContent = navigator.onLine ? "Online" : "OFFline";
});
@gitdagray
gitdagray / online_offline_detection.js
Last active March 14, 2024 20:55
Online / Offline Status Detection w/ Async & Await
/* ********** Online / Offline Detection ********** */
// Request a small image at an interval to determine status
// ** Get a 1x1 pixel image here: http://www.1x1px.me/
// ** Use this code with an HTML element with id="status"
const checkOnlineStatus = async () => {
try {
const online = await fetch("/1pixel.png");
return online.status >= 200 && online.status < 300; // either true or false
@gitdagray
gitdagray / kanview_complete.py
Last active June 10, 2020 18:22
Full Python code for web scraping Kanview utilizing Selenium, Beautiful Soup, and pandas
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from bs4 import BeautifulSoup
import re
import pandas as pd
from tabulate import tabulate
import os
#launch url
url = "http://kanview.ks.gov/PayRates/PayRates_Agency.aspx"
@gitdagray
gitdagray / kanview_selenium5.py
Created February 18, 2018 18:25
Creating the JSON data file.
#get current working directory
path = os.getcwd()
#open, write, and close the file
f = open(path + "\\fhsu_payroll_data.json","w") #FHSU
f.write(json_records)
f.close()