teleren/devto huggingface dataset:
Understanding SOLID Principles with Python Examples
Tags: python, solid, programming, softwareengineering
Published: 2024-07-10 07:27:19

## Understanding SOLID Principles with Python Examples

The SOLID principles are a set of design principles that help developers create more maintainable and scalable software. Let's break down each principle with brief Python examples.

### 1. Single Responsibility Principle (SRP)
A class should have only one reason to change, meaning it should have only one job or responsibility.

```python
class Invoice:
    def __init__(self, items):
        self.items = items

    def calculate_total(self):
        return sum(item['price'] for item in self.items)

class InvoicePrinter:
    def print_invoice(self, invoice):
        for item in invoice.items:
            print(f"{item['name']}: ${item['price']}")
        print(f"Total: ${invoice.calculate_total()}")

# Usage
invoice = Invoice([{'name': 'Book', 'price': 10}, {'name': 'Pen', 'price': 2}])
printer = InvoicePrinter()
printer.print_invoice(invoice)
```

### 2. Open/Closed Principle (OCP)
Software entities should be open for extension but closed for modification.

```python
class Discount:
    def apply(self, amount):
        return amount

class TenPercentDiscount(Discount):
    def apply(self, amount):
        return amount * 0.9

# Usage
discount = TenPercentDiscount()
print(discount.apply(100))  # Output: 90.0
```

### 3. Liskov Substitution Principle (LSP)
Objects of a superclass should be replaceable with objects of a subclass without affecting the correctness of the program.

```python
class Bird:
    def fly(self):
        return "Flying"

class Sparrow(Bird):
    pass

class Ostrich(Bird):
    def fly(self):
        return "Can't fly"

# Usage
def make_bird_fly(bird: Bird):
    print(bird.fly())

sparrow = Sparrow()
ostrich = Ostrich()
make_bird_fly(sparrow)  # Output: Flying
make_bird_fly(ostrich)  # Output: Can't fly
```

### 4. Interface Segregation Principle (ISP)
Clients should not be forced to depend on interfaces they do not use.

```python
class Printer:
    def print(self, document):
        pass

class Scanner:
    def scan(self, document):
        pass

class MultiFunctionPrinter(Printer, Scanner):
    def print(self, document):
        print(f"Printing: {document}")

    def scan(self, document):
        print(f"Scanning: {document}")

# Usage
mfp = MultiFunctionPrinter()
mfp.print("Document1")
mfp.scan("Document2")
```

### 5. Dependency Inversion Principle (DIP)
High-level modules should not depend on low-level modules. Both should depend on abstractions.

```python
class Database:
    def connect(self):
        pass

class MySQLDatabase(Database):
    def connect(self):
        print("Connecting to MySQL")

class Application:
    def __init__(self, db: Database):
        self.db = db

    def start(self):
        self.db.connect()

# Usage
db = MySQLDatabase()
app = Application(db)
app.start()  # Output: Connecting to MySQL
```

These examples illustrate the SOLID principles in a concise manner using Python. Each principle helps in building a robust, scalable, and maintainable codebase.
Import the database from the Heroku dump
Tags: db, import, shell, heroku
Published: 2024-07-10 07:33:54

Occasionally, as developers, we have to import staging or production databases and restore them to our local system in order to recreate bugs or maintain the most recent version, among other reasons.

Manual work takes a lot of time and can result in mistakes.

I propose creating a shell script that will do everything automatically, giving us more time to focus on our work.

Here's an example 


File name can be `import_remote_db.sh` for example

```shell
#!/bin/bash

# stop on first error
set -e

for ARGUMENT in "$@"
do
   KEY=$(echo $ARGUMENT | cut -f1 -d=)

   KEY_LENGTH=${#KEY}
   VALUE="${ARGUMENT:$KEY_LENGTH+1}"

   export "$KEY"="$VALUE"
done

command -v heroku >/dev/null 2>&1 || { echo >&2 "heroku command is required"; exit 1; }
command -v docker-compose >/dev/null 2>&1 || { echo >&2 "docker-compose command is required"; exit 1; }

DUMPFILE="tmp/db_dump.dump"

if [ -e $DUMPFILE ]
then
    echo "backup db found trying to restore it"
else
    echo "backup db not found downloading from heroku"
    heroku pg:backups:download --output=$DUMPFILE --app=${app:-heroku-app-name}
fi

# This will usually generate some warnings, due to differences between your Heroku database
# and a local database, but they are generally safe to ignore.
docker-compose run db pg_restore --verbose --clean --no-acl --no-owner -h db -p 5433 -U u_name -d db_name $DUMPFILE
```
Here, it first verifies that the packages `docker-compose` and `heroku` are installed. 
Next, it attempts to retrieve the database backup file; if this fails, it attempts to fetch data from `heroku`. Keep in mind that we must first complete the `heroku login` instruction.

