Skip to content

Instantly share code, notes, and snippets.

View KrashLeviathan's full-sized avatar

Nathan Karasch KrashLeviathan

View GitHub Profile
@KrashLeviathan
KrashLeviathan / fix_wrong_author.sh
Created August 19, 2016 01:54
Fix all the wrong author names and emails for all branches and tags of a repository
#!/bin/sh
# Got this from Pat Notz's answer on StackOverflow. It works amazing!
# http://stackoverflow.com/questions/750172/change-the-author-and-committer-name-and-e-mail-of-multiple-commits-in-git
git filter-branch --env-filter '
OLD_EMAIL="your-old-email@example.com"
CORRECT_NAME="Your Correct Name"
CORRECT_EMAIL="your-correct-email@example.com"
if [ "$GIT_COMMITTER_EMAIL" = "$OLD_EMAIL" ]
@KrashLeviathan
KrashLeviathan / config
Last active August 19, 2016 03:04
How to Work with GitHub and Multiple Accounts
# Got this handy tidbit from Jeffrey Way on tutsplus.com
# http://code.tutsplus.com/tutorials/quick-tip-how-to-work-with-github-and-multiple-accounts--net-22574
# This file goes in your $HOME/.ssh directory
# Default GitHub account (work or school)
Host github.com
HostName github.com
User git
IdentityFile ~/.ssh/id_rsa
DIR=$(mktemp -d)
git clone https://github.com/KrashLeviathan/NathanKarasch.git $DIR
jekyll build --source "$DIR" --destination /home/nkarasch/site
rm -rf $DIR
@KrashLeviathan
KrashLeviathan / mkv_to_mp4.sh
Last active August 30, 2016 15:41
Convert all MKV files in a folder to MP4
#!/usr/bin/env bash
# 16:9 ratio suggestion
$max_width=768
$max_height=432
# 4:3
# $max_width=640
# $max_height=480
@KrashLeviathan
KrashLeviathan / votd.sh
Created November 10, 2016 15:26
Command Line Verse of the Day
#!/usr/bin/env bash
# Asynchronously gets the Verse of the Day from OurManna.com and prints it to the terminal
# Must have httpie installed for it to work! (Visit https://httpie.org/)
function printVotd {
# Uses the REST API to get the verse of the day, discarding any errors
votd=`http --print=b http://www.ourmanna.com/verses/api/get/?format=text 2>/dev/null`
# Colorize and print the verse to the terminal
printf "\n\n\033[01;34m${votd/ - /\\n\\n}\n\n"
@KrashLeviathan
KrashLeviathan / isuvpn
Created August 31, 2016 19:11
Bash script to VPN into Iowa State University's network through the terminal
#!/bin/bash
# Openconnect command-line script for connecting to ISU's VPN servers
# from Debian-Ubuntu-derived Linux distro's. More info at
# http://www.socsci.uci.edu/~jstern/uci_vpn_ubuntu/ubuntu-openconnect-uci-instructions.html
# (because I originally got it from UCI)
#
# This script adapted from David Schneider's great page on github at
# https://github.com/dnschneid/crouton/wiki/Using-Cisco-AnyConnect-VPN-with-openconnect
# and with help from OIT's Linux OpenConnect instructions at
@KrashLeviathan
KrashLeviathan / markdownToPdf.sh
Created November 6, 2017 17:49
Simple Markdown to PDF Command
#!/bin/bash
# I actually just added this as a function in my .bashrc, but you
# could just "chmod +x" this script and drop it in a bin folder in
# a local $PATH directory such as "/usr/local/bin"
# Requires pandoc be installed. https://pandoc.org/
# Might also require latex to be installed, but I'm not sure about that one.
mdBase=`basename -s ".md" "${1}"`
@KrashLeviathan
KrashLeviathan / batchrename
Created January 30, 2018 01:51
Rename batches of files
#!/bin/bash
function usage() {
echo "USAGE: batchrename.sh <query> <replacement> [shouldMove]"
echo -e "\n\
Rename a batch of files. The first parameter (query) should be a\n\
string common to all the filenames in the batch. The second\n\
parameter (replacement) should be a string that replaces the\n\
query in the new filenames. The third parameter indicates whether\n\
it should copy or move the files. It defaults to false.\n\
@KrashLeviathan
KrashLeviathan / myCollector.js
Created March 20, 2019 16:28
Used to collect data from Squarespace analytics charts (or any react chart tooltips for that matter)
myCollector = {
data: {},
intervalId: 0,
intervalMillis: 5,
selectors: {
container: '.react-charts-tooltip',
header: '.react-charts-tooltip-header',
rows: '.react-charts-tooltip-row'
},
start: function() {
@KrashLeviathan
KrashLeviathan / logout-cleanup-component.ts
Created June 12, 2019 13:17
This Angular 7 class and decorator can be used to perform component cleanup actions when a user logs out.
import {OnDestroy, OnInit} from '@angular/core';
import {AuthService} from '../service/auth/auth.service';
import {Subscription} from 'rxjs';
/**
* To use this class and the decorator below (must be used together):
*
* @CleanupAfterLogout()
* @Component({