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 / 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');
Public Function BASE64SHA1(ByVal sTextToHash As String)
Dim asc As Object
Dim enc As Object
Dim TextToHash() As Byte
Dim SharedSecretKey() As Byte
Dim bytes() As Byte
Const cutoff As Integer = 5
Set asc = CreateObject("System.Text.UTF8Encoding")
@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]? "
@jakebathman
jakebathman / .colors
Last active October 5, 2018 16:24
Terminal colors for your .aliases file (macOS)
# First are the color variables
# Second is a function that will test the colors on your machine (tested on bash and zsh on macOS)
# Some terminals/OS's have weird inconsistencies with the escape codes,
# so google will be your friend if this doesn't work quite right
#
# You can copy/paste these into your .bashrc or similar file
# Don't forget to source the file again or restart your terminal session to apply!
# Normal Colors
export Black='\033[0;30m' # Black
## Add multi and setmulti
!commands add !multi Multi-Stream Link: http://kadgar.net/live/$(channel)
!commands add !setmulti -ul=moderator -a=!commands edit !multi Multi-Stream Link: http://kadgar.net/live/$(channel)/$(query)
# usage: !setmulti other_stream/another_stream
@jakebathman
jakebathman / search_git_diffs.md
Created November 27, 2018 16:33
Search for a string in all diffs in a repo

Search through diffs

To make case-insensitive, add -i to all grep and git log commands

Search for "Telescope" (case sensitive) in all diffs in a repo

$ git log -STelescope

Result is something like this:

@jakebathman
jakebathman / test_create_alarm.ts
Created December 30, 2018 02:42
Test file for createAlarm function PR for Shortcuts JS
// Only used to create the .shortcut file
const fs = require('fs');
const {
buildShortcut,
} = require('./');
const {
comment,
createAlarm,
} = require('./actions');