Skip to content

Instantly share code, notes, and snippets.

View Drblessing's full-sized avatar
:shipit:

Dev Daniel Drblessing

:shipit:
View GitHub Profile
# Python OOP Examples
from abc import ABC, abstractmethod
from datetime import datetime
# Abstract Base Class
# Defines abstract methods that must be implemented
class Building(ABC):
# Properties are managed attributes
@property
"""
Observer Design Pattern for Car objects when it starts.
"""
from __future__ import annotations
from abc import ABC, abstractmethod
from typing import List, Optional
class Subject(ABC):
# Observer Design Pattern
from __future__ import annotations
from abc import ABC, abstractmethod
from typing import List, Optional
from random import randrange
class Subject(ABC):
"""
The Subject interface declares a set of methods for managing and
@Drblessing
Drblessing / dependency_inversion_principle.py
Created June 7, 2023 20:13
The Dependency Inversion Principle: High level modules should not depend on low level modules.
# Dependency Inverson Principle
# High level modules should not depend on low level modules
# Without Dependency Inversion:
class LightBulb_wo:
def turn_on(self):
print("LightBulb: turned on...")
def turn_off(self):
print("LightBulb: turned off...")
@Drblessing
Drblessing / StakingRewardExploit.t.sol
Created May 26, 2023 17:17
Solidity-by-example StakingRewards exploit
// SPDX-License-Identifier: MIT
pragma solidity ^0.8;
import "forge-std/Test.sol";
import "forge-std/console.sol";
import "../src/StakingRewards.sol";
IERC20 constant WETH = IERC20(0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2);
@Drblessing
Drblessing / PayableForward.sol
Created May 4, 2023 00:51
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.8.18+commit.87f61d96.js&optimize=false&runs=200&gist=
// SPDX-License-Identifier: GPL-2.0
pragma solidity >=0.8.9;
contract PayableForward {
Forwardee forwardee;
constructor(Forwardee forwardee_) {
forwardee = forwardee_;
}