This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def bool_array_find_clusters_and_islands(bool_array): | |
clusters = [] | |
islands = [] | |
cluster_start_index = None | |
currently_iterating_through_cluster = False | |
for i,value in enumerate(bool_array): | |
value = bool(value) | |
if currently_iterating_through_cluster and (value is True): | |
if i == len(bool_array)-1: # if last element | |
cluster_end_index = i |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sympy | |
import readline # allow arrow keys while typing inputs | |
while True: | |
expression = input("expression: ") | |
unknowns = input("unknowns comma delimited: ") | |
exec_str = f"{unknowns} = sympy.symbols(\"{unknowns}\")" | |
print(f"> {exec_str}") | |
exec(exec_str) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def fmt_table(table, disable_column_headers=False) -> str: | |
""" | |
I would use tabulate but I don't want nonstandard imports | |
""" | |
table_output = "" | |
# no row has more elements than the header row | |
assert(all(len(row) <= len(table[0]) for row in table)) | |
column_widths = [ 0 ] * len(table[0]) | |
for row in table: | |
for i,element in enumerate(row): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import os | |
import sys | |
import glob | |
import zipfile | |
import tempfile | |
from subprocess import check_output, CalledProcessError | |
assert len(sys.argv) >= 3 | |
grep_args = ' '.join(sys.argv[1:-1]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from collections import deque | |
def round_up(x): | |
return round(x + 0.4999999) | |
def make_routh_table(coefs: list): | |
num_columns = round_up(len(coefs)/2)+1 | |
num_rows = num_columns*2 | |
routh_table = [[0]*num_columns for x in range(num_rows)] | |
i = 0 # column |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# list .exe files in $1/* | |
# if one of those directories contains nothing but another subdirectory, | |
# then list .exe files in $1/dir/subdir | |
function fail(){ | |
echo $@ >&2 | |
exit 1 | |
} | |
function list_exe(){ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
import socket | |
import subprocess | |
LOOKUPS = [ | |
"unity.rc.umass.edu.", | |
"ood.unity.rc.umass.edu.", | |
"docs.unity.rc.umass.edu.", | |
] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import os | |
import grp | |
import sys | |
import json | |
import shutil | |
import subprocess as subp | |
from typing import List | |
SINFO_CACHE_FILE_PATH="/modules/user-resources/cache/sinfo.json" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -eo pipefail | |
SETTING="mousewheel.default.delta_multiplier_y" | |
CONFIG_FILE_PATH="/home/simon/.mozilla/firefox/shlbuz9i.default-esr/prefs.js" | |
LOW="30" # comfortable with my macbook 2015 touchpad | |
HIGH="101" # 100 is default, firefox deletes default values from the file | |
firefox_found=$(pgrep -U "$(whoami)" -fx '(.*/)?firefox(-esr)?$' | uniq || true) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
prettier_style_check: | |
image: node:latest | |
stage: test | |
script: | |
- npm install -g prettier | |
- prettier --version | |
- prettier . --check || { echo "did you run \`format.sh\`?"; exit 1; } |