Skip to content

Instantly share code, notes, and snippets.

@konahart
konahart / tarjan.py
Created October 2, 2020 05:15
Tarjan algo
# https://en.wikipedia.org/wiki/Tarjan%27s_strongly_connected_components_algorithm
def get_sccs(graph=None):
""" Check for strongly connected components using Tarjan's algorithm"""
# set up graph
# graph = {1: [2], 2: [3], 3: [2], 4: []}
sccs = []
index = 0
indices = {}
lowlinks = {}
onstack = set()
@konahart
konahart / Code.gs
Created June 10, 2020 05:30
Library Shelf Alphabetize Google Sheet
// adapted from https://webapps.stackexchange.com/questions/84218/sorting-alphabetically-a-z-ignoring-beginning-a-an-and-the-using-a-scri
function sortByTitle() {
var sheet = SpreadsheetApp.getActiveSheet();
// Ignore header row (A1:Z1)
var range = sheet.getRange(2, 1, sheet.getLastRow() - 1, sheet.getLastColumn());
var values = range.getValues();
values.sort(function(a,b) {return (trimmed(a[0]) < trimmed(b[0]) ? -1 : 1);});
range.setValues(values);
}