Skip to content

Instantly share code, notes, and snippets.

View mstudio's full-sized avatar

Alex Motzenbecker mstudio

View GitHub Profile
@mstudio
mstudio / toICSDateFormat.js
Last active April 19, 2022 15:28
Converts a Javascript UTC date string into the proper format for ICS calendar files for DTSTAMP, DTSTART and DTEND
/**
* Converts a UTC date into the proper format for ICS calendar files for DTSTAMP, DTSTART and DTEND
* @param {String} isoDateString, e.g. new Date().toISOString()
* @returns {String} formatted as UTC date for ICS files, e.g. 20220511T170000Z
*/
const toICSDateFormat = (isoDateString) => {
const dateArray = isoDateString.split("T");
const day = dateArray[0].replace(/-/g, "");
const time = dateArray[1].replace(/[a-zA-Z]+/g, "").split(":");
@mstudio
mstudio / scrollToUtil.js
Created April 27, 2022 16:16
Scroll to a particular element
/**
* Smooth scrolls to an element's position
* @param {string} buttonSelector
* @param {string} gotoSelector - element to scroll to
* @param {Number} yOffset - Y offset for scrolling
*/
export const addScrollLink = (
buttonSelector,
gotoSelector,
yOffset = 0,
@mstudio
mstudio / update-git-submodules.sh
Created March 6, 2024 15:35
Recursively update all git submodules in a direcory
#!/bin/bash
# Updates Git submodules to latest commit
# use:
# $bash update-submodules.sh WORKING_DIRECTORY SUBMODULE_DIRECTORY SHOULD_UPDATE_GIT
# sample use:
# $ bash update-submodules.sh ~/code/my-repo my-submodule true
update_submodule () {