Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save chrisbarnes2000/5ea808f94e70b2547a26759458c46b0e to your computer and use it in GitHub Desktop.
Save chrisbarnes2000/5ea808f94e70b2547a26759458c46b0e to your computer and use it in GitHub Desktop.

Notes on Debuging

If you can’t find the bug, you’re looking in the wrong place. Go back to where it last worked. Contain the bug. Look for the bug in a new place, time, or format. Be responsible for the code. Learn from the bug.

  • Reading new docs, recent stack-overflow/GitHub discussions, and doing minor test outside of the project to develop workarounds and patches for deprecations and/or errors.

?s

What error message (if any) is there?

What line number is causing the error?

What is the actual output vs. the expected?

What assumption(s) the developer has made?

Techniques

  • Trace Backward: If there is a specific line number causing the error
  • Trace Forward: If you aren't sure which line is causing the error
  • Divide and Conquer: If there are multiple areas which may have caused the error

Trace backward, figure out which line of code is producing the error.

Then, work backwards one line at a time until you find the source of the bad data.
Use this technique when...

- The error is thrown from a known location
- You understand the program well enough to know what it's supposed to be doing

Trace forward, start at the beginning of your program.

Then, work forwards one line at a time and verify that your mental model matches the result, using a debugger or log statements.
Use this technique when...

- The problem line isn’t known
- You can't narrow down the problem to one specific area of the code

To divide and conquer:

Identify different code sections that could have caused the error
Use breakpoints or log statements at the boundaries to test which area is the problem
Focus your efforts on that area using Trace Forward or Trace Backward
Use this technique when...

- There are multiple areas where the error could have come from

Example Sketch

#! Plan OF Attack
'''
First, Skim the Functions main and contains_3_consecutive from above, what do you expect to be outputed?
- expected output
    -
    - output would be:
    -
Next, Run the code in the terminal with pyhron3 exercise-1.py to view the Actual Output
- actual

Looks Like we got a call to the Traceback, can you spot what the error message is?
-
Can you find what line(s) may be causing said error?
    -
    -
-
What can you deduce about the cause of the error?
-
What assumptions did the developer(s) make, State them here
-
State your Solutions/Assumptions here
- To Fix this error Change
'''

Interview_Breakdown

"""Problem: -

Example Input:
    -

Example Output:
    -

-1 Restate the problem - -2 Ask clarifying questions - -3 State your assumptions - -4 Think out loud -4a Brainstorm solutions - -4b Explain your rationale - -4c Discuss tradeoffs - -4d Suggest improvements - """

"""Pseudo Approach -

Edge Cases:
    -

Complexity Check:
    After implementing some code go back through and revaluate its time and/or space complexity -- refractor/improve/find more edge cases -- repeat

"""

class ClassName: def function_name(self, param): function_return = None return function_return

if name == "main": # RunTime: c = ClassName() param = None function_output = c.function_name(param) print(function_output)

Things To Consider

  • Vertical scailing

  • Horizontal scailing

  • Load Balancing

  • Availability

  • Security

  • Maintenance

  • Monitoring

  • And... actual features

    • Implemented user facing features for the mobile banking app

    • Responsible for driving adoption of software best practices

    • Implemented functional stories per business requirements

    • Implemented many critical parts of the system

    • Mentored junior developers on the team

    • Colaborated with business stakeholders to understand requirements

    • Colaborated with QAs and DevOps engineers to deploy application to production

    • Architected an Event-Driven system based on Apache Kafka composed of ~20 microservices, enabling real-time decision-making supporting airport’s operational capabilities

    • Led a team of 15 backend, frontend, mobile and DevOps engineers and Data Scientists to develop the system

Create Empty Branch

git checkout --orphan empty-branch

Then you can remove all the files you'll have in the staging area (so that they don't get committed):

git rm -rf .

At this point you have an empty branch, on your machine.

Before you can push to GitHub (or any other Git repository), you will need at least one commit, even if it does not have any content on it (i.e. empty commit), as you cannot push an empty branch

git commit --allow-empty -m "root commit"

Finally, push it to the remote, and crack open a beer

git push origin empty-branch

Two of my fav aliases rn:

💻 Delete merged branches:

alias bclean="git branch --merged | egrep -v '(^*|master|main)' | xargs git branch -d"

💻Delete/reinstall node modules:

alias nclean="rm -rf node_modules/ && rm package-lock.json && npm i"


UpgradeRequirements

In Hermes' comment, he suggests freezing all of your dependencies in order to have predictable builds.

When doing that, you can update all dependencies at once like this:

sed -i '' 's/==/>=/g' requirements.txt
pip install -U -r requirements.txt
pip freeze > requirements.txt

Having done the above, test your project with the new set of packages and eventually commit the requirements.txt file to the repository.


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment