Skip to content

Instantly share code, notes, and snippets.

View mattkenefick's full-sized avatar
🏠
Working from home

Matt Kenefick mattkenefick

🏠
Working from home
View GitHub Profile
@mattkenefick
mattkenefick / dispatch.ts
Created July 15, 2024 19:36
Bubble events in Vue 2.0
/**
* Example:
*
* import Vue from 'vue';
* import Dispatch from './dispatch';
* Vue.use(Dispatch);
*
* @author Matt Kenefick <matt@polymermallard.com>
* @package Plugin
* @project Your Project
@mattkenefick
mattkenefick / functions.js
Last active July 13, 2024 16:07
parentSelector
// interface Element {
// parentSelector(selector: string): Element | null;
// previousSelector(selector: string, traverseUpwards?: boolean): Element | null;
// previousSelectorAll(selector: string, traverseUpwards?: boolean): Element[];
// }
/**
* Traverse upward from an existing element.
*
* @param string selector
@mattkenefick
mattkenefick / .browserslistrc
Created June 23, 2024 23:53
Boilerplate! Hidden files
# This file is used by the build system to adjust CSS and JS output to support the specified browsers below.
# For additional information regarding the format and rule options, please see:
# https://github.com/browserslist/browserslist#queries
# For the full list of supported browsers by the Angular framework, please see:
# https://angular.io/guide/browser-support
@mattkenefick
mattkenefick / index.html
Created December 14, 2023 19:52
Luma example
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>Three.js Basic Scene</title>
<style>
body {
margin: 0;
}
</style>
@mattkenefick
mattkenefick / receiveTwilio.js
Created December 6, 2023 18:20
Twilio Google Sheets Macro
// Constants
const TWILIO_ACCOUNT_SID = 'AC94f51c8f89430a6...'; // change me
const TWILIO_ACCOUNT_TOKEN = '426cee8c3...'; // change me
const TWILIO_PHONE = '+18005551234'; // change me
const NUMBER_TO_RETRIEVE = 1000;
const HOURS_OFFSET = 0;
const START_COLUMN = 2;
const START_ROW = 3;
/**
@mattkenefick
mattkenefick / scroll-distance.js
Created December 3, 2023 19:15
Get normalized value of scroll amount of window
document.addEventListener('scroll', (e) => {
const documentHeight = document.documentElement.scrollHeight;
const windowHeight = window.innerHeight;
const scrollDistance = window.scrollY;
const ratio = scrollDistance / (documentHeight - windowHeight);
console.log(ratio);
});
/**
* Usage:
*
* const ratio = approximateAspectRatio(855, 482, 20);
* // "16:9"
*
* @param number width
* @param number height
* @param number maxRatio
* @return string
<section class="view-${input.filename}">
My Template
</section>
@mattkenefick
mattkenefick / index.html
Last active November 6, 2023 14:40
Ultra Generic Website Starter Kit
<!DOCTYPE html>
<html>
<head>
<style>
body {
background: black;
color: white;
font-family: sans-serif;
}

Composition and inheritance are both fundamental concepts in object-oriented programming (OOP) that help in organizing and structuring code. While they achieve similar goals, they differ in their approach and usage. Here's a comparison between composition and inheritance:

Composition:

  1. Composition is a design principle that allows objects to be composed of other objects or components.
  2. It emphasizes building complex functionality by combining simpler, reusable components.
  3. It follows the "has-a" relationship, where an object contains or is composed of other objects.
  4. Components can be dynamically composed or changed at runtime, providing flexibility and modularity.
  5. Composition promotes code reusability, as components can be shared across different objects.
  6. It encourages loose coupling between objects, making the system more maintainable and adaptable.
  7. Composition can lead to a more modular and flexible code structure, as components can be easily replaced or modified without affecting the ent