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 dataclasses | |
import inspect | |
from functools import lru_cache | |
from typing import Any | |
from typing import Dict | |
from typing import Set | |
from typing import Tuple | |
from typing import Union |
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
# check for available pypi synonyms of a given word | |
# $ available_pypi_synonyms.py <words...> | |
import argparse | |
import itertools | |
import re | |
import diskcache as dc | |
import requests | |
from bs4 import BeautifulSoup |
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 | |
# TPS corresponds to IOPS: | |
# https://en.wikipedia.org/wiki/IOPS | |
function cluster-disk-info() { | |
folders="/tmp /home-mscluster/ /scratch" | |
# disk space | |
df -h -P $folders | |
disks=$(df -h -P $folders | perl -n -e '/.*.dev.(...).*/ && print "$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
def torch_pca_svd(X, center=True): | |
n, _ = X.shape | |
# center points along axes | |
if center: | |
X = X - X.mean(dim=0) | |
# perform singular value decomposition | |
u, s, v = torch.svd(X) | |
# extract components | |
components = v.T | |
explained_variance = torch.mul(s, s) / (n-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
import imageio | |
import numpy as np | |
import sys | |
import os | |
import imagesize | |
if __name__ == '__main__': | |
assert len(sys.argv) >= 2, 'must supply at least 1 file argument' |
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
unload_files=( | |
"/Library/LaunchAgents/com.tuxera.ntfs.agent.plist" | |
) | |
for unload_file in "${unload_files[@]}"; do | |
echo "Unloading: ${unload_file}" | |
launchctl unload "${unload_file}" | |
echo | |
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
# Copyright (c) 2020 Nathan Juraj Michlo | |
# | |
# Permission is hereby granted, free of charge, to any person obtaining a copy | |
# of this software and associated documentation files (the "Software"), to deal | |
# in the Software without restriction, including without limitation the rights | |
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
# copies of the Software, and to permit persons to whom the Software is | |
# furnished to do so, subject to the following conditions: | |
# | |
# The above copyright notice and this permission notice shall be included in all |
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
# Adapted from https://amitness.com/vscode-on-colab | |
# Copy this script into a colab cell | |
# install deps if needed | |
!(command -v "code-server" 1>/dev/null) || (curl -fsSL https://code-server.dev/install.sh | sh && echo) | |
!(python -c "import pyngrok" 2>/dev/null) || (pip install -qqq pyngrok) | |
# run vscode in background if needed | |
!(ps -ef|awk '/code-server/&&!/awk/{exit 1}') && (nohup code-server --port 9000 --auth none &) |
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 | |
# get the directory that this script is in so you can call it from anywhere | |
script_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" | |
# your output folder, where sub0MyAgent.py.zip will be placed | |
# TODO: EDIT | |
out_dir="$script_dir/submissions/latest" | |
# locations of your files |
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
# XTerm Control Sequences based on: | |
# - https://invisible-island.net/xterm/ctlseqs/ctlseqs.html | |
# ========================================================================= # | |
# XTerm Control Sequences from invisible-island.net as pythonic code. | |
# Basic control sequences are string variables. | |
# - eg: ESC = '\033' | |
# CSI = ESC + '[' | |
# Control sequences that have args can be called to return a string. | |
# - eg: sgr = CSI + Ps + 'm' |
NewerOlder