teleren/devto huggingface dataset:
FREE Google Courses 2023.
Tags: googlecloud, analytics, datascience, python
Published: 2022-12-29 12:41:39

## FREE (Google) Courses you will regret not taking in 2023.


**[1] Google Analytics for Beginners**

🔗https://lnkd.in/deSN6Bsb

**[2] Advanced Google Analytics**

🔗https://lnkd.in/dA7dhdwi

**[3] Google Analytics for Power Users**

🔗https://lnkd.in/da42MiC5

**[4] Fundamentals of digital marketing**

🔗https://lnkd.in/dE7FFs6m

**[5] Get started with Google Maps Platform**

🔗https://lnkd.in/dX2aRzs9

**[6] Google Cloud Computing Foundations:**

🔗https://lnkd.in/dYW5FF_B

**[7] Google Cloud Computing Foundations:**

🔗https://lnkd.in/d_7VWMqv

**[8] Google Cloud Computing Foundations: Data, ML, and AI in Google Cloud**

🔗https://lnkd.in/dYJzj9R2

**[9] Google Cloud Computing Foundations: Networking and Security in Google Cloud**

🔗https://lnkd.in/dYuHD_3S

**[10] Machine Learning Crash Course**

🔗https://lnkd.in/dmZinF4p

**[11] Basics of Machine Learning**

🔗https://lnkd.in/dNTMQPM9

**[12] Data Science with Python**

https://lnkd.in/dkr4KGHD

**[13] Python Basics for Data Analysis**

🔗https://lnkd.in/dRunXPtA

**[14] Data Science Foundations**

🔗https://lnkd.in/d5Dz7q8Y

Happy Learning.💥

