Skip to content

Instantly share code, notes, and snippets.

View mstudio's full-sized avatar

Alex Motzenbecker mstudio

View GitHub Profile
@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 () {
@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 / 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 / withData.js
Created October 2, 2019 20:39
React HOC to load data and show Carbon v10 loader
/**
* withData HOC - loads any data as Promise.all, shows loading icon and passes data along via props to children
*/
import React, { Component } from 'react';
import { Loading } from 'carbon-components-react';
import ErrorModal from '../ErrorModal/ErrorModal';
import RequestUtils from '../../utilities/RequestUtils';
/**
@mstudio
mstudio / cloudSettings
Last active July 16, 2019 16:43
Alex - vscode settings
{"lastUpload":"2019-07-16T16:43:35.573Z","extensionVersion":"v3.4.0"}
@mstudio
mstudio / index.html
Last active September 7, 2018 13:53
D3 Transitions
<!DOCTYPE html>
<meta charset="utf-8">
<html>
<style>
body {
font: 10px sans-serif;
}
div {
@mstudio
mstudio / threejs.md
Last active June 29, 2017 15:15
ThreeJS Resources
@mstudio
mstudio / Chinese New Year
Last active January 2, 2016 15:39
Chinese New Year Dates and Animals (1924-2015) source: http://en.wikipedia.org/wiki/Chinese_zodiac
dates = [{
date : 'Feb 5 1924',
animal : 'Rat'
},
{
date : 'Jan 24 1925',
animal : 'Ox'
},
{
date : 'Feb 13 1926',
@mstudio
mstudio / hwk1
Created March 9, 2012 17:03
hwk1
//functional
function logCar(object) {
this.color = object.color;
this.make = object.make
console.log('I\'m a ' + this.color + ' ' + this.make);
}
// object-oriented
(function(window){
var main = function() {
var _index;
function iterate() {
console.log(_index);
if (_index > 1)
setTimeout(iterate, 1000);
_index--;
}