Skip to content

Instantly share code, notes, and snippets.

View hisnameisjimmy's full-sized avatar

Jimmy Hooker hisnameisjimmy

View GitHub Profile
@hisnameisjimmy
hisnameisjimmy / update-npm-packages.sh
Created February 11, 2019 15:52
Update all NPM packages that aren't global and update the package.json
# Run this from the root directory of your project. It takes the list of outdated packages, skips the first row (since that will be
# the header row), and runs a loop on the package names that updates and saves them.
for i in $(npm outdated | awk 'FNR > 1 {print $1}'); do npm update --save $i; done
@hisnameisjimmy
hisnameisjimmy / extract-urls-from-sitemap.sh
Last active February 28, 2018 18:03
Extract all URLs from a sitemap to plan text
#!/bin/sh
# Replace the website for your own, and you can extract all sitemap files from a parent sitemap file.
#
# Into their own individual sitemap section files:
number=1;
for i in $(curl https://website.com/sitemap.xml | sitemap-urls);
do curl -s -N $i | sitemap-urls > ~/Desktop/sitemap-output/map-$number.txt;
number=$(($number+1));
done
@hisnameisjimmy
hisnameisjimmy / wordpress-media-finder.sh
Last active December 19, 2017 15:52
Find all duplicate images from Wordpress
To see the list before deleting:
find -E . -regex '.*\-[0-9]{1,4}\x[0-9]{1,4}\.(png|gif|jpg)$' > ./duplicates.txt
To delete:
find -E . -regex '.*\-[0-9]{1,4}\x[0-9]{1,4}\.(png|gif|jpg)$' -delete
Run a find/replace on your mysqldump backup (and create a backup of that) to remove references to alternate wordpress files:
sed -i .bak -E 's#\-[0-9]{1,4}\x[0-9]{1,4}##g' backup.sql
@hisnameisjimmy
hisnameisjimmy / sftp-chroot-server-setup.sh
Created December 11, 2017 20:14
Chrooted SFTP Server Setup
# Add the following to the bottom of /etc/ssh/sshd_config
# This makes it so any user with the group sftponly only has access to
# their chrooted home directory and forces internal-sftp. In this situation,
# we're going to make the home directory the chroot. We'll also
# comment out PasswordAuthentication so that we don't run into issues there.
# This setup will prevent shell access as long as you use the script over here:
# https://gist.github.com/hisnameisjimmy/a3cbc5c7c925ce8854afa350cb01cfe4
#
@hisnameisjimmy
hisnameisjimmy / add-chroot-sft-only-user.sh
Last active December 28, 2017 17:51
Add user with only SFTP access
#!/bin/bash
#
# Use this guide for initial setup:
# https://www.digitalocean.com/community/tutorials/initial-server-setup-with-ubuntu-16-04
#
# Install fail2ban
# apt install fail2ban
#
# Disable Root Login
# sudo vim /etc/ssh/sshd_config
@hisnameisjimmy
hisnameisjimmy / le-install.sh
Last active March 14, 2022 22:14
Unifi Controller one-shot install script for Ubuntu 16.04 with Lets Encrypt
#!/bin/sh
#
# This script stands on the shoulders of giants.
#
# You can always find the most recent version here: https://gist.github.com/hisnameisjimmy/56f9414076ca39a79bfa07eefa89759e
#
# It is written and tested for Ubuntu 16.04 on Digital Ocean using a 1GB droplet.
# Anything less than 1GB of memory may cause issues with anything memory intensive
# like imports/exports.
#