Skip to content

Instantly share code, notes, and snippets.

View brianspiering's full-sized avatar

Brian Spiering brianspiering

  • San Francisco, CA, USA
View GitHub Profile
@brianspiering
brianspiering / negative_r_squared.ipynb
Last active January 10, 2022 17:54
Negative R² example
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@brianspiering
brianspiering / Brewfile
Last active January 4, 2023 22:53
My Brewfile
tap "heroku/brew"
tap "homebrew/bundle"
tap "homebrew/cask"
tap "homebrew/cask-fonts"
tap "homebrew/cask-versions"
tap "homebrew/core"
tap "mongodb/brew"
brew "openjdk@11"
brew "apache-spark"
brew "scala"
@brianspiering
brianspiering / pip_update.py
Last active December 16, 2021 18:16
Find and update all pip packages within Python
# Find and update all pip packages within Python
# This code is dangerous but gets the job done 💀 💼
import pkg_resources
from subprocess import call
ignored = {'pycurl', 'tbb', 'daal', 'gast'}
packages = {dist.project_name for dist in pkg_resources.working_set
if dist.project_name not in ignored}
# Update each package individually
@brianspiering
brianspiering / techniques_to_improve_as_a_programmer.md
Last active March 9, 2022 17:09
Techniques to improve as a programmer

Techniques to improve as a programmer

Do not be the person who has practiced 10,000 things once, but be the person who has practiced one thing 10,000 times.
— Intentionally misquoting Bruce Lee

  1. Write a lot of code. Physically type code and run it (if either part is missing, it is not quality code practice).
  2. Think of coding practice as a portfolio. It should be a mix:
    • 40-60% Easy-for-you fundamentals. Practicing Pythonic idioms to solve common atomic problems. This develops fluency to solve novel challenges and build up to more advanced coding.
  • 20-30% Difficult-but-possible problems. LeetCode and similar is good for this level.
@brianspiering
brianspiering / debugging_advice_for_programming.md
Last active July 20, 2023 16:57
Debugging advice for programming

What to do when your code doesn't work

Follow these steps:

  1. Don't Panic! Relax and realize that you will solve this problem, even if it takes a little bit of messing around. Banging your head against the computer is part of your job (both as a student and as a professional programmer). Remember that the computer is doing precisely what you are telling it to do. There is no magic.

  2. Determine precisely what is going on. Did you get an error message from Python? If it is a SyntaxError, a helpful guide is here. Also, running your code in Python 3.11 or higher has improved error messages.

  3. Python error messages include a stack trace. There could be a number errors throughout the stack. You read a stack trace from bottom to top. Go slowly and understand each character and each line.

@brianspiering
brianspiering / debugging_advice_for_programming.md
Created December 4, 2021 01:38
Debugging advice for programming

What to do when your code doesn't work

If you have problems, follow these steps:

  1. Don't Panic! Relax and realize that you will solve this problem, even if it takes a little bit of messing around. Banging your head against the computer is part of your job. Remember that the computer is doing precisely what you tell it to do. There is no mystery.

  2. Determine precisely what is going on. Did you get an error message from Python? Is it a syntax error? If so, review the syntax of all your statements and expressions.

  3. If you got an error message that has what we call a stack trace, a number of things could be wrong. You read a stack trace from bottom-to-top. Go slowly and understand each character and each line.

@brianspiering
brianspiering / jn.md
Created November 24, 2021 04:31
Jupyter Notebook extensions
pip install jupyter_contrib_nbextensions
pip install jupyter_nbextensions_configurator
jupyter contrib nbextension install --user 
jupyter nbextensions_configurator enable --user
@brianspiering
brianspiering / install_tensorflow_on_apple_m1.md
Last active April 14, 2022 17:15
Installing TensorFlow/Keras on Apple's M1

Instructions

  1. Download the wheel called tensorflow-2.4.1-py3-none-any.whl located at this public google drive link:
    drive.google.com/drive/folders/1oSipZLnoeQB0Awz8U68KYeCPsULy_dQ7

  2. Assuming you downloaded the wheel to your Downloads folder, install it with pip:
    $ pip install ~/Downloads/tensorflow-2.4.1-py3-none-any.whl --user

  3. Test that it works with ipython at the command line: