Skip to content

Instantly share code, notes, and snippets.

View monkishtypist's full-sized avatar
👻

Tim Spinks monkishtypist

👻
  • BASIC/DEPT®
  • PNW
View GitHub Profile
@monkishtypist
monkishtypist / bs-exit-pop.js
Last active December 13, 2016 20:12
Bootstrap Exit Pop
/* Simple Bootstrap jQuery Exit Pop
* Trigger an existing Bootstrap modal on mouseleave()
*/
/* This first version uses a variable to determine when to trigger pop. */
(function(){
var pop = false; /* it has not pop'd */
jQuery(document).mouseleave(function(){
if(!pop || typeof pop === 'undefined'){
jQuery('#myModal').modal('show'); /* show the modal */
@monkishtypist
monkishtypist / class-custom-post-type-faqs.php
Created September 9, 2018 17:14
FAQs custom post type for WordPress
<?php
/*
Plugin Name: FAQs Custom Post Type
Plugin URI: https://github.com/monkishtypist
Description: This `mu-plugin` class creates a new custom post type for Frequently Asked Questions.
Version: 1.0
Author: Tim Spinks @monkishtypist
Author URI: https://github.com/monkishtypist
*/
@monkishtypist
monkishtypist / wp_permissions.sh
Last active August 30, 2023 15:56
WordPress file/folder permissions for Amazon EC2 Ubuntu instance
#!/bin/bash
# Location: Anywhere
# Add existing 'ubuntu' user to 'www-data' group
sudo usermod -a -G www-data ubuntu;
# Set the ownership of the files/directories
sudo chown -R www-data:www-data /var/www/html/;
# Set group ownership inheritance
@monkishtypist
monkishtypist / class-custom-post-type-leadership-team.php
Last active September 22, 2018 00:19
WordPress `mu-plugin` to create a custom post type for Leadership Team.
<?php
/*
Plugin Name: Leadership Team Custom Post Type
Plugin URI: https://github.com/monkishtypist
Description: This `mu-plugin` class creates a new custom post type for Leadership Team.
Version: 1.0
Author: Tim Spinks @monkishtypist
Author URI: https://github.com/monkishtypist
*/
@monkishtypist
monkishtypist / nav-dropdown-gap-fix.js
Created September 29, 2018 00:18
Nav fix for Dropdown gaps (Bootstrap)
/**
* Nav Fix for Dropdown Gaps (Bootstrap)
*
* This jQuery fixes hover state issues when the menu dropdown
* has a gap from its parent nav item, thus closing the dropdown
* before the cursor can span the gap. This adds a slight delay
* to allow the cursor to cross the gap before the dropdown is
* closed.
*/
(function( $ ) {
@monkishtypist
monkishtypist / add_bootstrap_class_to_images.php
Created October 7, 2018 17:52
Add Bootstrap image classes to WordPress media attachments
/**
* Add the following to your theme's `functions.php` to automatically add `img-fluid` class
* to all images inserted using the "Add Media" upload button in WordPress editor.
*/
if ( ! function_exists( 'add_bootstrap_class_to_images' ) ) {
function add_bootstrap_class_to_images( $html, $attachment_id, $attachment ) {
$img_element = "/<img[^>]*>/";
$found = preg_match( $img_element, $html, $image );
// If no image, do nothing
@monkishtypist
monkishtypist / bootstrap-carousel-height-fix.js
Last active October 27, 2018 16:07
Set Bootstrap carousel item heights
@monkishtypist
monkishtypist / hosts
Last active July 8, 2024 11:02
Nginx virtual host example for Windows Subsystem for Linux (WSL)
# Location: /mnt/c/windows/system32/drivers/etc/hosts
127.0.0.1 virtualhost.local www.virtualhost.local
@monkishtypist
monkishtypist / functions.php
Last active June 7, 2019 07:22
Bootstrap Buttons via Wordpress shortcode
add_shortcode( 'button', 'wpbs_button', 10, 2 );
if ( ! function_exists( 'wpbs_button' ) ) {
/**
* Custom Button
*
* Add an inline button to content, with customizeable CSS classes, and
* link to a page by `page-id` or URL.
*
* [button class="btn-primary"]My Button Text[/button]
*
@monkishtypist
monkishtypist / process-images.py
Last active March 31, 2022 18:25
Image Compression and Resize with Python3 and Pillow
from PIL import Image
import getopt
import os
import shutil
import sys
def process_images(argv):
arg_help = "{0} -i <input_folder> -o <output_folder> -a -c -d <delimiter> -f -s".format(argv[0])
# Args