Skip to content

Instantly share code, notes, and snippets.

View ronaldroe's full-sized avatar

Ronald Roe ronaldroe

View GitHub Profile
@ronaldroe
ronaldroe / pmft.js
Last active August 29, 2015 14:09
The Poor Man's FitText
/* Requires jQuery
** Include this file or copy/paste into your document.
** Call the function, passing the selector as a jQuery-style string.
** Offset is a number used to keep the text just short of the width of the parent to avoid rounding errors that will wrap the text.
** You can use the offset to adjust how close you want the width to be. Offset is optional and defaults to 10.
** Step defines the increase in font size. If you find one or more of your elements pushes out further than the others, adjust this
** number.
** For this to work, the element containing the text must be set to display:inline or inline-block, and the parent should be anything
** other than inline. So, if you have an h1 inside a header, you will need to make sure the h1 is inline or inline-block and the header
** isn't inline.
@ronaldroe
ronaldroe / niceMenu.css
Last active August 29, 2015 14:10
niceMenu.js - Similar to Mean Menu, but supports converting multiple menus into one
/*!** NICE MENU ***/
/*! Compiled from SCSS - also attached */
body.hasNiceMenu {
padding-top: 44px; }
.niceMenu {
background: rgba(0, 0, 0, 0.8);
position: fixed;
top: 0;
@ronaldroe
ronaldroe / Gruntfile.js
Created March 8, 2016 23:05
My Wordpress Theme Dev Grunt Setup
module.exports = function(grunt) {
// Project configuration.
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
sass: {
dist:{
options: {
style: 'expanded',
compass: true
@ronaldroe
ronaldroe / cloudSettings
Created October 31, 2018 18:05
Visual Studio Code Settings Sync Gist
{"lastUpload":"2018-10-31T18:05:50.635Z","extensionVersion":"v3.2.0"}
@ronaldroe
ronaldroe / flatten-test.js
Last active December 13, 2023 15:27
Array Flatten
// This test takes an array, loops through each top level index
// and logs an error if the index contains an array.
// Passes are tallied, and passes/fails are output at the end of the test.
const flattenTest = arr => {
// Define error message and initialize pass counter
const errorMessage = ind => `Index ${ind} contains an array`;
let passCount = 0;
const XML2JSON = (xml, selector) => {
let entries = xml.querySelectorAll(selector);
let outData = [];
Array.from(entries).forEach((entry, i) => {
outData[i] = {};
Array.from(entry.children).forEach(node => {
let nav_buttons = document.querySelectorAll('.nav');
function addNavButtonListeners() {
Array.from(nav_buttons).forEach(button => {
button.addEventListener('click', e => {
console.log(button);
e.preventDefault();
if(button.classList.contains('next')){
switchPanel();
<!DOCTYPE html>
<html>
<head>
<title>Delivery/Event Dates | Flower Moxie</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/flatpickr/4.6.6/flatpickr.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/axios/0.17.1/axios.min.js"></script>
<script type="text/javascript" src="supplies.js"></script>
<link rel="stylesheet" href="supply.css" type="text/css" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/flatpickr/4.6.6/flatpickr.min.css">
<style>
@ronaldroe
ronaldroe / npm-install-all.sh
Created May 19, 2022 00:41
Runs `npm install` in all child directories
rootdir=`pwd`
echo $rootdir
for dir in */; do
cd "$rootdir/$dir"
echo "Installing $dir at $PWD"
npm i
done
@ronaldroe
ronaldroe / recurse_obj.js
Last active February 28, 2023 14:32
Recurse JavaScript Object from Path
/**
* Recursive function to walk down into the config object and return the requested data
*
* @param {string[]} pathArray Array containing the paths to the requested key
* @param {Object} inputObj The object being traversed.
* @param {number} [idx=0] Current index. Used internally to determine where in the pathArray we are
*
* @returns {any|null} Requested config setting(s)
*/
const recurseConfigPath = (pathArray, inputObj, idx = 0) => {