I hereby claim:
- I am kbfreder on github.
- I am kbfreder (https://keybase.io/kbfreder) on keybase.
- I have a public key ASBmBZ75k43sulYdxxEkyvL5njbPuAE2l01Q_wSlTIwwRQo
To claim this, I am signing this object:
# to change the username displayed at the bash prompt | |
PS1="kendra@\W $ " | |
# functions | |
function path(){ # nicely list all dir in path | |
old=$IFS # rather than separated by ':', listed 1 per line | |
IFS=: | |
printf "%s\n" $PATH | |
IFS=$old |
# this is intended to live as a function inside ~/.bash_profile | |
function git_del_branches { | |
pattern=$1 | |
im=$2 | |
usage="git_del_branches -p pattern [-i] | |
Match and delete git branches that match <pattern>. | |
Use the -i (--inverse) flag to delete branches that do | |
not match <pattern>" |
# ref: https://janakiev.com/blog/python-shell-commands/ | |
# 1. using os | |
import os | |
output = os.system('ls -l') | |
print(output) | |
# 2. using subprocess | |
import subprocess |
!#python | |
""" | |
After you make a virtualenv relocatable (https://pypi.org/project/virtualenv/1.3.3/#making-environments-relocatable), pip will execute a file called 'activate_this.py' in <ENV_NAME>/bin if you go to install another module. In Python3 (? not sure of the cause), this file doesn't get created, so you have to make it. Through trial & error (no copy-and-paste correct answer was out there), I got this code to work. | |
""" | |
import os | |
activator = <path to activate_this.py> # ex: '/home/kfrederick/repos/domain_twists/env/bin/activate_this.py' | |
virtual_env = <path to virutal env> # ex: '/home/kfrederick/repos/domain_twists/env' |
I hereby claim:
To claim this, I am signing this object:
#!/bin/bash | |
#-------------------------------------- | |
# if no argument given, 'd' defaults to yesterday's date | |
# the `-z` argument checks for an empty string | |
if [ -z "$1" ] | |
then | |
echo "No argument supplied; using yesterday's date" | |
d=$(date --date '-1 day' +%Y-%m-%d) | |
else |
import argparse | |
import config_file as cfg # a config file | |
# i like to have 'main' as a stand-alone function, so I have the option | |
# of importing this file as a module, and calling main directly | |
def main(*args): | |
# in which we do the things | |
print('Running main function') |
#!/bin/bash | |
# loop through dates, using GNU dates | |
# GNU date reference: https://www.gnu.org/software/coreutils/manual/html_node/Examples-of-date.html | |
# define paths | |
open_path=../data/raw | |
save_path=../data/processed | |
# define dates | |
start_date=2020-02-25 |
# BASIC | |
# ---------------------------------------------------------------------- | |
# elapsed time | |
import time | |
start_time = time.time() | |
'''code to execute''' | |
end_time = time.time() | |
print('Elapsed time: {:.1f} min'.format((end_time - start_time) / 60)) |
import logging | |
# REFERENCES | |
# logging message attributes: https://docs.python.org/3/library/logging.html#logrecord-attributes | |
# datetime formatting: https://docs.python.org/3/library/datetime.html#strftime-and-strptime-behavior | |
# --------------------------------------------- | |
# BASIC LOGGING | |
# --------------------------------------------- |