Skip to content

Instantly share code, notes, and snippets.

View davzaman's full-sized avatar

Davina Zaman davzaman

View GitHub Profile
@davzaman
davzaman / export_env.py
Last active November 30, 2022 22:07
Export your entire conda/mamba environment (including pip files) for only those packages that were manually installed.
from argparse import ArgumentParser
import subprocess
import yaml
try:
import pip_chill
except ModuleNotFoundError:
print("module 'pip-chill' is not installed, but is required for this script.")
if __name__ == "__main__":
#!/bin/bash
port=$PROCESS_PORT # You can add `export PROCESS_PORT=8888` to your bashrc and then use it here. Or just memorize number.
screen_name=process_name
# An example command. Chained commands MUST be separated by ; (in my experience, && will cause the `screen stuff` command to fail)
cmd="cd ~/your/project/directory; jupyter lab --port=$port"
# Run only if screen doesn't exist
if ! screen -ls | grep -q $screen_name; then
# Start detached screen and run command in the screen
screen -dmS $screen_name bash -c "$cmd"
@davzaman
davzaman / jupyter_snippet.py
Last active January 5, 2021 21:49
Parse Guild YAML file to execute your project on the command-line without logging anything (for debugging/testing/etc purposes). Also included is an example bash script you can create to use this for your project.
import sys
import yaml
from parse_yaml import parse
with open("guild.yml", "r") as f:
res = parse(yaml.safe_load(f))
d = {f"--{k.replace('_','-')}": str(v) for k, v in res.items()}
if d["--toggle-var-on"] == 'False':
del d["--toggle-var-on"]
@davzaman
davzaman / download_from_gdrive.sh
Created December 16, 2020 22:34
Uses fileid to download an artifact from google drive only using curl. Cannot upload.
#!/bin/bash
# Reference: https://stackoverflow.com/a/48133859/1888794
# fileid is the part of the link to the artifact: https://drive.google.com/file/d/<FILEID>/view?
FILEID=$1
FILENAME=$2
curl -c ./cookie -s -L "https://drive.google.com/uc?export=download&id=${FILEID}" > /dev/null
curl -Lb ./cookie "https://drive.google.com/uc?export=download&confirm=`awk '/download/ {print $NF}' ./cookie`&id=${FILEID}" -o ${FILENAME}
rm cookie
@davzaman
davzaman / adjectives.txt
Last active August 29, 2015 14:20 — forked from bergantine/gist:2390284
creates tumblr style insults
aggressive
aloof
arrogant
belligerent
bi
headed
bitchy
boastful
bon
idle