Skip to content

Instantly share code, notes, and snippets.

@ZachEngstrom
ZachEngstrom / package-check.sh
Created October 31, 2024 13:57
Shell script that checks if Git (or any other package) is installed and reachable on your system.
#!/bin/bash
# An associative array to store color codes for terminal output.
declare -A colors=(
[none]="\e[0;37m"
[green]="\e[0;32m"
[red]="\e[0;31m"
[blue]="\e[1;34m"
[darkcyan]="\e[0;36m"
[darkgreen]="\e[1;32m"
@ZachEngstrom
ZachEngstrom / Shell_Script_Markers.sh
Last active January 10, 2023 14:17
Shell snippet that sets text color and outputs an asterisk block
#!/bin/bash
# txtBold=$(tput bold)
txtError=$(tput setaf 1)
txtSuccess=$(tput setaf 2)
txtYellow=$(tput setaf 3)
txtInfo=$(tput setaf 6)
txtReset=$(tput sgr0)
iso8601() {
@ZachEngstrom
ZachEngstrom / zshrc.sh
Created January 21, 2020 19:03
React Native Repository Reset (Local)
# text colors for outputting messages
# put at top of file
txtError=$(tput bold && tput setaf 1)
txtSuccess=$(tput bold && tput setaf 2)
txtInfo=$(tput bold && tput setaf 6)
txtReset=$(tput sgr0)
# Used to calculate process duration
# put at top of file
function convertsecs() {
@ZachEngstrom
ZachEngstrom / functions.php
Created January 13, 2020 16:24
WordPress - Enqueue Custom Scripts on Certain Admin Pages
<?php
/**
* Load custom script on the following pages:
* - admin-page-menu-slug-url-01
* - admin-page-menu-slug-url-02
*
* @link https://www.webmaster-source.com/2013/02/06/using-the-wordpress-3-5-media-uploader-in-your-plugin-or-theme/
*/
if ( ! function_exists( 'prefix_plugintextdomain_admin_script' ) ) {
@ZachEngstrom
ZachEngstrom / functions.php
Last active January 13, 2020 16:19
WordPress - Add New User Programmatically
<?php
/**
* Create New User
*
* Add this code near the bottom of the functions.php file in your current (activated) theme
*
* Roles:
* 1 - Administrator (default if undefined)
* 2 - Editor
@ZachEngstrom
ZachEngstrom / git-workflow.md
Last active January 15, 2020 15:16
Git Workflow
  • Git workflow using terminal
    1. git checkout -b [my-feature] master - create new branch based on your up-to-date local master branch
    2. make edits and save the file(s) with your text editor
    3. git add [file.ext] - stage changes made to each file
    4. git commit -m "Message with specifics" - commit changes to [my-feature] branch
    5. git checkout master - switch to local master branch
    6. git pull origin master - pull changes from remote repo
    7. git checkout [my-feature] - switch back to local [my-feature] branch
    8. git rebase master - update local [my-feature] branch with new changes pulled from remote repo
  1. git checkout master - switch back to local master branch
@ZachEngstrom
ZachEngstrom / index.php
Created January 13, 2020 16:11
PHP Function - List all subdirectories #php
<?php
function listProjects($main) {
$dirHandle = opendir($main);
$dir_list = array();
while($file = readdir($dirHandle)){
if(is_dir($main.$file."/") && $file != '.' && $file != '..'){
$dir_list[] = $file;
}
}
natcasesort($dir_list);
@ZachEngstrom
ZachEngstrom / readme.md
Last active August 29, 2015 14:25
Wordpress - Function - Last modified date as version number for styles and scripts

Last Modified Date as Version Number
WordPress Function

This code automatically pulls in the date that the file was last modified as the version number for your styles and scripts. Notice how I've also included functions for manually setting version numbers too which works well for library files.

How WordPress renders the code:

  • Within the header
<link rel='stylesheet' id='bootstrap-css'  href='http://www.yoursite.com/wp-content/themes/yourtheme/assets/css/lib/bootstrap.min.css?ver=3.3.5' type='text/css' media='' />
<link rel='stylesheet' id='font-awesome-css'  href='http://www.yoursite.com/wp-content/themes/yourtheme/assets/css/lib/font-awesome.min.css?ver=4.3.0' type='text/css' media='' />
@ZachEngstrom
ZachEngstrom / functions.php
Last active August 24, 2022 05:09
Wordpress - Custom Breadcrumb Function
/**
* Adds Breadcrumbs to the page
* Add the function below to your functions.php file and then call it in the header or a page template
* functions.php location: /wp-content/themes/yourtheme/functions.php
* Put <?php custom_breadcrumbs(); ?> in the code where you would like it to appear
* Example output: Home / About Us / Our History
* In the example "Home" and "About Us" would be linked to their respective pages and "Our History" would not be linked because it is the current page
* If you are not using Bootstrap on your site you could easily style this with CSS to look the way you want it to
*/
function custom_breadcrumbs() {
@ZachEngstrom
ZachEngstrom / _mixins.scss
Last active August 29, 2015 14:16
Sass Mixin - Media Queries
/*
* ** Inline Media Queries **
*
* ********* WIDTHS *********
* min-sm-1 >= 767px
* max-sm-1 <= 767px
* min-sm >= 768px
* max-sm <= 768px
* sm-md = 768px-992px
* min-md-1 >= 991px