teleren/devto huggingface dataset:
PostgreSQL Replication (Part 3)
Published: 2023-07-17 01:05:09

Modes of Replication in PostgreSQL Database :

Synchronous mode of Replication : Transactions on the master database in this mode are not considered complete until all replicas have received the modifications. For the transactions to successfully complete on the master, all of the replica servers must be up at all times.


Asynchronous mode of Replication : When changes have only been made on the master server in this mode, transactions on the master server can be deemed complete. Later, these modifications are reproduced to the copies.


Types of PostgreSQL Database Replication?

Physical Replication of PostgreSQL Database : 
In Physical replication, we deal with with files and directories. 
Physical replication is done at file system level or disk level.
Logical Replication of PostgreSQL Database :
In Logical Replication, we deal with databases, tables, and DML operations.
Logical replication is done at the database cluster level.
PostgreSQL Replication (Part 2)
Published: 2023-07-17 01:04:31

PostgreSQL Replication

 Models of PostgreSQL Database Replication : 
Single-Master Replication (SMR) : This process replicates modifications to table rows in a selected master database server to one or more replica servers. The replica database's replicated tables are not allowed to accept any changes (apart from those made by the master). Changes are not replicated back to the master server, even if they occur.
Multi-Master Replication (MMR) : This method replicates changes to table rows in multiple designated master databases to the corresponding tables in all other master databases. Conflict resolution techniques are frequently used in this paradigm to prevent issues like multiple main keys.

Classes of PostgreSQL Replication : 
Unidirectional Replication : Since in single-master replication data only moves in one direction, from master to replica, single-master replication is often referred to as unidirectional replication. 
Bidirectional Replication : On the other side, data from Multi-Master Replication travels both ways and is referred to as bidirectional replication.
GraphQl Vs Rest Api
Tags: discuss, webdev, softwareengineering, web
Published: 2023-07-17 00:54:28

Looking at product development engineering, teams are quick to make an impact or achieve success while building a product of their dreams based on how efficient they are in choosing frameworks, architectures, and API architecture styles.

API architecture styles play a major role in how data is transported in an application; understanding what to choose is the key. Please share your view on what you think are the conditions and advantages of one over the other in choosing between graphQl and Rest Api architecture styles.
Composition over inheritance in OOP simple explanation
Tags: designpatterns, software, oop
Published: 2024-05-17 17:05:21

---
title: Composition over inheritance in OOP simple explanation
published: true
date: 2023-07-17 00:00:00 UTC
tags: designpatterns,software,oop
canonical_url: https://coffeebytes.dev/en/composition-over-inheritance-in-oop-simple-explanation/
---

Composition over inheritance is a recurring theme in object-oriented programming. Usually, it is explained in a very complex way, but today I will try to simplify it to the point where purists will hate me.

Let’s start, imagine you have a giant box of LEGO bricks, yes, those little plastic blocks that cause unimaginable pain when you step on them. But, in this case, we won’t use them to cause pain but to build different types of cars.

## Inheritance or composition

To build our tiny cars, there are two ways:

1. Inheritance: you can start with a basic car design, and then make changes to it to create different types of cars. But sometimes this turn into a complete disaster, since you can end up with some strange cars that won’t work properly.

2. Composition: Instead of starting with a basic car and changing it, you can use smaller LEGO pieces to build the different parts of a car, such as wheels, doors, and windows. Then put those pieces together to create different types of cars. This way, you have more control and flexibility to create exactly the type of car you want without making a mess.

So, **composition over inheritance means that it’s often better to build things by putting smaller parts together rather than changing one big thing to make something new**.

### Compositing over inheritance

And put in an example using Python code we would get something like:

``` python

# Inheritance 
class Car:
    def start_engine(self):
        print("Starting engine")

class SportsCar(Car):
    def start_engine(self):
        print("Rrrrrrrr! Starting engine")

# Composition 
class Engine:
    def start(self):
        print("Starting engine")

class Car:
    def __init__ (self):
        self.engine = Engine()

    def start_engine(self):
        self.engine.start()

class SportsCar:
    def __init__ (self):
        self.engine = Engine()

    def start_engine(self):
        print("Vroooooom! Starting engine")

# Using Composition
regular_car = Car()
regular_car.start_engine()

fast_car = SportsCar()
fast_car.start_engine()

```

