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 / digitalocean-create-sudo-sftp-ssh-user.md
Created March 6, 2023 16:04
DigitalOcean Create sudo SFTP/SSH user

DigitalOcean Create sudo SFTP/SSH user

WARNING Create a snapshot before doing any changes!!!

Example new user data:

  • Username: exampleuser
  • Password: examplepassword
  • Home: /home/exampleuser/
  • IP: exa.mp.le.ip
@scottnunemacher
scottnunemacher / find-years-from-start-date.php
Created March 10, 2023 18:56
PHP - Find Years From Start Date
<?php
$startDate = new DateTime("1976-04-30");
$today = new DateTime('Y');
$interval = $startDate->diff($today);
echo $interval->y . " YEARS";
?>
@scottnunemacher
scottnunemacher / wordpress-display-post-tag-links.php
Created August 28, 2023 22:50
Wordpress - Display Loop's Post Tag Links - Ex: display tag links for an article
<?php
// Will output links displayed like:
// Tags: Article Tag | Other Article Tag | Another Article Tag
$post_tags = get_the_tags();
$separator = ' | ';
$output = '';
if (!empty($post_tags)) {
echo "Tags: ";
@scottnunemacher
scottnunemacher / wordpress-display-post-category-link.php
Created August 29, 2023 19:18
Wordpress - Display Loop's Post Category Link - Ex: display category link for an article
<?php
//Note Wordpress only uses the first category applied to a post.
$category = get_the_category();
if (!empty($category)) {
echo 'Category: <a class="post-category" href="' . esc_url(get_category_link($category[0]->term_id)) . '">' . esc_html($category[0]->name) . '</a>';
}