Skip to content

Instantly share code, notes, and snippets.

View kodie's full-sized avatar
💻
#doworkson

Kodie Grantham kodie

💻
#doworkson
View GitHub Profile
@kodie
kodie / scan-projects-for-git-changes.sh
Created May 2, 2024 22:21
A small one-liner bash script that will scan through all of the directories inside of the current directory and let you know if they have any changes not yet pushed up to your git repository.
for d in */ ; do echo "Checking for changes in $d..."; cd $d; if [[ `git status --porcelain` ]]; then echo "\033[0;32mChanges found in $d\033[0m"; fi; cd ../; done
@kodie
kodie / array_map_assoc.php
Last active April 24, 2024 12:04
Array map function that allows you to change keys as well as values
<?php
// Array map function that allows you to change keys as well as values
// Example: array_map_assoc(function($k, $v) { return array($k => $v); }, $array);
function array_map_assoc(callable $f, array $a) {
return array_merge(...array_map($f, array_keys($a), $a));
}
?>
@kodie
kodie / updateModified.js
Last active April 15, 2024 07:02
A JavaScript function for Google Sheets that updates a specific cell with the current date/time when cell(s) are updated.
function getColumnNumberByName(name, sheet) {
if (!sheet) {
sheet = SpreadsheetApp.getActiveSheet()
}
var headers = sheet.getDataRange().offset(0, 0, 1).getValues()[0]
var column = false
for (var i = 0; i < headers.length; i++) {
if (headers[i].trim() === name) {
@kodie
kodie / hmodal.js
Created September 12, 2023 18:23
A modal function created by a former HM developer - Simply here so we can pull it in remotely until it can be replaced
// BUG
// Sometimes a newly opened modal sets the image height to zero
// Stupid ios menu bar showing/hiding counts as a screen resize
// Can't calculate height with padding before resize to adjust top positioning
// - After resize, calculate the difference between the height of the content
// and the height of the image-holder and set the top of the content to
// scrollTop + the difference in top height
// -------------------------------------------------------------------------------
@kodie
kodie / jquery-wrap-text-plugin.js
Created July 28, 2023 15:27
A wrap text jQuery plugin - Originally created by the good people over at PSD2HTML.com - Simply here so we can pull the code in remotely
/*
* jQuery wrap text plugin
*/
;(function($) {
function WrapText(options) {
this.options = $.extend({
holder: '.wrap-text',
wrapBefore: '<span>',
wrapAfter: '</span>',
wrapTag: 'span',
@kodie
kodie / jquery-sticky-box-plugin.js
Created July 28, 2023 15:22
A sticky box jQuery plugin - Originally created by the good people over at PSD2HTML.com - Simply here so we can pull the code in remotely
/*
* jQuery sticky box plugin
*/
;(function($, $win) {
'use strict';
function StickyScrollBlock($stickyBox, options) {
this.options = options;
this.$stickyBox = $stickyBox;
this.init();
@kodie
kodie / jquery-open-close-plugin.js
Created July 28, 2023 15:18
A accordion jQuery plugin - Originally created by the good people over at PSD2HTML.com - Simply here so we can pull the code in remotely
/*
* jQuery Open/Close plugin
*/
;(function($) {
function OpenClose(options) {
this.options = $.extend({
addClassBeforeAnimation: true,
hideOnClickOutside: false,
activeClass: 'active',
opener: '.opener',
@kodie
kodie / responsive-layout-helper.js
Created July 28, 2023 15:15
A responsive layout helper jQuery plugin - Originally created by the good people over at PSD2HTML.com - Simply here so we can pull the code in remotely
/*
* Responsive Layout helper
*/
ResponsiveHelper = (function($){
// init variables
var handlers = [],
prevWinWidth,
win = $(window),
nativeMatchMedia = false;
@kodie
kodie / Tribe__Events__Filterbar__Filters__Category_Custom.php
Created November 4, 2022 20:21 — forked from elimn/Tribe__Events__Filterbar__Filters__Category_Custom.php
MT | TEC | Customized version of the Category Filter that includes CSS classes for subcategories
<?php
/**
* Customized version of the Category Filter that includes CSS classes for subcategories
* New filter available in WP-Admin > Events > Settings > Filters
*/
if ( class_exists( 'Tribe__Events__Filterbar__Filters__Category' ) ) {
class Tribe__Events__Filterbar__Filters__Category_Custom extends Tribe__Events__Filterbar__Filters__Category {
@kodie
kodie / wp_numeric_pagination.php
Created October 31, 2022 23:41
Displays numeric pagination links in WordPress
<?php
// Displays numeric pagination links
function numeric_pagination($query = null, $echo = true) {
if (!$query) {
global $wp_query;
$query = $wp_query;
}
$total_pages = $query->max_num_pages;
$big = 999999999; // need an unlikely integer