Skip to content

Instantly share code, notes, and snippets.

View bmmalone's full-sized avatar

Brandon Malone bmmalone

  • Tuebingen, Germany
View GitHub Profile
@bmmalone
bmmalone / dvc-config
Created July 14, 2023 11:32
A simple dvc config file for a shared cache, as well as sample commands to create and assign appropriate groups for the cache folder
[core]
analytics = false
remote = remote_storage
[cache]
dir = /srv/dvc-cache
shared = group
type = symlink
['remote "remote_storage"']
url = gs://my-dvc-shared-bucket/dvc-cache-folder
@bmmalone
bmmalone / settings.json
Last active April 13, 2023 19:29
A simple .vscode settings file
{
"editor.rulers": [
88,
120
],
"editor.formatOnSave": true,
"python.formatting.provider": "black",
"python.formatting.blackArgs": [
"--line-length",
"120"
@bmmalone
bmmalone / python-project-template.txt
Last active February 17, 2022 16:58
This gist gives a template for python projects oriented towards data science.
|-- LICENSE (if relevant)
|
|-- README.md <- the top-level README for developers using this project
|
|-- CHANGELOG.md <- a changelog for tracking changes over the history of a project.
| Example: https://github.com/bmmalone/pyllars/blob/dev/CHANGELOG.md
|
|-- setup.cfg <- project-specific configuration for python.
|
|-- .gitignore <- avoid uploading data, credentials, outputs, system files, etc.
@bmmalone
bmmalone / update-all-git-branches.sh
Created August 19, 2021 10:36
Pull and update all github repositories and all branches for a given user
#! /usr/bin/env bash
set -vx
gh_token=/path/to/my/gh-token.txt
account=my_account
# login to github
gh auth login --with-token < "$gh_token"
@bmmalone
bmmalone / conda-cronjob.sh
Created August 19, 2021 10:30
Run a cronjob from an existing conda environment
SHELL=/bin/bash
BASH_ENV=/path/to/my/.bashrc_conda
00 03 * * * cd /my/working/dir; conda activate my_env; /path/to/my/script.py >>/path/to/my.stdout 2>>/path/to/my.stderr; conda deactivate
@bmmalone
bmmalone / install-nvidia-drivers-debian.sh
Created August 6, 2021 09:42
Install NVIDIA drivers and container toolkit on Debian
# check running kernel version
uname -r
# check installed kernel headers
apt list --installed | grep "linux-headers"
# if the correct ones aren't installed, then install them
sudo apt install linux-headers-$(uname -r)
# probably reboot, but I'm not sure if it's necessary
@bmmalone
bmmalone / install-docker-debian.sh
Last active March 16, 2022 09:59
Install docker on Debian. Further, create the docker group and add the current user to it. Finally, set a custom location for storing images.
#! /usr/bin/env bash
image_loc="/data/docker"
###
# https://docs.docker.com/engine/install/debian/
###
# set up the docker repository
# Configuration file for jupyter-notebook.
def add_home_dir(*fn):
import os.path
return os.path.join(os.path.expanduser('~'), *fn)
#------------------------------------------------------------------------------
# Configurable configuration
#------------------------------------------------------------------------------
@bmmalone
bmmalone / cross-validation.pseudo
Created April 15, 2021 08:41
Pseudocode for cross-validation with embedding models
given labeled_training_indices (e.g., maybe there are 20 labeled training instances)
given labeled_test_indices (there are always ~3000 of these due to the split created by Harutyunyan et al.)
train_fold, val_fold <- stratified split(labeled_training_indices, train=70%, "test"=30%) # "test" is really the validation set here
# for example, if we have 20 labeled training instances, then we have 14 instances for training and 6 for validation
# ... so we really don't have a lot when the number of labeled training instances is small
hp_grid = ParameterGrid({
'penalty': ['l1', 'l2'],
@bmmalone
bmmalone / conda_wrapper.sh
Created March 14, 2020 08:53
Automation on top of conda
#! /usr/bin/env bash
function mkipycondaenv {
if [ "$#" -ne 1 ]; then
echo "usage: mkipycondaenv <condaenv_name>"
return 1
fi
conda create --name "$1" pip wheel jupyter ipykernel