This file contains 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
[alias] | |
st = status | |
di = diff | |
co = checkout | |
ci = commit | |
br = branch | |
sta = stash | |
llog = log --date=local | |
flog = log --pretty=fuller --decorate | |
lg = log --graph --abbrev-commit --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' |
This file contains 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
git config --global credential.helper store | |
git config --global user.email [email protected] | |
git config --global user.name bobby | |
export PS1="\[\033[38;5;133m\]\t\[$(tput sgr0)\] \[$(tput sgr0)\]\[\033[38;5;33m\]\w\[$(tput sgr0)\] \[$(tput sgr0)\]\[\033[38;5;2m\]\\$\[$(tput sgr0)\] \[$(tput sgr0)\]" | |
alias ls='ls --color=auto' |
This file contains 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
# 0: Attach a lifecycle configuration to you Notebook instance to persist environments between sessions | |
# See https://modelpredict.com/sagemaker-save-your-conda-environments/ for instruction | |
# Alternative: create environments under the persisted folder (/home/ec2-user/SageMaker) with | |
# conda create -p /home/ec2-user/SageMaker/py310 python=3.10 | |
# then systematically symlink: ln -s /home/ec2-user/SageMaker/py310 ~/anaconda3/envs/py310 | |
# 1: Create a new conda environment and make it accessible to SageMaker | |
conda create -y -n py310 python=3.10 | |
conda activate py310 | |
# From https://forum.deepchem.io/t/deploying-a-deepchem-sagemaker-notebook-instance/174 |
This file contains 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
pip install -q jupyterlab | |
ssh-keygen -q -t rsa -N '' -f ~/.ssh/id_rsa <<<y >/dev/null 2>&1 | |
eval "$(ssh-agent -s)" | |
ssh-add | |
jupyter lab --ip=0.0.0.0 --port=8989 --allow-root & ssh -o StrictHostKeyChecking=no -R 80:localhost:8989 ssh.localhost.run |
This file contains 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 tarfile | |
import subprocess | |
import os | |
import s3fs | |
REQUIRED_AWS_ENV = {"AWS_ACCESS_KEY_ID", "AWS_SECRET_ACCESS_KEY", "AWS_DEFAULT_REGION"} | |
def setup_aws_fs() -> s3fs.S3FileSystem: | |
"""Check the presence of AWS required environment variables | |
and return an S3 filesystem object. |
This file contains 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 bash | |
# From https://betterdev.blog/minimal-safe-bash-script-template/ | |
set -Eeuo pipefail | |
trap cleanup SIGINT SIGTERM ERR EXIT | |
script_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd -P) | |
usage() { | |
cat <<EOF |
This file contains 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 onNewRow(e) { | |
var sheet = SpreadsheetApp.getActiveSheet(); | |
Logger.log("Trigger: new row inserted:" + sheet.getLastRow()); | |
// Get index of row inserted | |
var row = sheet.getLastRow(); | |
// Get word/phrase inserted | |
var range = sheet.getRange(row, 1); | |
var phrase = range.getValue(); | |
Logger.log("Row insertion detected"); |
This file contains 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 sklearn.metrics import roc_curve, auc | |
def plot_roc_curve(true_labels, scores): | |
""" Plot ROC curve with associated score thresholds """ | |
# compute fpr, tpr, thresholds and roc_auc | |
fpr, tpr, thresholds = roc_curve(true_labels, scores) | |
roc_auc = auc(fpr, tpr) # compute area under the curve | |
fig, ax = plt.subplots() |
This file contains 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
# Official doc: https://docs.python.org/3/howto/logging-cookbook.html | |
import os | |
import logging | |
from logging import StreamHandler | |
from logging import Formatter | |
LOGS_DIR = os.path.join(os.path.dirname(os.path.realpath(__file__)), '../logs') | |
if not os.path.exists(LOGS_DIR): |
This file contains 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
# inspired by https://stackoverflow.com/a/50658993/5174617 | |
import pandas as pd | |
import json | |
df = pd.DataFrame([['0 {"a":"1","b":"2","c":"3"}'],['1 {"a" :"4","b":"5","c":"6"}']], columns=['json']) | |
exploded_df = df['json'].apply(json.loads).apply(pd.Series) |
NewerOlder