Skip to content

Instantly share code, notes, and snippets.

View chrisfalter's full-sized avatar

Christopher Falter chrisfalter

View GitHub Profile
@chrisfalter
chrisfalter / tfidf.py
Created June 13, 2022 22:19
How to Implement TF-IDF in Python
from collections import Counter
import math
from string import punctuation
from typing import List
from nltk.tokenize import word_tokenize
import nltk
nltk.download("punkt")
test_corpus = ["The quick, brown fox jumps, over the lazy dog.", "Never jump over the lazy dog quickly."]
@chrisfalter
chrisfalter / binary_search.py
Last active April 20, 2022 03:36
A reasonably robust binary search *with unit tests*
from typing import List, Tuple
import pytest
def binary_search(desired_member:Tuple[int, float], sorted_list:List[Tuple[int, float]]) -> int:
"""perform binary search over sorted list, return index of desired member"""
# check parameter type
if not (type(desired_member) is int or type(desired_member) is float):
raise TypeError("desired_member must be a number")
@chrisfalter
chrisfalter / merge-to-master.sh
Created April 19, 2022 06:30
Merge back to master
~/code/my_repo $ git checkout master
~/code/my_repo $ git merge dev
~/code/my_repo $ git push origin
@chrisfalter
chrisfalter / add_commit_push.sh
Created April 19, 2022 06:25
Store your work on the git server
~/code/my_repo $ git add .
~/code/my_repo $ git commit -m "helpful, short commit message" .
~/code/my_repo $ git push origin
@chrisfalter
chrisfalter / start_local.sh
Created April 19, 2022 06:22
Start working locally with a git repo
$ cd ~/code # or wherever you work on code
~/code $ gcloud source repos clone my_repo
~/code $ cd my_repo
~/code/my_repo $ git checkout -B dev
@chrisfalter
chrisfalter / repo_names.csv
Last active April 19, 2022 05:21
Better Names for Version Control Repositories
POOR NAME COMMENT BETTER NAME
FlaskPredictionService What if you switch from Flask to Lambda? ProductRecommendationService
repo_chris Indicate the business concern UserSessionAnalysis
graph-analytics Model class could change; naming convention InfluencerMetrics
@chrisfalter
chrisfalter / gist:496509616ec40fa9fd3344ed5f9ddbde
Last active April 19, 2022 03:54
A simple gitignore to exclude Python notebooks
# .gitignore
__pycache__
.ipynb*