Skip to content

Instantly share code, notes, and snippets.

Nathan Karasch KrashLeviathan

Block or report user

Report or block KrashLeviathan

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
KrashLeviathan / queries_are_equivalent.sql
Last active Jan 6, 2020
Check to see if two SELECT statements are equivalent in SQL
View queries_are_equivalent.sql
-- Found this in the following StackOverflow post and found it useful on multiple occasions
WITH query1 AS
-- Copy/paste SELECT statement here
query2 AS
-- Copy/paste SELECT statement here
KrashLeviathan / logout-cleanup-component.ts
Created Jun 12, 2019
This Angular 7 class and decorator can be used to perform component cleanup actions when a user logs out.
View logout-cleanup-component.ts
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({
KrashLeviathan / myCollector.js
Created Mar 20, 2019
Used to collect data from Squarespace analytics charts (or any react chart tooltips for that matter)
View myCollector.js
myCollector = {
data: {},
intervalId: 0,
intervalMillis: 5,
selectors: {
container: '.react-charts-tooltip',
header: '.react-charts-tooltip-header',
rows: '.react-charts-tooltip-row'
start: function() {
KrashLeviathan /
Last active Oct 4, 2018
Bash Script Template
#!/usr/bin/env bash
# TODO: This script does ... something
# The equivalent of "use strict"; makes bash a little less error prone
set -euo pipefail
SCRIPT_NAME=`basename $0`
# Prints usage information
KrashLeviathan / batchrename
Created Jan 30, 2018
Rename batches of files
View batchrename
function usage() {
echo "USAGE: <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 /
Created Nov 6, 2017
Simple Markdown to PDF Command
# 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.
# Might also require latex to be installed, but I'm not sure about that one.
mdBase=`basename -s ".md" "${1}"`
KrashLeviathan /
Created Nov 10, 2016
Command Line Verse of the Day
#!/usr/bin/env bash
# Asynchronously gets the Verse of the Day from and prints it to the terminal
# Must have httpie installed for it to work! (Visit
function printVotd {
# Uses the REST API to get the verse of the day, discarding any errors
votd=`http --print=b 2>/dev/null`
# Colorize and print the verse to the terminal
printf "\n\n\033[01;34m${votd/ - /\\n\\n}\n\n"
KrashLeviathan / isuvpn
Created Aug 31, 2016
Bash script to VPN into Iowa State University's network through the terminal
View isuvpn
# Openconnect command-line script for connecting to ISU's VPN servers
# from Debian-Ubuntu-derived Linux distro's. More info at
# (because I originally got it from UCI)
# This script adapted from David Schneider's great page on github at
# and with help from OIT's Linux OpenConnect instructions at
KrashLeviathan /
Last active Aug 30, 2016
Convert all MKV files in a folder to MP4
#!/usr/bin/env bash
# 16:9 ratio suggestion
# 4:3
# $max_width=640
# $max_height=480
DIR=$(mktemp -d)
git clone $DIR
jekyll build --source "$DIR" --destination /home/nkarasch/site
rm -rf $DIR
You can’t perform that action at this time.