Skip to content

Instantly share code, notes, and snippets.

View joshespi's full-sized avatar

Josh Espinoza joshespi

View GitHub Profile
@joshespi
joshespi / abbreviate.php
Last active May 28, 2023 16:00
Swap abbreviated versions of words/names with PHP
function apply_abbreviations($string) {
$abbreviated_words = [
"Teaching and Learning" => "T&L",
"Teaching & Learning" => "T&L",
"Human Resources" => "HR",
"Admin" => "Administrator",
"Asst" => "Assistant",
"Elem" => "Elementary",
"Sec" => "Secondary",
];
@joshespi
joshespi / update.sh
Last active August 28, 2022 03:56
APT update everything, cleanup, reboot
#!/bin/bash
sudo apt update --fix-missing -y && sudo apt dist-upgrade -y && sudo apt autoremove -y && sudo apt autoclean -y && sudo shutdown -r now
@joshespi
joshespi / chromefunction.sh
Created November 30, 2021 22:20
detect if chrome is running
#!/bin/bash
SERVICE="chromium"
if pgrep "$SERVICE" > /dev/null
then
echo "$SERVICE is running"
#for SNMP
echo "0"
else
echo "$SERVICE stopped"
#for SNMP
@joshespi
joshespi / index.php
Last active May 28, 2023 15:57
basic wordpress loop
<?php
// Start “The Loop”
if ( have_posts() ) : // Does our website have any posts to display?
while ( have_posts() ) : the_post(); // If the answer is “yes”, let’s run some code.
the_title( '<h2>', '</h2>' ); // Let’s display the title of our post.
the_content(); // Let’s display the content of our post.
@joshespi
joshespi / backup.sh
Last active August 11, 2023 16:23
pcsd - pi device, ship backup folder to backup server.
#!/bin/bash
hs=$HOSTNAME
# Trap interrupts and exit instead of continuing the loop
trap "echo Exited!; exit;" SIGINT SIGTERM
MAX_RETRIES=10
i=0
# Set the initial return value to failure
@joshespi
joshespi / docker-laravel.sh
Last active April 30, 2023 06:01
docker composer to create a new laravel app
docker run --rm -v C:\Users\Joshe\OneDrive\Documents\docker\laravel:/app composer create-project --prefer-dist laravel/laravel myapp
@joshespi
joshespi / ubuntu22_ipv6_disable.sh
Last active May 23, 2023 19:32
script to disable IPV6 on ubuntu22 LT
#!/bin/bash
# Append IPv6 disable configuration to /etc/sysctl.conf
echo "net.ipv6.conf.all.disable_ipv6=1
net.ipv6.conf.default.disable_ipv6=1
net.ipv6.conf.lo.disable_ipv6=1" | sudo tee -a /etc/sysctl.conf > /dev/null
# Apply the changes
sudo sysctl -p
@joshespi
joshespi / update-server-sh
Created May 24, 2023 19:32
simple script that will invoke our update script on remote servers. then ping for you to monitor the reboot
#!/bin/sh
#
# Define the IP address variable
IP_ADDRESS="158.91.1.124"
# Runs apt upgrade, dist-upgrade, autoclean, autoremove, and reboots the VM
ssh webadmin@$IP_ADDRESS -t 'sudo /home/webadmin/update.sh'
# Ping the IP address
ping $IP_ADDRESS
#!/bin/bash
# Creates backup folder if it doesn't exist
mkdir -p /home/pi/backup;
# Moves files to home backup folder
rsync -av --delete /etc/snmp/ /home/pi/backup/snmp
rsync -av --delete /usr/local/bin/ /home/pi/backup/usrlocalbin
rsync -av --delete /etc/rc.local /home/pi/backup/rc.local
rsync -av --delete /boot/config.txt /home/pi/backup/config.txt
@joshespi
joshespi / bottom-modal.html
Created June 12, 2023 16:22
simple bottom modal for a survey
<?php //=============================Survey Modal=======================
if(is_null($_COOKIE['pcsd-chocochip'])){ ?>
<div id="modalcontrols">
<h2>Bottom Modal</h2>
<!-- Trigger/Open The Modal -->
<button id="myBtn">Open Modal</button>
<!-- The Modal -->
<div id="myModal" class="modal">