Skip to content

Instantly share code, notes, and snippets.

View itolosa's full-sized avatar
🎯
Focusing

Ignacio Tolosa itolosa

🎯
Focusing
View GitHub Profile
@itolosa
itolosa / clean_architecture_2023_05_16.md
Last active May 21, 2023 01:56
Clean Architecture Notes

How to pass the ViewModel from the Presenter to the View?

Solution 1: Inject a shared reference

You could use a shared reference between the view and the presenter to store the viewModel (as a data structure).

For example, using dependency injection:

Response perform(Request request) {

How to refactor code

Refactoring: Change the code's structure without changing its external behavior

  • Low coupling: Separate all that's possible to separate without making a mess
  • High cohesion: Minimize the mess ~ Minimize the inter-group dependencies and maximize the intra-group ones

Invariants:

  • Behavior must be the same at all times - i.e Testing
@itolosa
itolosa / morse.py
Created September 28, 2023 20:02
morse translator
import random
alphabet = {
".-": "A",
"-...": "B",
"-.-.": "C",
"-..": "D",
".": "E",
"..-.": "F",
# based on edx harvard cs50ai uncertainty lesson source code
from pgmpy.models import BayesianNetwork
from pgmpy.factors.discrete import (
TabularCPD,
)
from pgmpy.inference import VariableElimination
model = BayesianNetwork(
[
@itolosa
itolosa / inference.py
Last active October 5, 2023 03:49
CS50AI - Lecture 2 - Bayesian Network updated source code
import torch
from model import model
X = torch.tensor(
[
[
-1,
-1,
1, # delayed
-1,