In the inheritance example, we started with a basic “Car” and modified it to make a “SportsCar”. In the compositing example, we build an “Automobile” and a “SportsCar” by combining smaller parts, such as the engine. It’s like using LEGO pieces to build cars, and it gives us more control and flexibility when writing our programs.
I was on the Bright Founders Talk podcast!
Tags: entrepreneurship, infrastructure, podcast, update
Published: 2023-07-19 05:15:49

---
title: I was on the Bright Founders Talk podcast!
published: true
date: 2023-07-17 00:00:00 UTC
tags: entrepreneurship, infrastructure, podcast, update
cover_image: https://assets.brettops.io/blog/interview-bright-founders-talk-podcast/cover-1000x420.jpg
canonical_url: https://brettops.io/blog/interview-bright-founders-talk-podcast/
---

This week is a BrettOps first. I was honored to be a guest on [Temy's](https://www.temy.co/) [Bright Founders Talk](https://www.youtube.com/@temyco) podcast, where I got to talk about my philosophy on infrastructure, work-life balance, and entrepreneurship.

As an add-on achievement, I actually found an opportunity to work in a prodigious Python packaging alliteration right in the middle of the interview. 😆

I want to say thank you to Temy for having me on, and to Matthew Wickham for being an excellent host.

Enjoy!

{% youtube eTyRfd4a1PA %}
Edge Computing and the ChRIS Project
Tags: edge, edgecomputing
Published: 2023-07-16 23:48:39

Hello dear reader, today I am going to tell you about the open source project I am contributing to as an [Outreachy](https://www.outreachy.org/) intern, the ChRIS Project.

## ChRIS
ChRIS is an open source platform that makes computational medicine more accessible to researchers wherever they are, enabling them to conduct large-scale translational research in the cloud. It provides a common platform for researchers to innovate, develop and share computational medicine across the globe using a combination of public and private cloud resources. 

ChRIS is the result of a cooperative effort between [the Mass Open Cloud](https://massopen.cloud/) (MOC), [Red Hat](https://www.redhat.com/en) and [Boston Children's Hospital](https://www.childrenshospital.org/alliance?utm_campaign=FY21PCARegPractice&utm_medium=cpc&utm_source=google&utm_content=brockton&gad=1&gclid=Cj0KCQjwzdOlBhCNARIsAPMwjbyK2A7TwHuFElML0_nvA-C9h9XaaSFS-2IpYoW5jDNDZL9PMkLAjTsaAj1oEALw_wcB). It takes advantage of the latest technologies and user-friendly best practices to spur both creation and deployment of applications, so that users of the platform can simply focus on and only interact with their data. Everything else is abstracted away. Some of the technologies used in the development of ChRIS are:

- Kubernetes
- OpenShift
- Red Hat Enterprise Linux
- OCI Containers
- Swift  

You'll observe that they are all also open source and industry-standard.

So far, I have given a brief overview of what ChRIS is all about. Moving on, I will talk about the specific subproject within ChRIS that I am working on. This is **ChRIS in a Box**. The goal of **ChRIS in a Box** is to facilitate --with code and configurations-- the deployment of the ChRIS platform at the edge.

## What is the edge?
The **Edge** in this context refers to **edge-computing**. Edge-computing is the paradigm and practice of deploying applications and processing data much closer to the end users, where the data is being generated. The aim here is to enable greater processing speeds and volumes in a reliable and secure manner.

## ChRIS in a Box
I believe at this point you are beginning to get an idea of what the **ChRIS in a box** project is about. My work on **ChRIS in a box** is about containerizing the ChRIS platform with code and configurations in a way that it can be deployed on Red Hat edge devices and then transported to where it will be of great use. 
With ChRIS at the edge, ChRIS is then accessible at remote medical facilities for researchers to use, wherever they may be. I am using a lot of automated DevOps processes to facilitate easy, secure and reliable deployment of the ChRIS platform so they can really enjoy its benefits.

The ChRIS project is all about facilitating the cooperative analysis, development and distribution of computational medicine, and I am glad I get to work on this project.
The 35th & 36th Day of the 100 Days of Code challenge
Published: 2023-07-16 23:16:08

Hey everyone!
Yesterday was a traveling day and I arrived so late that I forgot to post. I finished making the real-time transcription with Whisper, I just need to refine some things like the requirements.txt file and check some things off the to-do list but the initial implementation is done. I still haven't pushed it as those things have to be done first.

I also worked on a project for a client and went to sleep.

Today was also a day of traveling, I just worked on two projects for two clients and that was it. Tomorrow morning, I'll finish everything in the real-time transcription app to finally push it and move on to the next project which is about improving my restaurant reservations app. Then there's some other projects I wanna make, among them exploring how LLM's like ChatGPT affect more complex automation tasks, it seems to be really promising so far especially with its ability to break down complex tasks to small problems.

That's it for these two days,
Happy coding everyone!

For those interested:

Being Israeli-French, I moved back to France for a couple of months but I didn't know how to speak French so I had to learn. I learned a good amount of French and now I'm practicing with my family, just here for a visit now :)
Why I used Local Storage for my citizen science app
Tags: webdev, database, web
Published: 2023-06-12 15:47:46

--- 
title: Why I used Local Storage for my citizen science app
published: true 
description: Using local storage for a citizen science mobile app 
tags: webdev, database, web
series: bee
--- 

Local storage is great because you can save data on the browser for web apps without the need for hosting (and paying for!) a database. Here's why we used it for Bee, a citizen science mobile app and entry to the 2023 Dev x GitHub Hackathon.

### About the app

![Record Bumblebees in the field; Realtime weather and geolocation; Log your sightings; View your data; #SaveTheBees | BeeWalk](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nkij206dujskpr2jcdwy.png)

Bee app allows a _BeeWalk_ citizen scientist to walk a survey outdoors, and record walk data including any sightings of bumblebees on their phone. Using the geolocation of the user, the app can fetch the real-time weather as well as the time the survey starts and ends.

## Persistence

Local storage is perfect for the small amounts of data citizen scientists collect on each walk.
`localStorage` persists data client-side after you close your browser tab, therefore the app saves data for a single field survey, this is useful for saving and displaying the data during the survey on a mobile device, and then being able to recall the data later to input into the recording submission system of the survey scheme.

This reproduces the behaviour of recording your survey on a paper form, entering the data in the submission system, then discarding the used form.

## Field portability

Being lightweight means users will use less storage and compute while in the field - that's important because you need the app to respond quickly during a survey, and you don't want to drain your device's power while you're away from any charger. It's not possible to stop-and-start your walk, or wait to re-charge your phone during a survey, as that will compromise the quality of your scientific data. Local storage is reliable if you go off-line - you can still access it to use without internet access, which is useful in the field!

## Coding visibility

It's easy to see what data you've stored, using Chrome browser inspect developer tool, the local storage contents are saved as key value pairs and viewed in the 'Application' tab:


![Chrome developer tools, shows data in local storage eg `sunshine: "Cloudy"
temperature: 19.5`](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/om1nzwfhcjbv1gjlafi7.png)

You can clear the saved data in the Inspect tool GUI or within your app code using `localStorage.clear()`. Data being passed to storage for a bee survey doesn't need to be secured, so there's no need to obfuscate data here.

---

Read more about `localStorage` in the [MDN web docs](https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage)
Which Technologies are Shaping the Ruby on Rails Ecosystem in 2023?
Tags: programming, ruby, rails, discuss
Published: 2023-07-16 22:34:15

I want to know what are the best technologies for a web system using Ruby on Rails. For example, in the front-end with JavaScript, some of these technologies include Vite, MUI, Reactstrap, and Axios.

But what about Ruby on Rails? Is it jQuery?

What technologies are you using in your ruby ​​on rails systems?

OBS: I work with this language and framework, but I don't have any senior or someone to help me and remove these doubts
Ruby Gym Sprint
Tags: learning, ruby
Published: 2023-07-16 22:28:12

Today I completed about 10 assigned Ruby exercises on Canvas. I managed to complete this sprint in < 1.5 hours.

Some classics included "Two Fer", "Raindrops" and "Leap Year".

I had already completed the majority of these exercises (in the Ruby Track) on exercism but I decided to write my solutions from scratch on Canvas.

In the next few days I will delve into http requests, continue practicing on exercism, and work on some projects in other languages.
Exercitation ad veniam ullamco elit non
Published: 2023-07-16 22:16:13

Culpa reprehenderit consectetur velit laboris qui enim excepteur anim incididunt nostrud elit cupidatat. Sint laborum deserunt reprehenderit pariatur. Exercitation cillum eiusmod do anim minim ut adipisicing.

Nostrud reprehenderit occaecat veniam occaecat nostrud. Occaecat duis nulla pariatur Lorem laborum do exercitation tempor excepteur mollit irure occaecat. Anim qui deserunt nostrud exercitation sunt proident. Ipsum proident nulla duis id magna est mollit ullamco mollit incididunt sit. Id ullamco occaecat ad reprehenderit qui aliqua anim proident eiusmod.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5aqbhovppdx1i05ub3m4.jpg)

Aute eiusmod proident nulla exercitation velit. Fugiat occaecat est velit aliqua fugiat eu eiusmod labore aute aute non fugiat. Occaecat in deserunt deserunt deserunt adipisicing. Voluptate ipsum dolor esse pariatur tempor cillum.

Sit consequat velit id in laborum labore pariatur. Et ea labore ut do pariatur occaecat laborum aliquip. Laborum cillum occaecat laboris ex sunt nisi. Nisi magna non consequat esse sint elit exercitation.

Veniam et exercitation veniam irure non anim cupidatat mollit anim. Aliquip aliqua labore eu duis. Nostrud adipisicing excepteur qui et proident enim deserunt quis culpa laborum. Ea nostrud cillum incididunt elit dolore adipisicing aute adipisicing in nostrud. Veniam occaecat nostrud non ut sunt amet. Enim ex reprehenderit eu labore in sit commodo aliquip nostrud eiusmod elit sunt. Ea pariatur ea aliquip exercitation magna aliquip consectetur.

Voluptate anim tempor sint reprehenderit id labore consequat proident amet. Voluptate aute amet ut exercitation. Enim elit sunt velit laboris culpa officia aute. Minim excepteur veniam proident sit. Ad consequat irure est excepteur esse exercitation aute nisi. Sint esse amet aliquip proident voluptate labore veniam deserunt fugiat.

Exercitation ad veniam ullamco elit non exercitation enim occaecat Lorem nisi cillum velit minim. Sit anim et fugiat laboris ex enim aliqua occaecat cupidatat dolor veniam dolore laboris proident. Adipisicing laboris culpa aliquip occaecat. Veniam ea dolor occaecat et voluptate commodo reprehenderit consectetur sit eu Lorem ut amet. Velit reprehenderit proident pariatur eiusmod.

Sunt amet in nulla id voluptate occaecat. Qui enim minim officia eiusmod ex culpa reprehenderit. Qui proident aute reprehenderit cupidatat irure ipsum fugiat aliqua sunt anim tempor mollit. Labore qui enim amet Lorem enim adipisicing proident in officia ex do velit ea esse. Adipisicing culpa exercitation do ad nisi. Ex labore ad cillum dolore.
Experiences of Early Career Software Developers Survey
Tags: devrel, career, computerscience, developer
Published: 2023-07-16 22:10:49

### An evidence-based software engineering study
***

#### TLDR; Are you a software developer* with **less than five years of experience**? Share your experience in our 10-minute survey.

Your contributions may help inform future early career engineers and their managers about what works and what doesn't during onboarding and beyond.

**Software developer, QA engineer, infra engineer, network engineer, security engineer, site reliability, dev ops, data engineer or related; or any type of lead or manager role.*

#### [Go to Survey](https://seattleux.qualtrics.com/jfe/form/SV_7V6HQ1gFbHJAyd8)
***
### Purpose of this Study
It is no secret that landing an entry-level software development role as a new graduate or early-career software developer in a saturated market is an arduous and highly competitive endeavor.

According to DataUSA, in the United States alone upwards of 50 thousand computer science degrees were awarded in 2020 and that number is expected to grow 12% each year.

#### But what happened after you landed that role?
![LinkedIn New Role Banner](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/38lup0not0nn8sbkzwz9.png)

The purpose of this study is to learn more about:

1. What is anecdotally called a “sink-or-swim” environment, the effects of this environment, and the actions that they take when they encounter it.

2. Gather evidence of what does not qualify as a sink-or-swim environment.

3. Gather evidence of what served as a positive environment for early-career developers.
#### [Go to Survey](https://seattleux.qualtrics.com/jfe/form/SV_7V6HQ1gFbHJAyd8)
***
Research Team 

![Research Team Photos](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6k4r8dql5hyf4mkwcqs2.png)

**Xin Zhao** is an Assistant Professor in the Department of Computer Science at Seattle University. His research spans Empirical Software Engineering, Model-Based Systems Engineering, Code Smells, and Systems Models Refactoring. View his website [here](https://qhd-zhaoxin.github.io/).

**Narissa** (Nars) Tsuboi is a Master of Computer Science candidate at Seattle University. She is interested in human factors in software engineering, [community smells](https://nars.cc/community-smells-in-software-engineering), and developer morale.

#### Contact
For any questions or concerns about this study please email tsuboin@seattleu.edu.

You can read my other articles at my website [https://nars.cc/](https://nars.cc/).
Spark on AWS Glue: Performance Tuning 5 ( Using Cache)
Tags: aws, glue, spark, performance
Published: 2023-07-16 21:56:10

This is a continuation of my previous posts as follows.


1. [Spark on AWS Glue: Performance Tuning 1 (CSV vs Parquet)](https://dev.to/tmyoda/spark-on-aws-glue-performance-tuning-1-csv-vs-parquet-2l5)

2. [Spark on AWS Glue: Performance Tuning 2 (Glue DynamicFrame vs Spark DataFrame)](https://dev.to/tmyoda/spark-on-aws-glue-performance-tuning-2-glue-dynamicframe-vs-spark-dataframe-12gb)

3. [Spark on AWS Glue: Performance Tuning 3 (Impact of Partition Quantity)](https://dev.to/tmyoda/spark-on-aws-glue-performance-tuning-3-impact-of-partition-quantity-4i55)

4. [Spark on AWS Glue: Performance Tuning 4 (Spark Join)](https://dev.to/tmyoda/spark-on-aws-glue-performance-tuning-4-spark-join-39m3)

5. [Spark on AWS Glue: Performance Tuning 5 (Using Cache)](https://dev.to/tmyoda/spark-on-aws-glue-performance-tuning-5-using-cache-4ob5)

## Using Cache
Spark RDDs are re-computed each time an action is performed on them. You can avoid this by using cache() or persist(), which keep the RDD in memory.

### Comparison between using cache and no cache
Please note that cache() and persist() are transformations, not actions, so they are evaluated lazily.

https://kb.databricks.com/scala/best-practice-cache-count-take#:~:text=Since%20cache()%20is%20a,RDD%20in%20a%20single%20action
> Since cache() is a transformation, the caching operation takes place only when a Spark action (for example, count(), show(), take(), or write()) is also used on the same DataFrame, Dataset, or RDD in a single action.

Let's try cache!

```python
with timer('before cache'):
    part_df.select("backend_port").distinct().count()

part_df.cache()
part_df.count() # execute cache (cache is a transformation)
with timer('after cache'):
    part_df.select("backend_port").distinct().count()
```

```
[before cache] done in 4.5241 s
[after cache] done in 1.6293 s
```

It's faster with cache()!

### Summary
- RDDs are re-computed for each action, so caching makes them faster
- Since cache() and persist() are transformations
Simple Code for Blockchain using python
Published: 2023-07-16 21:31:11

import hashlib

class Block:
    def __init__(self, data, previous_hash):
        self.data = data
        self.previous_hash = previous_hash
        self.hash = self.calculate_hash()

    def calculate_hash(self):
        hash_digest = hashlib.sha256()
        hash_digest.update(str(self.data).encode('utf-8'))
        hash_digest.update(str(self.previous_hash).encode('utf-8'))
        return hash_digest.hexdigest()

def create_genesis_block():
    return Block('Genesis block', '0')

def next_block(previous_block):
    return Block('Block 2', previous_block.hash)

genesis_block = create_genesis_block()
block_1 = next_block(genesis_block)
block_2 = next_block(block_1)

print(genesis_block.hash)
print(block_1.hash)
print(block_2.hash)