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

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
@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;
}
@mattkenefick
mattkenefick / README.md
Last active August 25, 2023 04:29
Combine two env/ini files and remove duplicate entries

Purpose

If you're making a project where you need a base level of configs and various combinations of overrides... this merge.sh script will let you combine multiple .env or .ini files (key/value) and remove duplicates based on the key.

Usage Example

Create both files in a structure like:

    specific.env
 base.env
@mattkenefick
mattkenefick / .bash_profile
Created February 9, 2023 14:53
Convert a file or directory into webp files from jpg, jpeg, or png
#
# Convert a file, or folder, into webp
# Example:
# toWebp splash-01.png
# toWebp splash-01.jpg
# toWebp splash-01.jpeg
# toWebp ./images
# toWebp
#
@mattkenefick
mattkenefick / bookmarklet
Last active February 5, 2023 17:19
Wraps your website in a visually simulated iPhone
javascript:(function(){ const script = document.createElement('script'); script.src = 'https://buck-web-javascript.s3.us-west-2.amazonaws.com/iphone-simulator/simulate-iphone.js'; document.body.appendChild(script); })();