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

DGTC Discord Code of Conduct

Welcome!

The purpose of this server is to help you learn about all things code, programming, and web development as well as connect with others that are doing the same.

The current admins are:

  • Dave Gray (owner)
@gitdagray
gitdagray / js_chapter_22_html.html
Created January 3, 2022 17:11
JS Chapter 22 HTML
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>My Page</title>
<link rel="stylesheet" href="css/js_chapter_22_css.css" />
<script defer src="js/main.js"></script>
</head>
@gitdagray
gitdagray / js_chapter_22_css.css
Created January 3, 2022 17:09
JS Course Chapter 22 CSS
* {
margin: 0;
padding: 0;
-webkit-box-sizing: border-box;
box-sizing: border-box;
}
html {
font-family: Arial, Helvetica, sans-serif;
font-size: 16px;
@gitdagray
gitdagray / index.html
Created November 21, 2021 23:17
HTML and CSS for Javascript DOM Tutorial
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>My Page</title>
<style>
* {
margin: 0;
padding: 0;
@gitdagray
gitdagray / memoize.js
Last active February 8, 2024 14:45
A memoize decorator function that is capable of handling multiple parameters
// A memoize decorator function
// that is capable of handling multiple parameters
export const memoize = (fn) => {
const cache = {};
return (...args) => {
if (JSON.stringify(args) in cache) {
// if you want to verify result comes from cache
console.log(cache);
return cache[JSON.stringify(args)];
@gitdagray
gitdagray / js_object_composition.js
Created August 18, 2021 15:38
Javascript Object Composition
// Class with methods
class Pizza {
constructor(size, crust, sauce) {
this.size = size;
this.crust = crust;
this.sauce = sauce;
this.toppings = [];
}
prepare() { console.log('Preparing...') }
bake() { console.log('Baking...') }
@gitdagray
gitdagray / decorators.js
Created August 11, 2021 19:30
Using multiple decorators
// Our basic function
let rectangleArea = (length, width) => {
return length * width;
}
// A decorator that counts the parameters
const countParams = (fn) => {
return (...params) => {
console.log('countParams')
if (params.length !== fn.length) {
@gitdagray
gitdagray / functional_composition_example
Created June 4, 2021 14:46
Functional composition for Vehicle and Motorcycle
// Define methods first. They can be used when building any object.
const readyToGo = () => {
return {
readyToGo() { console.log('Ready to go!') }
}
}
const wheelie = () => {
return {
@gitdagray
gitdagray / util.js
Last active February 8, 2024 14:15
Javascript Utility Functions
// Youtube tutorial here: https://youtu.be/LDgPTw6tePk
// These functions are designed to be exported, but you could create a class instead. See tutorial video.
// #1 proper case
export const properCase = (string) => {
return `${string[0].toUpperCase()}${string.slice(1).toLowerCase()}`;
};
@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>