CREDIT: [ARIF ASLAM](https://www.linkedin.com/in/iamarifalam/)
Dynamically Change the Content-Disposition of an S3 Object URL
Tags: aws, devops, cloud, webdev
Published: 2022-12-29 12:10:29

The **_Content-Disposition_** response header of an S3 object can be changed dynamically by modifying the header value in the HTTP response that is returned when the object's URL is accessed.

One way to do this is to use an AWS Lambda function to intercept the request for the object's URL and modify the **_Content-Disposition_** response header before returning the response to the browser. This allows you to change the **_Content-Disposition_** value dynamically based on the request or other  conditions.

Here's an example of a Lambda function that changes the **_Content-Disposition_** value based on the value of a query parameter in the request URL:

```
exports.handler = async (event) => {
  // Get the object key and bucket from the event
  const key = decodeURIComponent(event.Records[0].s3.object.key.replace(/\+/g, ' '));
  const bucket = event.Records[0].s3.bucket.name;

  // Get the request query parameters
  const params = event.Records[0].cf.request.querystring;

  // Set the Content-Disposition value based on the "download" query parameter
  let contentDisposition;
  if (params.includes('download=1')) {
    contentDisposition = 'attachment';
  } else {
    contentDisposition = 'inline';
  }

  // Get the object from S3
  const s3 = new AWS.S3();
  const s3Object = await s3.getObject({
    Bucket: bucket,
    Key: key
  }).promise();

  // Create the response
  const response = {
    status: '200',
    statusDescription: 'OK',
    headers: {
      'Content-Type': [{
        key: 'Content-Type',
        value: s3Object.ContentType
      }],
      'Content-Disposition': [{
        key: 'Content-Disposition',
        value: contentDisposition
      }]
    },
    body: s3Object.Body
  };

  // Return the response
  return response;
};

```

To use this Lambda function, you would need to set up an Amazon CloudFront distribution that points to your S3 bucket and associates the Lambda function with the distribution as an origin request trigger. Then, you can access the object's URL through the CloudFront distribution and use the **_download_** query parameter to control whether the object is rendered in the browser window or downloaded.

For example, the following URL would cause the object to be downloaded:

```
https://my-cloudfront-distribution.com/path/to/object.ext?download=1
```

And the following URL would cause the object to be rendered in the browser window:

```
https://my-cloudfront-distribution.com/path/to/object.ext
```

With this setup, you can easily switch between rendering the object in the browser window and forcing a download without having to manually change the **_Content-Disposition_** value.
API Gateway é importante?
Published: 2022-12-29 12:08:22

---
title: API Gateway é importante?
published: true
description: 
tags: 
cover_image: https://dev-to-uploads.s3.amazonaws.com/uploads/articles/g7bg7zvjc1ef2ol50j9g.png
# Use a ratio of 100:42 for best results.
# published_at: 2022-12-27 12:37 +0000
---

Um API Gateway é uma camada de software que age como um intermediário entre um cliente e um conjunto de APIs ou microserviços. Ele é usado para gerenciar solicitações de API de maneira consistente e escalável, permitindo que os desenvolvedores criem e gerenciem APIs de maneira mais eficiente.

Há várias razões pelas quais é importante usar um API Gateway em uma arquitetura de aplicativo:

1.Gerenciamento de solicitações de API: Um API Gateway pode ajudar a gerenciar solicitações de API de maneira mais eficiente, incluindo o roteamento de solicitações para o back-end adequado, o cache de respostas e a autenticação de usuários.

2.Segurança: Um API Gateway pode fornecer uma camada adicional de segurança para suas APIs, incluindo autenticação de usuários, verificação de autorização e criptografia de dados.

3.Escalabilidade: Um API Gateway pode ajudar a gerenciar o tráfego de API de maneira mais eficiente, permitindo que você escalone o back-end de acordo com as necessidades. Isso pode ser especialmente útil em cenários de alta carga ou em aplicativos com muitas APIs.

4.Monitoramento: Um API Gateway pode fornecer métricas e dados de monitoramento para ajudar a identificar problemas e otimizar o desempenho das APIs.

Em resumo, usar um API Gateway pode ajudar a gerenciar solicitações de API de maneira mais eficiente, fornecer uma camada adicional de segurança, permitir a escalabilidade de acordo com as necessidades e fornecer métricas de monitoramento para ajudar a identificar problemas e otimizar o desempenho. Isso pode ser especialmente útil em aplicativos com muitas APIs ou em cenários de alta carga.
TIL - Implementing Encoder for NifStructs
Tags: rustler, elixir, rust, todayilearned
Published: 2022-12-29 12:07:50

---
published: true
tags:
  - rustler
  - elixir
  - rust
  - til
title: TIL - Implementing Encoder for NifStructs
---

I am currently using Rustler, a tool that allows for Elixir to interact with the Rust ecosystem. As a newcomer to Rust, working on Rust-Elixir crossover libraries helps me understand its quirks.


Today, I was trying to use a SQL parser in Rust and convert the results to Elixir terms. Rustler's NifStructs feature made this process convenient. However, I encountered an issue with a data structure defined as follows:

```
#[derive(NifStruct)]
#[module = "SqlParser.Select"]
pub struct Select {
    pub selection: Option<Expr>
}
```

The issue arose when I encountered this enum:

```
pub enum Expr {
    BinaryOp {
        left: Box<Expr>,
        op: BinaryOperator,
        right: Box<Expr>,
    }
}
```
Because of the `Box<Expr>`, this becomes a recursive data structure. To encode this with Rustler, I needed to implement the `Encoder` trait for `Box<Expr>`.

```
impl Encoder for Box<Expr> {
    fn encode<'a>(&self, env: Env<'a>) -> Term<'a>  {
        let data =&** self;
        data.encode(env)
    }
}
```

However, this caused a chain reaction. The `Select` struct above has a `Decoder` trait implemented for it, and it expects `Expr` to also implement that trait to decode. At first, I implemented the `Decoder` trait for `Expr`, but since I only need to use the parser one-way (from SQL through Rust to Elixir) and not vice-versa, this was not necessary.

I had to do a bit of digging but found that I could use:

```
#[derive(NifStruct)]
#[rustler(encode)]
#[module = "SqlParser.Select"]
```
and the `Select` struct would never implement the `Decoder` trait, resulting in that the `Expr` also did not need to implement it. 

So annotate the code with `#[rustler(encode)]` or `#[rustler(decode)]` if you only need one-way
encoding/decoding in Rustler.
Weird Phishing attempt on GitHub
Tags: github, security, phishing, discuss
Published: 2022-12-29 11:52:45

This morning I was awaken to a strange notification on my phone, I got tagged in a comment on GitHub. Since I have the [GitHub app](https://play.google.com/store/apps/details?id=com.github.android&hl=en&gl=US&pli=1) on my phone, I get push notifications of such things...

When I opened it up - reminder this was shortly after getting out of bed, before I even had my first coffee and it was on a mobile client, so I didn't have much context, just wanted to check my notifications - I got the weirdest comment I've ever seen on GitHub.

> Hi wanna see my nude photo **[shortened link]**
> bunch of other tagged users
> More photo goo **[shortened link]**


![Screenshot of phishing attack on GitHub](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mz9v38amrydb822ubxfv.png)

Now even in such an early hour this tripped off my defenses as an obvious phishing attempt. So I decided that instead of watching some *"nude photos"*, I'll click the "Report Abuse" option and direct the attention of GitHub's security team towards this comment.

GitHub responded quickly:

> Our review of the account(s) and/or content named in your report has concluded. We have determined that one or more violations of GitHub’s Terms of Service have occurred and have taken appropriate action in response.

The strangest thing is that I'm not even a follower of this [repo](https://github.com/satijalab/seurat) where the discussion was started, which by the way is a *R toolkit for single cell genomics*.

The phishing (or malware spreading or whatever shady business) is pretty obvious here, but I could imagine that this could be tunned up to be a bit more personalized for targeted individuals.

Has anyone encountered this or similar malicious use of GitHub's community features? Maybe does someone know what's the background of the scam?
How to connect an external database to Kubernetes for a flask deployment.
Tags: kubernetes, webdev, beginners, devops
Published: 2022-12-29 11:32:08


## The Problem.
I created a database on digital ocean and because I do not want to create a Kubernetes postgress database with persistent volumes and claims. I must connect to this External Service.

#### Digital ocean gave me this connection string for my `SQLALCHEMY_URI`

`postgresql://user:password@hostname:25061/databasename?sslmode=require`

It works with docker-compose and non docker flask run.

For Kubernetes though it complains that it cannot resolve the hostname.

We will rename the `hostname `to `digitaloceanpostgress`. It can be anything. It must match the `
service.yml` further down though.

So our deployment will look something like this. This is mine, yours could be different.

```
apiVersion: apps/v1 #  for k8s versions before 1.9.0 use apps/v1beta2  and before 1.8.0 use extensions/v1beta1
kind: Deployment
metadata:
  name: backend-deployment
  labels:
    app: backend-deployment
spec:
  replicas: 1
  selector:
    matchLabels:
      app: backend-deployment
  template:
    metadata:
      labels:
        app: backend-deployment
    spec:
      containers:
      - name: backend-deployment
        image: username/yourflaskserveretc:latest
        imagePullPolicy: Always
        ports:
        - containerPort: 8080
        env:
        - name: SQLALCHEMY_DATABASE_URI
        # Set this as a secret.
          value: "postgresql://user:password@digitaloceanpostgress:25061/databasename?sslmode=require"
```

### Setting up the service.

Type in your terminal `$ nslookup hostname (something.com)` and paste the ip in the `service.yml` bellow.

```
kind: Service
apiVersion: v1
metadata:
  name: digitaloceanpostgress
spec:
  clusterIP: None
  ports:
  - port: 25061
---
kind: Endpoints
apiVersion: v1
metadata:
  name: digitaloceanpostgress
subsets:
  - addresses:
  # nslookup hostname given by digitalocean database.
      - ip: ip-from-nslookup
    ports:
      - port: 25061
        name: digitaloceanpostgress
```

### Finito.

Disclaimer. Although this works for me it might not be the goto solution for a pro. I am still a newbie.

#### References.
- https://www.googblogs.com/kubernetes-best-practices-mapping-external-services/
- https://stackoverflow.com/questions/63344920/access-external-database-from-kubernetes
What you need to know about the web3 Browser: It's Brave!
Tags: web3, browser, crypto, review
Published: 2022-12-29 11:25:39

Brave Browser enables users to access decentralized applications, use cryptocurrencies, and navigate the decentralized web with increased privacy and security. That's why It's called the web3 browser.

For years, I saw the brave browser in different places but never paid attention to it. I felt it was just like other browsers trying to compete with Lord Chrome.

![Brave Wallet](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/waleet31fw8t84btrz5v.jpg)

But a few months ago, Brave browser’s built-in crypto wallet caught my interest and I downloaded it. Then I found out that it is open source (and not just any, it was forked from Chromium). After I used it for the first time, I saw how good it was at blocking annoying ads: Damn! I was impressed.

---

## Reasons to Choose the Brave Browser:
|

- 🪙 It has a **Crypto Wallet** built into the browser
- 🤗 It is [Open Source](https://github.com/brave) (forked from Chromium)
- 🚫 It **blocks online Ads** (Including YouTube Ads)

![Brave ads blocker illustration](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kzrpd7389ty1hoail0vr.png)

- 🛡️ It **protects privacy** by blocking website trackers by default
- 🥷 It has a built-in **TOR mode** (Anonymized network routing) which allows you to explore the dark web.
- 📥 It also has an in-built **torrent downloader** (powered by [WebTorrent](https://webtorrent.io/))
- 💰 It allows you to **earn crypto tokens (BAT)** by viewing their own ads (optional)
- 🍪 It **blocks third-party cookies** and can even block cookie consent notices, too.
- ⚡  It is **better than chrome** with this: 3x faster. 1 hour more of battery life. 33% less memory usage

---

{% embed https://vimeo.com/533695950 %}

---

## To get started
Take a Brave step just like I did and [download the browser.](https://brave.com/download/) 

After installation, you can easily jump ship in 60 seconds (from your previous browser): by importing your bookmarks, settings, extensions, and even saved passwords to the Brave Browser.

---
Be Brave & Like this Post ❤️🦁
Need help reg httpHeaderSecurityFilter
Published: 2022-12-29 11:16:56

Hello all , i am facing below issue for months nd months i could not found any forum or post related this , please help me , i have posted same in stackoverflow but no response yet 
please find attached post [link](https://stackoverflow.com/questions/74939662/configuring-forward-dispatcher-for-tomcats-httpheadersecurityfilter-throws-exce)
Preparation tips for live-coding interviews
Tags: interview
Published: 2022-12-29 11:03:18

---
title: Preparation tips for live-coding interviews
date: 2022-12-29 11:03:00 UTC
published: true
tags: ['interview']
canonical_url: https://sevic.dev/notes/live-coding-interviews/
---

Live coding is usually part of a technical interview where a candidate gets a task and demonstrates the coding solution in front of interviewers. As a candidate and interviewer, I have experience with both sides, so this post covers an opinionated list of tips.

### Communication

Good written and verbal skills in the English language are essential so candidates can understand the task, explain the solution and ask understandable questions.

### Technical preparation

Include pair programming sessions in your daily workflow so you feel comfortable when someone looks into your screen while you're coding. Include `git` in your daily workflow since some of the challenge requirements could be to clone a specific repository and start working on it instead of writing the solution from scratch.

Prepare yourself with data structures fundamentals knowing when you should use them, for example, why and when it's better to use a hash map instead of a two-dimensional array. Prepare yourself with the most used built-in methods for strings and arrays for the programming language you use during the interview.

If your current job role consists of more management duties, take some time to practice the syntax of the chosen programming language.

### During the interview

Use the programming language you're most comfortable with if requirements are not strictly coupled to one programming language. Share your thoughts while you're coding so the interviewers can feel your way of thinking and problem-solving. Also, ask questions when something needs to be clarified for you.

Try not to write pieces of code you don't fully understand, for example, using IIFE and not knowing how to pass an argument into it, using `;` in front of it, and not knowing why it's used. Try to write readable code with [understandable variable and function names](https://github.com/kettanaito/naming-cheatsheet).

Avoid writing too nested statements, so it's not easy to understand the code's flow. Try to write code that is easy to cover with the tests.
Psychological Safety
Tags: psychologicalsafety, teambuilding, storybytes, workcultre
Published: 2022-12-29 10:59:24


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tiontz77v32f2p0ups01.png)A team’s success is a recipe that has to be enjoyed once the dish is served. But what is that recipe? What are the ingredients? How about the quantity and the preparation time? Well, if that were easy, we would have only high-performing teams. One ingredient that we in Web and App Studio believe in to create a high-performing team is the need for Psychological Safety. Paul Santagata from HBR reveals, “There’s no team without trust”, and he couldn’t be more correct. But what is psychological safety, and why is it important? Psychological safety is the conviction that you won't suffer the consequences of the mistakes that have occurred. If we get to our unsafe zone, our thinking brains shut off, and our primal instincts take over, leading to nothing productive. And that's why psychological safety is so important. Psychological safety empowers employees to take risks and speak their minds. Team members who are quick to point the finger at one another when something goes wrong, team members who have different values or beliefs than others, and teams with a conflict-ridden culture are all signs of poor psychological safety. So rather than developing a compete-with-each-other mindset, we must never forget that it’s the team vs the problem. Blame can become a curiosity. Ask for feedback to improve on your own. When people feel connected to each other, they know that they're safe to step outside of their comfort zone. And yes, Feeling safe is a fundamental human need. Once this is covered, any performance will scale higher
NGRX: Notify after action has been dispatched
Tags: angular, ngrx, redux, webdev
Published: 2022-12-29 10:43:42

While working with ngrx, sometimes we need to be notified after an action has been dispatched successfully in order to perform some kind of action (e.g: open or close a modal from a component). 

One of the solution would be creating a `Subject` in the facade class and emit a value in the effect after the success action has been dispatched:

```ts
export class UserFacade {
  readonly userAdded$: Subject<boolean> = new Subject<boolean>();

  constructor(private readonly store: Store) {}

  addUser(user: UserPayload): void {
    this.store.dispatch(addUser({ user }));
  }
}
```
Our effect would look like this:
```ts
@Injectable()
export class UserEffects {
  addUser$ = createEffect(() =>
    this.actions$.pipe(
      ofType(addUser),
      switchMap(({ payload }) =>
        this.userDataService.addUser(payload).pipe(
          map(() => addUserSucceeded()),
          tap(() => this.userFacade.userAdded$.next(true)),
          catchError((error) => of(addUserFailed(error)))
        )
      )
    )
  );

  constructor(
    private readonly actions$: Actions,
    private readonly userFacade: UserFacade,
    private readonly userDataService: UserDataService
  ) {}
}
``` 
This solution is almost ideal. We don't need to directly subscribe to the effect and we can expose the information if action has been dispatched using facade pattern. On other hand, we have to create a `Subject` in the facade and control it in the effect. Instead, we can utilize an injectable service that provides an observable stream of all actions and listen on the success action:
```ts
export class UserFacade {
  readonly userAdded$: Observable<boolean> = this.actions$.pipe(
    ofType(addUserSucceeded),
    mapTo(true)
  );
}
```
With this solution, we don't have to create additional class member and emit anything in the effect. Now, we can use it in our component:
```ts
@UntilDestroy()
@Component({ ... })
export class UserComponent {
  constructor(
    private readonly userFacade: UserFacade,
    private readonly matDialogRef: MatDialogRef<UserComponent>
  ) {}

  confirmClicked(): void {
    this.userFacade.addUser({ ... })

    this.userFacade.userAdded$
      .pipe(
        filter((added) => added),
        take(1),
        untilDestroyed(this)
      )
      .subscribe(() => this.matDialogRef.close());
  }
}
```
If you have any questions, feel free to ask them in the comments!
Should I create a classification or regression model?
Tags: ai, machinelearning
Published: 2022-12-29 10:43:38

In many cases it's quite obvious that we have a classification or regression task and it's impossible to make such a mistake when you pick your model design. However, in some cases it's not so obvious, as the target variable can be a mix of regression and classification target variables. For example, our target variable can be equal to zero in vast majority of cases and varies a lot in all other cases. This is a very common situation in financial tasks, when we have to predict the default of the customer and potential damage depends from this customer's exposure, or when we try to identify fraud transactions and losses depend from the size of the transaction. In these cases, it can be quite difficult to pick a particular model design, so let's try to simulate this situation and investigate different approaches.


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

Also, let's introduce one more variable: _amount_=10^(Normal distributed variable), this variable will show potential loss connected with every case when y > th. Let's imagine that in our case p = 0.99, and alpha = 0.5, so we have any losses only in 1% of cases and Gini coefficient of our model in about 50%. Let's imagine also that our threshold on the same level as p, so we can reject only 1% of cases and have to accept 99%. The main target metric for us is recall, the percent of all losses rejected by our model, when we can reject only 1% of cases.

Let's consider 4 different options here:

1. We can create a classification model not directly connected with money, range our cases and reject 1% of cases with highest probability of loss. (In our particular case we will use x as a score.)
2. We can transform x to probability by normal cdf, and multiply this probability by money. It will be our expected loss and we can reject 1% of cases with highest expected loss.
3. We can create a ridge regression model based on our x and amount and reject 1% of cases with highest ridge predictions.
4. We can create a ridge regression model based on our x and log(amount) and reject 1% of cases with highest ridge predictions.

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

All in all, we can see that classification task multiplied by amount of money gave the best result here (recall = 58%), on the second place is regression on amount and x (recall = 52%), on the third place is regression on log(amount) and x (recall = 51%) and on the last place is naive classification model (recall = 12%). So, the best solution in such kind of tasks is to create a classification model with final multiplication by money or a simple regression model.