Skip to content

Instantly share code, notes, and snippets.

@jakebathman
jakebathman / shell_commands.sh
Last active January 6, 2018 02:37
Various shell commands that I always have to look up
# Delete files based on a pattern
# The example below removes PDF files in nested directories, such as ./50/round_2/foo.pdf
# but would NOT remove the file ./50/packages/foo.pdf
find . -regextype posix-extended -regex ".*/round.*\.pdf" -exec rm {} +
# Delete a history item by its ID
history # get the ID (left-hand number) for the item you want to remove
history -d item_number
# Delete keys in redis matching some pattern, atomically
@jakebathman
jakebathman / .tmux.conf
Last active December 14, 2017 17:16
Customizing tmux
# Many of these customizations are from
# http://www.hamvocke.com/blog/a-guide-to-customizing-your-tmux-conf/
# remap prefix from 'C-b' to 'C-a'
unbind C-b
set-option -g prefix C-a
bind-key C-a send-prefix
# split panes using | and -
bind | split-window -h
@jakebathman
jakebathman / is_backblaze_uploading.sh
Created February 15, 2018 20:25
Determine if Backblaze is currently backing up files on macOS
#!/bin/sh
# This will look at the overviewstatus.xml file and
# determine if Backblaze is currently transmitting a file.
#
# Developed against:
# macOS 10.13.3
# Backblaze 5.2.0.172
BBSTATUS='/Library/Backblaze.bzpkg/bzdata/overviewstatus.xml'
@jakebathman
jakebathman / remove_laravel_comments.php
Last active February 19, 2024 10:28
Remove comments from fresh Laravel files
<?php
/*
|--------------------------------------------------------------------------
| Remove Laravel Comments
|--------------------------------------------------------------------------
|
| Just made a new Laravel project, but don't want all those big
| comment blocks? Put this in the root of your project and run
| "php remove_laravel_comments.php"
|
@jakebathman
jakebathman / gfu.sh
Last active April 20, 2018 20:23
Update a repo fork with the original (upstream)
#!/bin/zsh
# sync a fork using the upstream branch
gfu(){
BRANCH="$1"
if [ -z "$1" ]; then
BRANCH="master"
fi
@jakebathman
jakebathman / random.sh
Created April 25, 2018 21:11
Random string generator
# Use these on the command line to generate random strings
# Tested in CentOS and macOS
# All printable characters
head /dev/urandom | LC_CTYPE=C tr -dc "[:print:]" | head -c 32
# Only A-Za-z0-9
head /dev/urandom | LC_CTYPE=C tr -dc "A-Za-z0-9" | head -c 32
# Alphanum with some special characters
@jakebathman
jakebathman / scrape_ign_fortnite_map_tiles.php
Created May 10, 2018 13:57
Scrape the IGN Fortnite map tiles and re-construct a large map image
<?php
/*****
If you have PHP installed, run this from the command line:
php scrape_ign_fortnite_map_tiles.php
**/
ini_set('memory_limit','2048M');
@jakebathman
jakebathman / provision_irc_server.sh
Last active September 19, 2021 16:53
IRC server setup on CentOS 7
#!/bin/bash
# This sets the variable $IPADDR to the IP address the new Linode receives.
IPADDR=$(/sbin/ifconfig eth0 | awk '/inet / { print $2 }' | sed 's/addr://')
sudo yum update -y
sudo yum install nginx wget git -y
cd ~
@jakebathman
jakebathman / logslaravel.sh
Created August 19, 2018 00:06
Tail Laravel logs and filter out the stack traces
tail -f -n 450 storage/logs/laravel*.log \
| grep -i -E \
"^\[\d{4}\-\d{2}\-\d{2} \d{2}:\d{2}:\d{2}\]|Next [\w\W]+?\:" \
--color
@jakebathman
jakebathman / gfu.sh
Created October 5, 2018 16:06
Git fetch upstream, to sync your fork with the original repo
# sync a fork using the upstream branch
# usage: gfu [branch-name (default: master)]
gfu(){
BRANCH="$1"
if [ -z "$1" ]; then
BRANCH="master"
fi
echo -n "Fetch and merge upstream for branch $BWhite$BRANCH$NC? [y/N]? "