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
| function nodes_with_state(){ | |
| sinfo -N --json | jq -r '.sinfo | .[] | select(any(.node.state[]; .=="$1")) | .nodes.nodes[0]' | |
| } |
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 _make_string_sortable_numerically(string:str) -> List[Tuple[int, int]]: | |
| """ | |
| each character becomes a tuple of two ints. The first int is either 0,1, or 2 | |
| 0 for characters that come before numbers, 1 for numbers, 2 for after numbers | |
| the second int is the unicode value of the character, or the integer value of the number | |
| that this character is a part of. | |
| $ 7 8 9 a ~ | |
| "$789a~" -> [[0, 36], [1, 789], [1, 789], [1, 789], [2, 97], [2, 126]] | |
| """ | |
| output = [[None, None] for _ in range(len(string))] |
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 string_matches_any_globs(x:str, globs:List[str]): | |
| return any(fnmatch.fnmatch(x, y) for y in globs) | |
| def find_files(walk_root_path:str, include_globs:List[str], exclude_globs:List[str]=None) -> list: | |
| """ | |
| excluding takes precidence over including | |
| """ | |
| output = [] | |
| for dirname, _, basenames in os.walk(walk_root_path): | |
| for basename in basenames: |
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 | |
| # let's say you have a cron job that updates some cache and you'd like it to | |
| # be updated often. You can measure the time it takes and set the cron frequency | |
| # similar to that amount of time, but what if this machine is running slower one day? | |
| # then, the last iteration of your job will still be running when the next | |
| # iteration begins. What happens if they're both overwriting a file? | |
| # What if the combined load of those two jobs slows down the computer even more, | |
| # and then there are 3 jobs, and so on? |
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 | |
| for file in $(find /var/spool/postfix/deferred -type f); do postcat -qb $(basename $file); done |
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
| <?xml version="1.0" encoding="UTF-8"?> | |
| <channel name="xfce4-panel" version="1.0"> | |
| <property name="configver" type="int" value="2"/> | |
| <property name="panels" type="array"> | |
| <value type="int" value="1"/> | |
| <property name="panel-1" type="empty"> | |
| <property name="autohide-behavior" type="uint" value="0"/> | |
| <property name="position" type="string" value="p=10;x=0;y=0"/> | |
| <property name="position-locked" type="bool" value="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
| import re | |
| import os | |
| import platform | |
| import tempfile | |
| import subprocess | |
| import urllib.request | |
| # https://stackoverflow.com/a/1732454/6307935 | |
| def get_links(url:str) -> list[str]: | |
| response = urllib.request.urlopen(url) |
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 control.matlab import tf, bode, rlocus, nyquist | |
| import matplotlib.pyplot as plt | |
| import numpy as np | |
| from scipy.interpolate import interp1d | |
| def indices_before_sign_flip(x: np.array): | |
| return np.where(np.diff(np.sign(x)))[0] | |
| def find_180deg_crossing_freq(phase, freq): | |
| target_phase = -1*np.pi # for some reason +pi doesn't work |
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) |