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 time | |
| import os | |
| import seaborn as sns | |
| import matplotlib | |
| import __main__ | |
| try: | |
| get_ipython | |
| except: | |
| # Use Agg when not in notebook |
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
| REPL = not hasattr(__main__, '__file__') | |
| import sys | |
| if REPL: | |
| sys.path.append('src/') |
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
| Counter.__mul__ = lambda self, other: Counter({k: v * other for k, v in self.items()}) | |
| Counter.__truediv__ = lambda self, other: Counter({k: v / other for k, v in self.items()}) |
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
| # If you don't have an installation of conda install using | |
| # https://docs.anaconda.com/anaconda/install/linux/ | |
| wget -c https://repo.anaconda.com/archive/Anaconda3-2019.03-Linux-x86_64.sh | |
| chmod +x Anaconda3-2019.03-Linux-x86_64.sh | |
| ./Anaconda3-2019.03-Linux-x86_64.sh | |
| # If you have one, update library defs using | |
| conda update conda | |
| # Create an environment 'py3' with python 3.7 and basic packages as |
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
| byobu keybindings can be user defined in /usr/share/byobu/keybindings/ | |
| (or within .screenrc if byobu-export was used). The common key bindings are: | |
| F2 - Create a new window | |
| F3 - Move to previous window | |
| F4 - Move to next window | |
| F5 - Reload profile | |
| F6 - Detach from this session | |
| F7 - Enter copy/scrollback mode | |
| F8 - Re-title a window |
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 itertools | |
| import time | |
| from multiprocessing.pool import Pool | |
| class Test: | |
| @classmethod | |
| def x(cls,y): | |
| time.sleep(y) | |
| print(f"{y}") |
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
| @classmethod | |
| def get_tpr_fpr(cls, pre_sigmoid_input, target): | |
| pre_sigmoid_input = pre_sigmoid_input.data.cpu().numpy() | |
| target = target.data.cpu().numpy() | |
| tpr = np.zeros_like(pre_sigmoid_input) | |
| fpr = np.zeros_like(pre_sigmoid_input) | |
| cls._tpr_fpr(tpr, fpr, pre_sigmoid_input, target) | |
| fpr = np.sort(fpr) | |
| tpr = np.sort(tpr) | |
| auc = np.sum((fpr[1:] - fpr[:-1]) * tpr[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 pynvml import * | |
| nvmlInit() | |
| for i in range(4): | |
| try: | |
| handle = nvmlDeviceGetHandleByIndex(i) | |
| info = nvmlDeviceGetMemoryInfo(handle) | |
| print "Device:\t", i , "Used memory:\t", float(info.used)/1024/1024/1024, "Total memory:\t", float(info.total)/1024/1024/1024 | |
| except: | |
| pass | |
| nvmlShutdown() |
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
| # Needs poppler, for mac use: | |
| # brew install poppler | |
| for i in `grep -nair 'includegraphics' ./* | grep pdf | grep -v '%' | perl -ne '/\{(.*?)\}/; print"$1\n"'` 1 ↵ ✹ ✭master | |
| do | |
| echo $i; pdffonts $i | |
| 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
| #!/bin/bash | |
| cat donations.csv.bkp | grep -v donationid | gshuf | head -n 1000 > donations.csv.tmp && head -n1 donations.csv.bkp > donations.csv && cat donations.csv.tmp >>donations.csv |
NewerOlder