Skip to content

Instantly share code, notes, and snippets.

View TheGitPanda's full-sized avatar
🌴
On vacation

Panda TheGitPanda

🌴
On vacation
View GitHub Profile
@rafaelbeckel
rafaelbeckel / readvar.sh
Created March 17, 2018 20:11
Bash Script - Read variable from .env file
#!/bin/bash
read_var() {
VAR=$(grep $1 $2 | xargs)
IFS="=" read -ra VAR <<< "$VAR"
echo ${VAR[1]}
}
MY_VAR=$(read_var MY_VAR .env)
@twxia
twxia / getScrollableParent.js
Created January 5, 2018 03:41
Get Scrollable Parent
function getScrollParent(node) {
const isElement = node instanceof HTMLElement;
const overflowY = isElement && window.getComputedStyle(node).overflowY;
const isScrollable = overflowY !== 'visible' && overflowY !== 'hidden';
if (!node) {
return null;
} else if (isScrollable && node.scrollHeight >= node.clientHeight) {
return node;
}
@markthiessen
markthiessen / getWeeksInMonth.js
Last active August 9, 2024 13:52
JavaScript - get weeks in a month as array of start and end days
//note: month is 0 based, just like Dates in js
function getWeeksInMonth(year, month) {
const weeks = [],
firstDate = new Date(year, month, 1),
lastDate = new Date(year, month + 1, 0),
numDays = lastDate.getDate();
let dayOfWeekCounter = firstDate.getDay();
for (let date = 1; date <= numDays; date++) {