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 / 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
@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); })();
@mattkenefick
mattkenefick / gist:a856ee60dfca78b6306acbe909531b8b
Created January 18, 2023 15:37
Setup a new PS1 for Powershell
# code $profile
function Write-BranchName () {
try {
$branch = git rev-parse --abbrev-ref HEAD
if ($branch -eq "HEAD") {
# we're probably in detached HEAD state, so print the SHA
$branch = git rev-parse --short HEAD