Using the `docker-compose` console, it adds to a local database after the backup is done. If you do not need to use docker images at all, you can simply replace this with your local `PostgreSql` server.

To run the script use 
`sh import_remote_db.sh`
You can also specify app name via
`sh import_remote_db.sh app=heroku_app_name`

Note: Make sure you backup your data before running the script if the Heroku app does not have automated daily or hourly backups. If not, you risk running out of backup data.

I saved a ton of time and effort during my work with this straightforward script.
MartialShop APP
Tags: programming, flutter, dart
Published: 2024-07-10 07:34:41

This is one of my projects that is written in Dart using Flutter framework.
This is an e-commerce app for martial arts products called : MartialShop
![](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ajrolhryq1z91appcfdt.jpg)
It's incomplete for now.
Here you can see parts of it.

This is the main page where products are shown
![This is the main page where products are shown](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ny8ghpymrttttl0io9z5.jpg)

This is the products page where details and pictures are shown
![This is the products page where details and pictures are shown](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/14g1cqk2ulbdo1w1mlca.jpg)

This is the cart page where you can submit your order
![This is the cart page where you can submit your order](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gb49m46x5f3wtwsmvm79.jpg)

If you want to know more about the app and be informed about it,
join our [Telegram Channel](https://t.me/DevHalen)
Which Python framework is used for mobile app development?
Tags: python, pythonframeworks
Published: 2024-07-10 07:39:25

For Mobile app development, Python GUI frameworks like Kivy and Beeware are very important. 

Kivy is a popular open-source [Python framework for mobile app development](https://www.ongraph.com/a-list-of-top-10-python-frameworks-for-app-development/) that offers rapid application development of cross-platform GUI apps. With a graphics engine designed over OpenGL, Kivy can manage GPU-bound workloads when needed.

BeeWare is another Python framework for Python iOS development & mobile app development that enables developers to code apps in Python and cross-compilation for deployment on several mobile platforms and OS like Android, Linux GTK, iOS, and Windows.
How Can I Efficiently Track and Manage Working Hours Using an Hour Calculator?
Tags: webdev, beginners, programming, tutorial
Published: 2024-07-10 07:41:45

I'm looking for the best ways to track and manage my working hours [Calculette Mauricette](https://mauricettecalculette.fr/). I've heard about hour calculators but I'm not sure which one would be the most efficient and user-friendly. 

Can anyone recommend a good hour calculator tool that they have used? Additionally, any tips on how to integrate it into daily work routines for optimal time management would be greatly appreciated.
sumatra slim belly tonic
Tags: weightloss, testing, database, security
Published: 2024-07-10 07:43:19

[Sumatra Slim Belly Tonic](https://sumatraslimbellytonicsite.online/) appears to be marketed as a weight loss supplement, often promoted with claims of helping people lose weight quickly and easily. However, it's important to approach such products with caution and skepticism, as many weight loss supplements can make exaggerated claims that are not supported by scientific evidence.
What Is Java? - Java Programming Language Explained
Tags: webdev, beginners, programming, learning
Published: 2024-07-10 07:52:15

Java was invented to make it easier to write code, easier than C++.

There is a bunch of things, a bunch of bookkeeping that you have to manage with C++, that you don't have to manage with Java.

The downside with Java is that it is slow compared to C++. It runs really really slow, but, for many many types of apps, many business apps, Java runs pretty fast and is pretty capable.

A big advantage of Java is that it is easier to write in respect to C++, and it gets the job done faster especially for types of work such as web apps.

You would write a web app in C++ but it would be crazy. It will take you forever to do it. You do it in Java much much quicker.

Java is also used in android development as well, although that might be fading because there is a newer faster language called Kotlin, that Google has endorsed.

It is easier with Kotlin over Java.

Java may fade in terms of being used to create apps for android devices. But today, Java is used hugely for legacy apps that are web based, and server based, again, working for very large corporations.

-----

P.S. [Follow me on X](https://x.com/thekarlesi) for more tech content.
JavaScript Design Patterns - Behavioral - Mediator
Tags: programming, javascript, beginners
Published: 2024-07-10 07:57:12

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tja0ay1kedi6e9h6d30q.png)

The **Mediator** pattern allows us to reduce chaotic dependencies between objects by defining an object that encapsulates how a set of objects interact.

The **Mediator** pattern suggests that we should cease all direct communication between the instances we want to make independent of each other.

Instead, these instances must collaborate indirectly by calling a special mediator object that redirects the calls to appropriate instances.

In the example below, we are creating a class mediator **TrafficTower**, to let us know all the positions from the airplane instances.

```js
class TrafficTower {
  constructor() {
    this.airplanes = [];
  }

  getPositions() {
    return this.airplanes.map(airplane => {
      return airplane.position.showPosition();
    });
  }
}

class Airplane {
  constructor(position, trafficTower) {
    this.position = position;
    this.trafficTower = trafficTower;
    this.trafficTower.airplanes.push(this);
  }

  getPositions() {
    return this.trafficTower.getPositions();
  }
}

class Position {
  constructor(x,y) {
    this.x = x;
    this.y = y;
  }
  
  showPosition() {
    return `My Position is ${this.x} and ${this.y}`;
  }
}

export { TrafficTower, Airplane, Position };
```

A complete example is here 👉 https://stackblitz.com/edit/vitejs-vite-zvu5ed?file=main.js

**Conclusion**

We can use this pattern when objects communicate between them but in complex ways.

---

I hope you found it helpful. Thanks for reading. 🙏

Let's get connected! You can find me on:
- **Medium:** https://medium.com/@nhannguyendevjs/
- **Dev**: https://dev.to/nhannguyendevjs/
- **Hashnode**: https://nhannguyen.hashnode.dev/
- **Linkedin:** https://www.linkedin.com/in/nhannguyendevjs/
- **X (formerly Twitter)**: https://twitter.com/nhannguyendevjs/
- **Buy Me a Coffee:** https://www.buymeacoffee.com/nhannguyendevjs
Sustainability Benefits of Wing Expansion Boxes
Published: 2024-07-10 08:21:22

How many times has your sandwich ended up squished in the bottom of a lunchbox or leftovers leaked out all over you fridge? The Wing Expansion Box is the next big thing in storage boxes and other container systems that aim to upgrade your food into optimal preservation system. Not only that, but these special material boxes will keep your food fresh and save our Earth as well. modular house cost.
Advantages of Wing Expansion Boxes

Benefits of Wing Expansion Boxes are remarkable. These are boxes that you can use time, and not like those nasty Earth-killing single-use plastic ones. Wing Expansion Boxes help maintain a healthier planet What's more, their leak-proof construction helps to keep food safe and secure in either your bag or fridge. Products.
Using the Wing Expansion Boxes

Wing Expansion Boxes make life easy All you have to do is unfold the box, drop your food in it and enclose the little guy before storing him away back into your bag or fridge. It is also very easy to clean – just wash under soap and water. buy container house.
If you would like me to improves or change the text, let me know!
Wednesday Links - Edition 2024-07-10
Tags: libphonenumber, wireshark, tcpdump, jq
Published: 2024-07-10 08:28:29

Shell Spell: Extracting and Propagating Multiple Values With jq (3 min)🧙‍♂️
https://www.morling.dev/blog/extracting-and-propagating-multiple-values-with-jq/

The Best Way to Handle Phone Numbers (2 min)☎️
https://foojay.io/today/the-best-way-to-handle-phone-numbers/

Wireshark & tcpdump: A Debugging Power Couple (8 min)🔌
https://foojay.io/today/wireshark-tcpdump-a-debugging-power-couple/
Understanding SAP BASIS: The Backbone of SAP Systems
Published: 2024-07-10 08:28:58

Introduction
SAP BASIS plays a critical role in the smooth operation of SAP systems. It encompasses various tasks and responsibilities that are essential for the administration and management of SAP applications. This blog aims to provide a comprehensive overview of what SAP BASIS is and why it is considered the backbone of SAP systems.

What is SAP BASIS?
SAP BASIS stands for "Business Application Systems Integrated Solutions." It is the underlying system administration and technical architecture that supports various SAP applications. BASIS professionals are responsible for ensuring the stability, performance, and security of SAP systems.

Core Responsibilities of SAP BASIS
System Administration:

Installation and configuration of SAP systems.
Managing SAP instances and system landscapes.
Database Administration:

Maintenance and monitoring of the underlying database (e.g., Oracle, SAP HANA).
Database backup and recovery.
Performance Monitoring and Tuning:

Monitoring system performance using tools like SAP Solution Manager.
Tuning parameters to optimize system performance.
User and Authorization Management:

User administration, including creation, deletion, and modification of user accounts.
Role and authorization assignment to ensure data security.
Transport Management:

Managing the transport of changes between SAP systems using Transport Management System (TMS).
Ensuring seamless movement of configurations and developments across landscapes.
System Upgrades and Patch Management:

Planning and executing system upgrades to newer versions of SAP software.
Applying patches and updates to fix bugs and security vulnerabilities.
Security and Compliance:

Implementing security measures to protect SAP systems from unauthorized access.
Ensuring compliance with regulatory standards and company policies.
Why SAP BASIS is Essential
Foundation for SAP Applications: Without a well-maintained BASIS, SAP applications cannot function optimally.
Ensures Reliability: BASIS professionals ensure that SAP systems are reliable and available for business operations.
Supports Growth and Innovation: By managing system upgrades and optimizations, BASIS supports the scalability and innovation within SAP environments.
Security and Compliance: BASIS professionals play a crucial role in maintaining the security posture of SAP systems, ensuring data integrity and compliance with industry regulations.
Conclusion
SAP BASIS is more than just technical administration; it is the backbone that supports the entire SAP landscape. Understanding its role and responsibilities is crucial for anyone involved in SAP system management or considering a career in [SAP BASIS](https://intellimindz.com/sap-basis-training-in-chennai/). By mastering BASIS fundamentals, organizations can leverage SAP systems effectively to drive business success and innovation.
How Do I Speak With [QuickBooks Desktop Support] Now 855-200 0590
Tags: webdev, javascript, beginners, tutorial
Published: 2024-07-10 08:33:28

If you need help with [QuickBooks Desktop (https://community.ruckuswireless.com/t5/Community-and-Online-Support/How-Do-I-Speak-With-QuickBooks-Desktop-Support-Now-855-200-0590/m-p/83275#M2693), you can speak directly with our support team by calling 855-200-0590. Our knowledgeable specialists are ready to assist you with installation, setup, troubleshooting errors, and optimizing your QuickBooks Desktop experience. Whether you’re facing technical issues or have questions about specific features, our team is here to provide timely and effective solutions. Don’t let technical difficulties slow you down; call QuickBooks Desktop support at 855-200-0590 for professional assistance and get back to business quickly.
Fildena 100 Tablets (Purple Pills) | Sildenafil | Reviews
Published: 2024-07-10 08:34:02


What is Fildena 100 Purple pill?

[Fildena 100 Purple Pill](https://powmedz.com/product/fildena-100-mg-purple-viagra-pill/), also known as the "weekend pill," contains 100 milligrams of sildenafil citrate and is used to increase blood flow to certain areas of the body, and also helps treat erectile problems in older men between the ages of 18 and 70.


Because this is the same active ingredient as Viagra, the drug is also known as generic Viagra, but taking Fildena 100 is more effective and less expensive than Viagra


**

What is Fildena 100 used for?**

Typically, Fildena 150 mg helps increase blood flow to the penis. This pill is also known as the "purple triangle pill." You can get an erection that lasts up to four hours.



This medicine helps in the following conditions:

Erectile dysfunction
Pulmonary hypertension
Mental problems and anxiety
Sexual problems
Sexual stimulation
High blood pressure
Enlarged prostate


**How to use Fildena 100 Purple? What is the correct dosage?
**
We do not recommend taking Fildena 100 mg Purple without a prescription, as some factors depend on metabolism, blood flow, mental state and other external factors. We know you are interested in this application. Therefore, first of all, take Fildena 100 Purple tablets with a glass of water 30 minutes before sexual activity.



The dosage depends on several factors, such as age, weight, medical history and the purpose of the prescription. A doctor is the best person to determine the dosage, but the dosage may vary from case to case. Standard doses can be 150 mg fildena, Fildena 200 mg, or between several variations.



**How much does one pill of fildena purple cost?
**
Usually, at the trusted online pharmacy [Powmedz](https://powmedz.com/), fildena dosages start at just $0.75 per pill, but this entirely depends on the pack size you choose.


Is fildena 100 MG approved by the FDA?

Yes, fildena tablets are 100% approved. Fildena pills contain sildenafil citrate, which is safe and approved in the United States for the treatment of erectile dysfunction. Those who are unsure of its approval status need not worry. It is approved in the United States and can be purchased as a medicine.

How long does it take for fildena to work?

The effect of the pill usually lasts for 4 to 6 hours. If your body responds well to the pill, you will feel the effect for longer, but if your body responds slowly, the effect of the pill may last only 4 hours.
Kim Ha-sung contributes to victory at a high level despite poor batting performance
Published: 2024-07-10 08:35:21

At the end of this season, Kim Ha-sung, a free agent (FA) of the San Diego Padres in the U.S. professional baseball, who is eligible for free agency, has been found to have a top-level winning contribution (WAR).

According to FanGraph, a sabermetric site that collects various statistics on MLB players, Kim Ha-sung's WAR is 2.6, second to Jurickson Profar's 3.3. This means that he greatly contributes to his team's victory. He is 49th when expanding to the entire MLB, and 24th when narrowing down to the National League.

Kim Ha-sung, whose batting average has fallen since playing full-time shortstop this season, is tied for sixth with 10 homers, 5th in RBIs, 47 walks, 17 stolen bases, and 0.331 on-base percentage with a batting average of 0.331. However, the batting average is 0.229, which is somewhat disappointing.

If there's any comfort, Kim Ha-sung showed his strong side in July. If you look at Kim Ha-sung's MLB career performance, he always peaked in July. According to Kim Ha-sung's monthly statistics from April to September, entering the MLB in 2021, July was his best month in 63 games with a batting average of 0.304, seven homers, 26 RBIs, and 33 points.

Kim Ha-sung continued his rise in July and played in 24 games, batting .337 with five home runs, nine RBIs and 21 points, eventually ending the season with a career high.

If he can raise his batting average to 240 before the All-Star break, Kim Ha-sung is expected to gain momentum in the second half of the season. Kim Ha-sung has 193 RBIs in his career, and if he adds seven, he will reach the 200 RBIs mark.

[토토사이트 모음](https://www.outlookindia.com/plugin-play/2023년-11월-스포츠-토토사이트-순위-및-추천-사설토토-먹튀검증-top15-news-328577
)
picoCTF Mod 26 Write Up
Published: 2024-07-10 08:38:10

**Details:**
**Points:** 10
Jeopardy style CTF
**Category:** Cryptography
**Comments:**
Cryptography can be easy, do you know what ROT13 is?

```
cvpbPGS{arkg_gvzr_V'yy_gel_2_ebhaqf_bs_ebg13_MAZyqFQj}
```
ROT13 is a cipher that rotates each character 13 letters over. The mod 26 is a hint about looping back around. You can use an online decoder but since I'm trying to explain things a bit more here I decided to make a small script to decode this:

```
# initial encrypted text
flag = "cvpbPGS{arkg_gvzr_V'yy_gel_2_ebhaqf_bs_ebg13_MAZyqFQj}"

# A-Z
AZ = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"

# a-z
az = "abcdefghijklmnopqrstuvwxyz"

# string to store result
s = ""

# iterate through encrypted flag
for x in flag:
    # if the character is in AZ
    if x in AZ:
        # go 13 characters further from the current character
        s += AZ[(AZ.index(x)+13)%len(AZ)]
        # if the character is in az
    elif x in az:
        # go 13 characters further from the current character
        s += az[(az.index(x)+13)%len(az)]
    else:
        # else add the character
        s += x

# print string
print(s)
```

After running this script, you can get the flag:

```
picoCTF{next_time_I’ll_try_2_rounds_of_rot13_aFxtzQWR}
```
How To Calculate MAP Pricing?
Tags: calculatemappricing, minimumadvertisedprice
Published: 2024-07-10 08:41:37

Explore the importance of[ Minimum Advertised Price](https://www.iwebscraping.com/how-to-calculate-map-pricing.php) (MAP) and how MAP pricing is calculated and how it helps ensure fair competition, maintains profit margins, and builds consumer trust.