Skip to content

Instantly share code, notes, and snippets.

View kjbrum's full-sized avatar
🤘

Kyle Brumm kjbrum

🤘
View GitHub Profile
@kjbrum
kjbrum / wp_first_paragraph_excerpt.php
Last active April 16, 2020 12:08
Create a custom excerpt from the first paragraph of the content.
<?php
/**
* Create a custom excerpt string from the first paragraph of the content.
*
* @param integer $id The id of the post
* @return string $excerpt The excerpt string
*/
function wp_first_paragraph_excerpt( $id=null ) {
// Set $id to the current post by default
if( !$id ) {
@kjbrum
kjbrum / scrollWindow.js
Last active January 12, 2018 21:02
Scroll window to an element
/**
* Scroll window to an element
*/
$('a[href^="#"]').not('a[href="#"]').click(function(e) {
e.preventDefault();
$('html, body').animate({
scrollTop: $($(this).attr('href')).offset().top
}, 500);
});
@kjbrum
kjbrum / WordPress Setup Script.md
Last active March 10, 2018 18:31
Easily set up a project with a Bitbucket repository, ServerPilot application, base plugin and theme, as well as run miscellaneous WordPress tasks.

WordPress Setup Script

Easily set up a project with a Bitbucket repository, ServerPilot application, base plugin and theme, as well as run miscellaneous WordPress tasks. Should be used with https://github.com/Mixd/wp-deploy.

Step 1: Setup project

# Enter your project directory
cd your/desired/project/directory
#! /bin/bash
# Source our config file
. config/config.cfg
# Function to generate random characters
function random_chars() {
if [ $1 ]; then
serverpilot_client_id=""
serverpilot_api_key=""
bitbucket_username=""
bitbucket_password=""
serverpilot_staging_user_id=""
base_plugin=""
base_theme=""
@kjbrum
kjbrum / bash_profile.sh
Last active December 27, 2024 21:34
My personal bash profile
#---------------------------------------------------------------------------------------------------------------------------------------
#
# Author: Kyle Brumm
# Description: File used to hold Bash configuration, aliases, functions, completions, etc...
#
# Sections:
# 1. ENVIRONMENT SETUP
# 2. MAKE TERMINAL BETTER
# 3. FOLDER MANAGEMENT
# 4. MISC ALIAS'
@kjbrum
kjbrum / randpass.sh
Last active October 28, 2016 22:55
Generate a random password and copy it to your clipboard.
#!/usr/bin/env bash
# Randpass - Random Password Generator
# Generate a random password and copy it to your clipboard.
# Copyright (C) Kyle Brumm <http://kylebrumm.com>
# Display the help text
usage() {
cat << EOF
@kjbrum
kjbrum / search-and-kill.sh
Created August 11, 2015 04:34
A small bash script to search and kill processes
#!/bin/bash
if [ -z "$1" ]; then
echo "You need to supply a search string..."
else
processes=$(ps aux | grep $1 -i | awk -F ' ' '{print $2}' | xargs)
echo "Processes: "$processes
while true; do
read -ep "Are you sure you want kill all '$1' processes? [y/N] " yesno
case $yesno in
@kjbrum
kjbrum / wp_display_404.php
Last active May 21, 2016 02:16
Display the 404 template.
<?php
$wp_query->set_404();
require TEMPLATEPATH.'/404.php';
exit;
@kjbrum
kjbrum / is_multi_array.php
Last active November 11, 2015 20:36
Check if an array is a multidimensional array.
<?php
/**
* Check if an array is a multidimensional array.
*
* @param array $arr The array to check
* @return boolean Whether the the array is a multidimensional array or not
*/
function is_multi_array( $x ) {
if( count( array_filter( $x,'is_array' ) ) > 0 ) return true;
return false;