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
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
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
KrashLeviathan / bash_template.sh
Last active Oct 4, 2018
Bash Script Template
View bash_template.sh
#!/usr/bin/env bash
#
# TODO: This script does ... something
# The equivalent of "use strict"; makes bash a little less error prone
set -euo pipefail
QUIET="false"
SCRIPT_NAME=`basename $0`
# Prints usage information
@KrashLeviathan
KrashLeviathan / batchrename
Created Jan 30, 2018
Rename batches of files
View batchrename
#!/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 / markdownToPdf.sh
Created Nov 6, 2017
Simple Markdown to PDF Command
View markdownToPdf.sh
#!/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 / votd.sh
Created Nov 10, 2016
Command Line Verse of the Day
View votd.sh
#!/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 Aug 31, 2016
Bash script to VPN into Iowa State University's network through the terminal
View isuvpn
#!/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 / mkv_to_mp4.sh
Last active Aug 30, 2016
Convert all MKV files in a folder to MP4
View mkv_to_mp4.sh
#!/usr/bin/env bash
# 16:9 ratio suggestion
$max_width=768
$max_height=432
# 4:3
# $max_width=640
# $max_height=480
View build_jekyll.sh
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 / config
Last active Aug 19, 2016
How to Work with GitHub and Multiple Accounts
View config
# 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
You can’t perform that action at this time.