Skip to content

Instantly share code, notes, and snippets.

View prof3ssorSt3v3's full-sized avatar
🎯
Focusing

Steve Griffith prof3ssorSt3v3

🎯
Focusing
View GitHub Profile
//finite state machine
const machine = {
state: "SOBER",
transitions: {
SOBER: {
drink: function(beverage, second) {
console.log("current state", this.state);
console.log("\tdrinking", beverage.type); //second would be undefined
if (beverage.type == "alcohol") {
console.log("\tAdios inhibitions!");
//https://www.npmjs.com/package/cordova-plugin-android-volume
//plugin to retrieve the android system volumes
// https://cordova.apache.org/docs/en/latest/reference/cordova-plugin-media/index.html
// cordova media plugin
let app = {
track: {
src: 'file:///android_asset/www/media/fight-club.mp3',
title: 'Fight Club Rules',
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Form Events</title>
<style>
* {
padding: 0;
margin: 0;
@prof3ssorSt3v3
prof3ssorSt3v3 / index.html
Created June 16, 2022 17:47
CSS :is() :where and :has() pseudo class example code
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width,initial-scale=1.0" />
<link rel="stylesheet" href="style.css" />
<title>CSS :is :where :has</title>
<link href="./main.css" rel="stylesheet" />
</head>
@prof3ssorSt3v3
prof3ssorSt3v3 / app.js
Created February 23, 2021 20:02
indexedDB part 3 - get( ) and getAll( )
import { uid } from './uid.js';
console.log(uid());
//nothing else to import because we are using the built in methods
//https://developer.mozilla.org/en-US/docs/Web/API/IDBDatabase
const IDB = (function init() {
let db = null;
let objectStore = null;
let DBOpenReq = indexedDB.open('WhiskeyDB', 6);
const http = require("http");
const fs = require("fs");
const server = http.createServer(function(req, res) {
let img = __dirname + "/pod.jpg";
fs.access(img, fs.constants.F_OK, err => {
//check that we can access the file
console.log(`${img} ${err ? "does not exist" : "exists"}`);
});
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>HTML Templates</title>
<meta name="viewport" content="width=device-width">
<style>
.temp{
background-color: cornflowerblue;
color: #fff;
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta
name="Content-Security-Policy"
content="default-src: http: https: 'self'"
/>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
@prof3ssorSt3v3
prof3ssorSt3v3 / data.json
Created March 26, 2024 13:11
Sample book data
{
"categories": ["historical fiction", "science fiction", "fantasy", "romance", "non-fiction", "programming", "classic"],
"books": [
{ "id": "cc196ef3-431f-4238-8aea-8a94e73229a4", "category": "science fiction", "title": "the 3 body problem", "author": "cixin lin" },
{ "id": "e2fd5989-6908-45c5-91db-d6e561fc8b8b", "category": "fantasy", "title": "the hobbit", "author": "j.r.r. tolkien" },
{ "id": "ee69e09a-61f0-4c19-bbbc-826399f678c4", "category": "programming", "title": "web developers practical guide to flutter", "author": "steve griffith" },
{ "id": "dbc27431-33b4-49fb-82a4-1ab9bea0f26a", "category": "classic", "title": "moby dick", "author": "herman melville" },
{ "id": "ef78671c-d518-468c-bfdf-4786c3a03c19", "category": "non-fiction", "title": "superintelligence", "author": "nick bostrom" }
]
}
@prof3ssorSt3v3
prof3ssorSt3v3 / index.html
Created May 10, 2023 18:01
Code from video about practical uses for Array.from() and all of it's parameters applied to Objects and NodeLists and copied Arrays
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
<script src="main.js" type="module"></script>
</head>
<body>