Skip to content

Instantly share code, notes, and snippets.

View scottnunemacher's full-sized avatar
😁
Doing the things

Scott Nunemacher scottnunemacher

😁
Doing the things
View GitHub Profile
@scottnunemacher
scottnunemacher / docker-help.md
Last active December 21, 2018 02:53 — forked from bradtraversy/docker-help.md
Docker Commands, Help & Tips

Docker Commands, Help & Tips

Show commands & management commands

$ docker

Docker version info

@scottnunemacher
scottnunemacher / dovecot-doveadm-sync.md
Last active April 28, 2024 19:06
Sync (migrate) a Dovecot Email Account from One Dovecot Server to Another

Sync (migrate) a Dovecot Email Account from One Dovecot Server to Another

The man doveadm-sync pages are cryptic and not very well explained, as well they are missing quality real-world examples.

This gist aims to give some clarity and explanation.

Here is the command I got to successfully transfer (and sync backwards too) an email account from an old Dovecot email server to a new Dovecot email server:

To my knowledge, both servers must have a matching account already setup for this to work:

@scottnunemacher
scottnunemacher / myscript.sh
Created October 6, 2021 12:20 — forked from bradtraversy/myscript.sh
Basic Shell Scripting
#! /bin/bash
# ECHO COMMAND
# echo Hello World!
# VARIABLES
# Uppercase by convention
# Letters, numbers, underscores
NAME="Bob"
# echo "My name is $NAME"
@scottnunemacher
scottnunemacher / return-plural-if-needed.php
Last active August 8, 2022 18:11
PHP - Test a value and return plural if needed.
<?php
function get_plural($value, $singular, $plural = NULL){
if($value == 1){
return $singular;
} else {
if(!isset($plural)){
$plural = $singular.'s';
}
return $plural;
}
@scottnunemacher
scottnunemacher / custom-search-results-subheading.php
Last active March 6, 2023 16:09
Custom Search Results Subheading
<?php
// Custom Search Results Subheading
add_filter( 'custom_search_results_subheading', function( $subheading ) {
if ( is_search() ) {
global $wp_query;
$posts_per_page = $wp_query->query_vars['posts_per_page'];
$posts_found = $wp_query->found_posts;
if ( $posts_found ) {
$subheading = sprintf(
esc_html__( 'Displaying results 1-%1$s out of %2$s for %3$s', 'total' ),
@scottnunemacher
scottnunemacher / get-post-slug.php
Created October 13, 2022 19:09
WP Get Post Slug
<?php
$slug = get_post_field( 'post_name', get_post() );
echo $slug;
?>
@scottnunemacher
scottnunemacher / find-recursively-and-cp-to-flat.sh
Last active January 5, 2023 17:56
Find recursively all files of extension and cp to flat directory
find . -name "*.pdf" -type file -exec cp {} /path/to/directory \;
@scottnunemacher
scottnunemacher / ssh-keygen-notes.sh
Last active January 5, 2023 17:56
ssh-keygen notes
# ssh-keygen for ed25519
ssh-keygen -a 100 -t ed25519 -f "/ABSOLUTE/PATH/TO/.ssh/PROFILE_SAASPROVIDER_ed25519" -C "PROFILE_SAASPROVIDER_ed25519"
# ssh-keygen for rsa 4096
ssh-keygen -b 4096 -t rsa -f "/ABSOLUTE/PATH/TO/.ssh/PROFILE_SAASPROVIDER_rsa" -C "PROFILE_SAASPROVIDER_rsa"
@scottnunemacher
scottnunemacher / highlight-words-on-search.js
Created January 26, 2023 16:10
JS - Highlight all matches to search input on Enter.
// From: https://codingartistweb.com/2021/06/highlight-searched-text-with-javascript/
function search() {
// Use the id of the input ex: text-to-search
let textToSearch = document.getElementById("text-to-search").value;
// Use the id of the source to be searched ex: paragraph
let paragraph = document.getElementById("paragraph");
// Characters in search input to be escaped: [.*+?^${}()|[\]\\]
textToSearch = textToSearch.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
let pattern = new RegExp(`${textToSearch}`, "gi");
@scottnunemacher
scottnunemacher / get-parent-directory.sh
Created January 31, 2023 23:13
Getting the parent of a directory from bash variable
#!/usr/bin/env bash
# From: https://stackoverflow.com/a/42956288
# example: dir=/home/smith/Desktop/Test
parentdir=$(builtin cd $dir; pwd)