teleren/devto huggingface dataset:
3 good books for Data Sciences on AWS
Tags: datascience, machinelearning, aws, ai
Published: 2021-11-04 04:56:46

3 Good books for AWS Machine Learning:
1/ Data Science on AWS by Chris Fregly and Antje Barth
- https://www.amazon.com/Data-Science-AWS-End-End/dp/1492079391/ref=pd_bxgy_img_2/133-4753681-0316866

2/ Learn Amazon SageMaker by Julien SIMON
- https://www.amazon.com/Mastering-Machine-Learning-AWS-TensorFlow/dp/1789349796/ref=pd_bxgy_img_1/133-4753681-0316866

3/ Mastering Machine Learning on AWS by Dr. Saket Mengle and Maximo Gurmendez - https://www.amazon.com/Learn-Amazon-SageMaker-developers-scientists/dp/180020891X

(original post at https://www.linkedin.com/posts/walterwlee_amazonwebservices-awscommunity-awscommunitybuilders-activity-6858060120648224768-oZEx/ )
Run towards conflict
Tags: leadership
Published: 2021-11-09 01:59:25

---
title: Run towards conflict
published: true
date: 2021-11-04 04:56:11 UTC
tags: leadership
canonical_url: 
---

One behavior I keep running into with most newly-formed teams is the overwhelming desire to steer clear of any conflict. This is very apparent when the team is brainstorming different ways to work, setting up processes, or even worse: drafting a roadmap.

This is a problem, because your initial conversations set the stage for the pattern of your conversations in the longer term. If you can't find a way to handle disagreements when you're starting out, it's only going to get so much harder later on (a fear of conflict is also one of the signs of a [dysfunctional team](https://www.amazon.com/Five-Dysfunctions-Team-Leadership-Fable/dp/0787960756)).

If you're part of a new team, invest more time up front identifying your differences and how best to leverage them together, and less time reaching for consensus. It's worth it.
Perbedaan SSE dan WebSockets
Tags: sse, websockets
Published: 2021-11-04 04:50:06

SSE dan WebSockets termasuk ke dalam teknologi data push. Lantas, apa yang membedakan keduanya? dan teknologi mana yang lebih baik untuk digunakan?


# Perbedaan SSE dan WebSockets

- Server-Sent Events (SSE) adalah teknologi HTML5 yang akan membuat server melakukan push data ke client secara satu arah (one-way messaging).

- WebSockets adalah teknologi HTML5 yang akan membuat server melakukan push data dua arah antara client dan server (two-way communication).


# Kapan perlu menggunakan data push? WebSockets atau SSE? 

Berikut pertimbangan saat memilih teknologi data push yang akan diimplementasikan dalam aplikasi.

- Seberapa sering server mengirimkan event (data) ke client? 
  - Jika server sering mengirimkan data ke client, aplikasi tersebut cocok menggunakan teknologi data push dibandingkan data pull.

- Apakah latency dan baterai menjadi pertimbangan utama bagi user?
  - Latency dan baterai dapat menjadi pertimbangan utama bagi mobile user. Konektivitas jaringan sangat penting bagi tipe user ini. Oleh karena itu, data push lebih baik dibandingkan data pull.

- Seberapa sering client mengiriman event (data) ke server?
  - Jika event terjadi dalam frekuensi rapat (di bawah 5 detik, atau bahkan 1 detik sekali), aplikasi tersebut lebih baik menggunakan WebSockets dibandingkan SSE. 
  - Jika event terjadi dalam frekuensi lebih jarang (5-10 detik sekali), Anda dapat menggunakan SSE dan bahkan data push technology tidak perlu terlalu diprioritaskan.

- Apakah waktu pengiriman event dari server bisa diprediksi? 
  - Ketika event dikirim lebih dari 1 menit sekali, data pull lebih baik karena tidak perlu membuka socket untuk SSE/WebSockets. 

- Apakah server mengirimkan (push) binary data ke client?
  - Jika ada banyak binary data yang dikirimkan server, sebaiknya menggunakan WebSockets dibandingkan SSE (bahkan lebih baik menggunakan XHR polling dibandingkan SSE).
  - Jika data binary hanya sedikit, lakukan encoding pada SSE untuk mengurangi jumlah byte yang dikirimkan

- Apakah client mengirimkan (push) binary data ke server?
  - XMLHttpRequest (seperti: Ajax dan SSE) dan WebSockets bisa digunakan untuk mengirimkan binary data.

# Jadi, teknologi mana yang lebih baik?

Masing-masing teknologi memiliki keunggulan yang berbeda, tergantung dari kebutuhan aplikasi yang dikembangkan. 

- Aplikasi yang membutuhkan komunikasi 2 arah antara client dan server
  - harus menggunakan WebSockets
  - tidak cocok menggunaakn SSE
  - Contoh: chat platform

- Aplikasi yang hanya mengirimkan data 1 arah ke client
  - sangat cocok menggunakan SSE
  - tidak cocok menggunakan WebSockets
  - Contoh: FX trading

# Selanjutnya

Post selanjutnya akan membahas cara implementasi SSE. Implementasi backend akan menggunakan bahasa pemrograman Golang. Implementasi dari sisi frontend akan menggunakan teknologi ReactJS.

# Referensi

Cook, D. (2014). _Data Push Apps with HTML5 SSE: Pragmatic Solutions for Real-World Clients_ (1st ed.) [E-book]. O’Reilly Media.
Test Driven Development - Explained
Tags: beginners, testing, dotnet
Published: 2021-11-04 04:45:29

Test Driven Development (TDD) in layman's language is a way of testing a piece of code before writing the actual code.

The first time I saw this explained, I was confused. It was completely abstract to me - How or why would I test a code I have not written? I think I felt this way because most of the research I did concerning this topic was always about adding two numbers or did not use [near] real examples, so I'm going to use my story to explain this term in this article.

I used to work in a company that writes API for financial companies, so I was given a task - display all active customers that have more than $400 in their account.
Easy task! I wrote the code: 
```
var activeCustomersWith400 = Customers.Where(cus => cus.IsActive && cus.Balance > 400)
 
//pardon my C# and LINQ 😏
```
Yes, that's correct, then I wrote the test for it after manually testing/making sure my code works - by debugging. That is not TDD approach.

TDD approach is:
- Creating test methods (or a class with methods) specifically for that task to:
   - test that the customers returned are active
   - test that they have $400 in their account
   - any other test you want, making sure they go along with the requirements of the task.
- Running the tests. They will obviously fail, or your IDE or compiler complains about errors, since you do not have the function that does the task in your actual code yet.
- Fix the errors by writing the function, then run the test again. Keep running the tests and making changes to your function until all the tests pass.

In conclusion, TDD approach is better than just jumping in the code because:
- It defeats the need for debugging. This is because you already laid down how you want your code to behave in the tests, you just write code to follow that behavior. This is the strong point of TDD.
- It makes you think about small chunks of code at a time. This is required in functional programming.
- It improves productivity because developers have to focus on _that_ part of code they are working on.
- You do not need manual testing to know your code works.
- One important advantage of TDD to me is how it helps in Behavior driven development (BDD).

Some people argue that TDD wastes time, maybe they are right, but to me, the advantages listed above outweigh this argument and I can say for a fact that it does not waste time, especially when you have your test setup ready from onset.

Thank you for reading.
Automating different websites with both chrome and Firefox
Published: 2021-11-04 04:29:42

“from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By
from selenium.webdriver.firefox.options import Options
from time import sleep

class Bot:
    def __init__(self, browser, url, search):
        self.browser = browser
        self.url = url
        self.search = search

        if self.browser == 'Chrome':
            self.driver = webdriver.Chrome(r'C:\chromedriver.exe')
        elif self.browser == 'Firefox':
            options = Options()
            options.binary_location = r'C:\Program Files\Mozilla Firefox\firefox.exe'
            self.driver = webdriver.Firefox(options=options, executable_path=r'C:\geckodriver.exe')

    def open_browser(self):
        if self.browser == 'Chrome':
            self.driver.get(self.url)
        elif self.browser == 'Firefox':
            self.driver.get(self.url)
        else:
            print('Browser not found')
    
    def search_string(self):
        if 'geeksforgeeks' in self.url:
            
            self.driver.find_element(By.CSS_SELECTOR, '.gfg-icon_search').click()
            search_field = self.driver.find_element(By.ID, 'gcse-search-input')
            search_field.send_keys(self.search)
            search_field.send_keys(Keys.RETURN)
            sleep(5)
        elif 'amazon' in self.url:
            search_field = self.driver.find_element(By.ID, 'twotabsearchtextbox')
            search_field.send_keys(self.search)
            search_field.send_keys(Keys.RETURN)
            sleep(5)
        else:
            print('Search string not found')

    def close_browser(self):
        if self.browser == 'Chrome':
            self.driver.close()
        elif self.browser == 'Firefox':
            self.driver.close()
        else:
            print('Browser not found')


class AmazonShopping(Bot):
    def __init__(self, browser, url, search, item_to_add):
        super().__init__(browser, url, search)
        self.item_to_add = item_to_add

    def open_browser(self):
        super().open_browser()
        self.product_name = ""
        self.rent = ""
        self.products = ""
        self.items = []
    
    def click_product(self):
        self.products = self.driver.find_elements(By.CLASS_NAME, 's-image')
        for prod in self.products:
            self.items.append(prod.get_attribute('alt'))
        
        for item in self.items:
            self.driver.implicitly_wait(10)
            if self.item_to_add in item:
                self.driver.find_element(By.LINK_TEXT, item).click()
                sleep(10)
            else:
           
                pass

    def add_to_cart(self):
        self.driver.find_element(By.CSS_SELECTOR, '#submit\.add-to-cart').click()
        sleep(10)”
Prevent accidental package installation to system Python.
Tags: python
Published: 2021-11-04 04:07:14

Ever happened to you, that one day you decided to start afresh Python project, and started to install all the packages, like pandas, NumPy,  jupyter notebook, and then you realized that you've installed all of them in the system python rather than in a virtual environment. Yeah, you are not alone buddy.

Well, worry no more. Introducing [`pip-venv-sure`](https://github.com/Adwaith-Rajesh/pip-venv-sure). (I don't know what I was thinking when I named it.)

## Installation and Setup

```commandline
pip3 insall pip-venv-sure
alias pip3=pip3-venv-sure
```

> Recommended to place the alias command in your `.bashrc`.

Now if you try to install a package without an activated venv this happens.

![Screenshot from 2021-11-04 09-02-36.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1635996777406/3csR-Dbvx.png)

But if you have an activated venv it works as normal.

![Screenshot from 2021-11-04 09-05-50.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1635996976006/Zf-5Xhoxl.png)

But, there are times when you've to install packages to the system Python in that case you can prevent [`pip-venv-sure`](https://github.com/Adwaith-Rajesh/pip-venv-sure) from checking for a venv using the `--allow-no-venv` flag.

```commandline
pip3 install any-template --allow-no-venv
```

![Screenshot from 2021-11-04 09-10-23.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1635997242595/v_dwS4hPo.png)

## Some other alternatives.

If you don't like to install the said package, there is a way around it.

You can set an environment variable like this
```commandline
export PIP_REQUIRE_VIRTUALENV=true
```
The problem with it Is you've to unset or set this to `false` when you want to install packages globally.

Well, that's all for today, and Thanks for reading.
Spreading the pods across multiple zones
Published: 2021-11-04 03:18:11

To achieve high availability and better utilization of resources, it is required to spread the pods across multiple failure domains / availability zones. You can use OpenShift’s *topologySpreadConstraint* feature to achieve this.

Here I will explain how to achieve this by labeling the nodes and defining the topology spread constraint for the pods.

#### 1. Label the nodes as per the zones they are located in
```
oc label node worker0 zone=az0
oc label node worker1 zone=az1
oc label node worker2 zone=az1
oc label node worker3 zone=az2
oc label node worker4 zone=az2
```
#### 2. Define the topology spread constraint in deployment yaml 
```
apiVersion: apps/v1
kind: Deployment
metadata:
spec:
  …
  template:
    metadata:
    …
    spec:
      containers:
      …
      topologySpreadConstraints:
        - maxSkew: 1
          topologyKey: zone
          whenUnsatisfiable: ScheduleAnyway
          labelSelector:
            matchLabels:
              app: app1
…
```
where,
**maxSkew:** This defines the maximum difference in number of pods between any two zones. It is used to control how strict the pod distribution should be.
**topologyKey:** The label used to define the zone value for nodes. In our example, it is *zone*. 
**whenUnsatisfiable:** How to handle a pod if it does not satisfy the spread constraint.
**labelSelector:** Pods to select for the distribution based on the labels associated with the pods. In this example, the pods are created with label app: app1 using `spec.template.metadata.labels` tag in the same deployment yaml as shown below.
```
apiVersion: apps/v1
kind: Deployment
metadata:
spec:
…
  template:
    metadata:
      …
      labels:
        app: app1
```


After making these changes, the pods will be evenly distributed across the zones. The worker node selection within the zone will be done based on the capacity available on those worker nodes. So it is quite possible that one worker node will have more pods than other worker node within the same zone.

In the below picture, we can see how the 5 pods are distributed to 3 availability zones.
- **Pod0** is assigned to **az0** which contains only one worker node **worker0**.
- **Pod1** and **Pod2** are assigned to **az1** which contains two worker nodes **worker1** and **worker2**. Both the pods are assigned to **worker1** as per the resource requirement and capacity available.
- **Pod3** and **Pod4** are assigned to **az2** which contains two worker nodes **worker3** and **worker4**. Both the pods are assigned to **worker4** as per the resource requirement and capacity available.
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3by66q2lw0osvkpk3cpm.png)
Awesome Dialog with Jetpack Compose
Tags: jetpackcompose, howto, android, mobile
Published: 2021-11-04 02:57:58

**Jetpack Compose** is a new toolkit for creating UI on native android. With jetpack compose building a display becomes easier and more intuitive. When this article was written, jetpack compose had reached version `1.1.0-beta01`

Alright, let's go straight to the Awesome Dialog discussion. This is a third party library for jetpack compose, this library displays beautiful dialogues unlike ordinary dialogue material.

Actually you can create a display of dialogue like this, but it takes a long time to recreate. For that you only need to add this library to your jetpack cm=compose project and then you use it (plug & play)

## 🎉 Requirement
There are requirements that you must meet in order to use this library:
1. Jetpack Compose version `1.0.3`
2. Android Gradle Plugin version `7.0.2`
3. Kotlin version `1.5.30`

## 📦️ Install library
To install this library, in the `build.gradle` file add the **jitpack** repository
```groovy
repositories {
    maven { url 'https://jitpack.io' }
}
```
After that in app/build.gradle add the library with the latest version
```groovy
dependencies {
     implementation 'com.github.farhanroy:compose-awesome-dialog:1.0.1'
}
```
After that until the build process is complete 👍
## ✏️ How to use ?

How to use it, just call the composable function. The way to display the dialogue is almost the same as displaying the dialog as usual.

```kotlin
val openDialog = remember { mutableStateOf(false)  }

Button(onClick = { openDialog.value = true }) {
       Text(text = "Open")
}

if (openDialog.value) {
     ComposeAwesomeDialog(
        type = ComposeAwesomeDialogType.Success,
        title = "Success",
        desc = "This is success dialog",
        onDismiss = { openDialog.value = false }
     )
}
```


## ✅ Run
<div style="width:100%;height:0;padding-bottom:205%;position:relative;">
<img src="https://media.giphy.com/media/6QvnmIcnr9BU75fZIf/giphy.gif"/>
</div>

## Reference
- https://github.com/farhanroy/compose-awesome-dialog
How to create a Diameter lab via Docker
Tags: docker, diameter
Published: 2021-11-03 17:05:46

winpty docker run -it debian:stable bash

apt update
apt -y upgrade
apt install -y wget gnupg gnupg1 gnupg2 nano
wget http://www.freediameter.net/packages/repository.key
apt-key add repository.key

nano /etc/apt/sources.list

deb http://www.freediameter.net/packages/debian sid contrib
deb-src http://www.freediameter.net/packages/debian sid contrib

apt update
apt upgrade
apt install freediameter

Se lo faccio partire direttamente, da errore:

root@77312d941f34:/# freeDiameterd
16:35:27  NOTI   libfdproto '1.2.1' initialized.
16:35:27  NOTI   libgnutls '3.7.1' initialized.
16:35:27  NOTI   libfdcore '1.2.1' initialized.
16:35:27  FATAL! Missing private key configuration for TLS. Please provide the TLS_cred configuration directive.
16:35:27  ERROR  ERROR: in '((fd_conf_parse()))' :      Invalid argument
16:35:27  ERROR  ERROR: in '(fd_core_parseconf(conffile))' :    Invalid argument
16:35:27  FATAL! Initiating freeDiameter shutdown sequence (1)
16:35:27  NOTI   freeDiameterd framework is stopping...
16:35:27  NOTI   Shutting down server sockets...
16:35:27  NOTI   Sending terminate signal to all peer connections

Devo allora creare i certificati.

root@77312d941f34:/# cat /etc/freeDiameter/freeDiameter.conf

# -------- Test configuration ---------
Identity = "peer1.localdomain";
Realm = "localdomain";
# Port = 3868;
# SecPort = 3869;
#TLS_Cred = "peer1.cert.pem",
#           "peer1.key.pem";
#TLS_CA = "cacert.pem";
#
LoadExtension = "extensions/test_app.fdx" : "test_app1.conf";
#
#ConnectPeer = "peer2.localdomain" { ConnectTo = "127.0.0.1"; No_TLS; port = 30868; };
#
Java Tip: What are Methods, Functions, and Procedures?
Tags: java, codenewbie, tutorial, 100daysofcode
Published: 2021-11-04 02:43:16

---
title: Java Tip: What are Methods, Functions, and Procedures?
published: true
description: Java Tip: What are Methods, Functions, and Procedures?
tags: Java, codenewbie, tutorial, 100daysofcode
//cover_image: https://direct_url_to_image.jpg
---

Methods 🦁, Functions 🐯, and Procedures 🐻, Oh My!

Programmers often use these terms interchangeably. But there are differences among them. The following paragraphs describe methods, functions, and procedures in Java.

## Methods

A **method** in Java is a subroutine that is part of a *class*. The subroutine is like a miniature program that can execute in other parts of the program. Methods promote code reuse and maintainability.

A *method definition* consists of the modifier, return type, name, parameter list, exception list, and body. The method name and parameter types form the *method signature*. The method signature uniquely identifies the method for execution.

>Note: Java also has *constructor methods*. A constructor is a special method that creates an object of a class.

There are two types of methods: *procedures* and *functions*.

## Procedures

A **procedure** is a method that does *not* have a return value. To define a method to be a procedure, define the return type to be `void`. An example of a built-in procedure in Java is `System.out.println()`. This procedure simply outputs its parameter to the console, without returning a value.

## Functions

A **function** is a method that *does* have a return value. To define a method to be a function, set its return type to be the type of the value it is returning. An example of a built-in function in Java is `Math.pow()`. This `Math` function accepts two `double` parameters and returns the first parameter raised to the power of the second parameter. The return type is `double`.

Finally, *user-defined* methods are procedures and functions that **you** define. Since Java only provides general-purpose methods, it is up to you to define methods that make sense for your programming project.

If you liked this article _proceed_ to my Twitter profile [`@realEdwinTorres`](https://twitter.com/realEdwinTorres) and follow me! 😊
flutter 优秀dio网络拦截可视化
Published: 2021-11-04 02:40:10

## flutter_interceptor
## flutter dio 拦截器

库源码：https://github.com/smartbackme/flutter_interceptor

### 开始集成

```bash
dependencies:
  flutter_interceptor: ^0.0.1
```

dio添加拦截器

```bash
_dio.interceptors.add(UiNetInterceptor())
```

页面插入浮动窗体

```bash
Overlay.of(context)?.insert(InterceptorDraggable());
```

功能介绍：
1、请求可视化
2、可以复制请求内容

集成后的效果如图
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ud7bnqvaoy8mihtvhenw.jpg)![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lvmelzr4m9848ck5mq0e.jpg)![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/im6b68ywlaayk2wbgbwt.jpg)![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xkcjf645nppro4la09df.jpg)![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1yptm9vdf3pz0a3n6r08.jpg)