teleren/devto huggingface dataset:
Should I send notifications on Slack only when tests fail or always?
Tags: testing, slack, cicd, automation
Published: 2021-06-10 16:43:52

Some people think that notifications that everything went well generate unnecessary “noise” in the communication.

On the other hand, some people see it as, "Let's celebrate the small victories!" 🎉

I invite you to look at this topic from another perspective, based on personal experiences in different real-world projects.

Have you ever found yourself in a situation where there were more failure notifications than passing tests?

Or, have you ever been “lucky” to work on a project where red pipelines were an exception?

I've lived both situations.

In the one where tests failed often, I had the following impressions. 1. It seemed that the application being developed was always broken (that people didn't care about quality); 2. it “smelled” of non-deterministic, and therefore unreliable, automated tests; and 3. triaging failures was “hell in earth” (unexpected instabilities often caused failures).

In the second experience, though, it was exactly the opposite, and my perceptions were. 1. The default was green pipelines ✅ , that is, quality was considered a first-class citizen; 2. when there was a failure ❌, soon the team self-organized to fix it and the pipeline turned green again ✅; and 3. when something has gone wrong ❌, we could look at all the other times it went right before it broke, alleviate any feelings of guilt, and refocus on quality through bug-fixing. ✅

Okay, but after all, do I only notify failures or all executions?

One approach that works is to have two channels, one for failures and one with all the execution history. The point is, remember to look at this history from time to time to understand the “healthy” of your project during its life. If the pattern is passing pipelines, you might be fine. Keep it up! If the pattern is more failures than green pipelines, stay alert ⚠️ and solve the problem's root cause.

What do you think of all that? Please, leave a comment.

___

This post was originally published in Portuguese on the [**Talking About Testing**](https://talkingabouttesting.com/2021/06/02/devo-enviar-notificacoes-no-slack-so-quando-os-testes-falham-ou-sempre/) blog.

___

👋 Until next time and happy testing!
Vector in C++
Tags: cpp
Published: 2021-06-10 16:27:36

`Vectors in C++` are sequence containers representing arrays that can change their size during runtime. They use contiguous storage locations for their elements.

## 1D Vectors 
### Syntax
`vector<data_type> variable_name`
`vector<int> vect;`
___
###Initializition of vector
![Initializition of vector](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cs79ly4mn0wq0bgwuelb.png)
### Iteration on vector
####1 ```cpp
  vector<int> vect(n, 10);
 
    for (int x : vect)
        cout << x << " ";
```
####2 ```cpp
vector<int> vect(n, 10);
// Traversing the vector using
// values directly
// no need to define datatype of vector
    for (auto& it : vect) {
  
        // Print the values
        cout << it << ' ';
    }
```

###Insert Elements into vector
![Insert Elements in vector](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hl608qkx1xfufl238soh.png)

###Access Elements of vector
![Access Elements of vector](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zwkg448rc6a40x37emnc.png)

###deleting vector elements
![deleting vector elements](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6d3h3kwywhw9hx6dro7b.png)

###Other functions
![Other functions](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/n4alk3ck5wedramn5gwp.png)

## Why Vector ?
* Size of arrays are fixed whereas the vectors are resizable i.e they can grow and shrink as vectors are allocated on heap memory. Arrays have to be deallocated explicitly if defined dynamically whereas vectors are automatically de-allocated from heap memory.
* Reserve space can be given for vector, whereas for arrays you cannot give reserved space.
* A vector is a class whereas an array is a datatype.
* Vectors can store any type of objects, whereas an array can store only homogeneous values.
Day 107
Tags: 100daysofcode, programming
Published: 2021-06-10 16:12:36

Day 107/200 of #200DaysOfCode #100DaysOfCode #100daysofcodechallenge 

- Solved two problems on Codewars.

1 - Binary to Text (ASCII) Conversion (6 kyu)
2 - Delta Bits (7 kyu)
JS Polyfills - Call, Apply, Bind
Tags: javascript, es6, polyfills, interview
Published: 2021-06-10 16:09:05

If you are here, I guess you would either be looking for new opportunities or honing your skills. I would like to help for either reasons with this article. Let's directly jump in to the topic without wasting our read time :metal:

##Polyfill for Call

{% embed https://gist.github.com/araddula/8a54a038334f307ba1892a807a18ff11.js %}

###Explanation:

What exactly is this :monocle_face: -> `arguments[0].fn = this;`

*In this above statement `this` refers to calling function i.e; `displayUser`*

* We are creating a property(fn) on object and assigning displayUser function to it
* Above would create an additional property `fn` on the passed object(user)
* Now, `fn` would have access to `this` on user object as `fn` is user objects property now
* So, pass only parameters now to function `fn` now, as it takes care of `this`
* Both `runCall` and `runCall2` are valid polyfills for `call` where `runCall2` has defined parameters and `runCall` depends on `arguments` object
* Look at the code below and compare with lines written inside function `runCall`

{% embed https://gist.github.com/araddula/b27f86ca5dd3bf76d848d3606192d9e4.js %}

##Polyfill for Apply

Apply polyfill is similar to call except that `apply` takes arguments as Array along with object(context)

{% embed https://gist.github.com/araddula/89957ce2af49cab5d4a54330afb5d84a.js %}

##Polyfill for Bind

Here comes the solution for our wait, atleast I feel though :wink:

{%embed https://gist.github.com/araddula/f61d66bd56f90825b484c7070469a58f.js %}

There are two functions created for bind polyfill in the above code. One is using `[].slice.call(arguments)` and the other one is using rest/spread syntax `...arguments`

> _Thank you for taking time to read my article. I know there would always be something to improve. Please feel free to share your thoughts_ :open_hands:
Gatsby Private Route not working as intended
Tags: help, gatsbyprivateroute
Published: 2021-06-10 16:02:18

---
title: Gatsby Private Route not working as intended
published: true
tags: help, GatsbyPrivateRoute
---

Hi everyone,

I'm trying to implement a blog with gated content using Gatsby as the front-end and Strapi as the CMS for authentication. Have been following the instructions from the official Gatsby docs on [client-only routes and user authentication](https://www.gatsbyjs.com/docs/how-to/routing/client-only-routes-and-user-authentication).

I want to make the following URLs private:
- `/app/articles` : This is the articles list page
- `app/articles/:slug`: URL for individual article page

If an unauthenticated user visits the above 2 URLs, they should be redirected to `/app/login` page.

The issue I'm facing here is, the Private route seems to work **only** for `/app/articles` (the unauthenticated user gets redirected to `/app/login`), but not for `app/articles/:slug` - the page displays the complete article even when the user is unauthenticated.

All the pages under both the URLs are prebuilt when I run the gatsby-server so that I can take advantage of static-site performance. I want to just prevent a user from seeing the content if they aren't logged in.

Can you please help me understand if I'm doing something wrong? Here is my [code](https://github.com/purnimagupta/Gatbsy-Authentication-With-Strapi) to get the complete picture.


**File: `/src/pages/app.js`**
```
const Index = ({location, history}) => {
    return(
        <Layout> 
            <Logout/>
            <Router>
                <PrivateRoute path="/app/articles/:slug" component={Article} />
                <PrivateRoute exact path="/app/articles" component={Home}/>
                <Login path="/app/login" location={location} history={history}/>
                <Signup path="/app/signup" />
            </Router>
        </Layout>
    )
}
export default Index;
```

Individual Article pages is being generated using gatsby `createPages`  API inside `gatsby-node.js`. And the template resides inside `/src/templates/article.js`

**File: `gatsby-node.js`**
```
exports.onCreatePage = async ({ page, actions }) => {
    const { createPage } = actions
    if (page.path.match(/^\/app/)) {
        console.log("matched app", page.path.match(/^\/app/))
        page.matchPath = "/app/*"
        // Update the page.
        createPage(page)
    }
}

exports.createPages = async function ({ actions, graphql }) {
    const { data } = await graphql(`
        query {
            allStrapiArticle {
                edges {
                    node {
                        slug
                    }
                }
            }
        }      
    `)

    data.allStrapiArticle.edges.forEach(article => {
        const slug = article.node.slug;
        console.log("node.slug", article.node.slug);
        actions.createPage({
            path: `/app/articles/${slug}`,
            component: require.resolve(`./src/templates/article.js`),
            context: { slug: slug },
        })
    })
    
}
```

Thank you!
How to tunnel to RDS without needing ec2 keypair
Tags: aws, rds, socat, ssm
Published: 2021-06-10 14:51:20

**Goals**

* Don’t require using ec2 keypair (ec2-user)
* Securely connect to your RDS database using a desktop client

**Solution**

* Install and run the “socat” tool on one of your application’s ec2 hosts
* Use SSM to forward the socat port to your local machine
* Run your desktop client and connect to your RDS database

**Details**

a. Setting up socat on ec2

* SSH to appls ec2
```
AWS_PROFILE=<saml-profile> aws ssm start-session — target “i-015b2a998123dsdsa4”
```
* Test connectivity (SG ingress) is correct for your ec2 server

* Using release DNS record for your RDS database (release your builds!)
```
curl -v telnet://<app-host>:1521

# Use socat to open a port up on i-015b2a998123dsdsa4

sudo yum install -y socat
sudo nohup socat tcp-l:9521,fork,reuseaddr tcp:<app-host>:1521 &

# Tunnel using socat + ssm port forward

AWS_PROFILE=<saml-profile> aws ssm start-session — target i-015b2a998123dsdsa4 \
 — document-name AWS-StartPortForwardingSession \
 — parameters ‘{“portNumber”:[“9521”],”localPortNumber”:[“9521”]}’
```

b. Get your credentials from AWS Secrets Manager (using your app ec2):
```
aws secretsmanager get-secret-value --region ap-southeast-1 --secret-id <secret-name> | jq -r .SecretString | jq
{
"password": "samplepwd",
"dbname": "demo-db",
"engine": "oracle",
"port": 1521,
"host": <db-host>,
"username": "root"
}
```
c. Test using SQL Developer.

Note: In your terminal, you’ll see a few log lines when you open/connect to your forwarded port:
```
Starting session with SessionId: botocore-session-1579056167-0c76865253a1232e
Port 9521 opened for sessionId botocore-session-1579056167-0c76865253a1232e.
Connection accepted for session botocore-session-1579056167-0c76865253a1232e.
```
And there you go. You can now see the data in SQL Developer !
Real World Data Science Interview Assignment
Tags: python, notebook, datascience, machinelearning
Published: 2021-11-16 16:05:29

---
title: Real World Data Science Interview Assignment
published: true
date: 2021-06-10 15:36:25 UTC
tags: python,notebook,datascience,machinelearning
canonical_url: 
---

[![](https://cdn-images-1.medium.com/max/600/1*KIWH_GMB-vzEnviQB4mPYg.png)](https://medium.com/dunder-data/real-world-data-science-interview-assignment-d26180ee95a5?source=rss----c2aa71d9ec41---4)

[Continue reading on Dunder Data »](https://medium.com/dunder-data/real-world-data-science-interview-assignment-d26180ee95a5?source=rss----c2aa71d9ec41---4)
How I installed Apertium on CentOS 7
Tags: apertium, installation, centos7, docker
Published: 2021-06-10 15:35:14

---
title: How I installed Apertium on CentOS 7 
published: true
description: 
tags: apertium,installation,centos7,docker
//cover_image: https://direct_url_to_image.jpg
---

* I use SBCL in my project but SBCL didn't work well on Ubuntu 20.04 in Docker 19.3 on CentOS 7, so I cannot use Docker. 
* I found that GCC 4.8.5 was too old for building VISL CG3, so I installed GCC 8.5.0. 
* Still it didn't work because VISL CG3 was linked with old libstdc++. So I avoid it by installing libicu using GCC 8.5.0. Then it works.

```bash
#!/bin/bash

set -x
mkdir -p apertium-src && \
mkdir -p $MTDIR 

cd apertium-src && \
    wget http://ftp.tsukuba.wide.ad.jp/software/gcc/releases/gcc-8.5.0/gcc-8.5.0.tar.gz -O - \
	| gzip -dc \
	| tar -xf - && \
    cd gcc-8.5.0 && \
    ./configure --prefix=$MTDIR --disable-multilib && \
    make -j $(nproc) && \
    make install && \
    cd .. || exit 1

cd apertium-src && \
    wget https://github.com/unicode-org/icu/releases/download/release-69-1/icu4c-69_1-src.tgz -O - \
    | gzip -dc \
    | tar -xf - \
    && cd icu/source \
    && CC=gcc CXX=g++ ./configure --prefix=$MTDIR \
    && CC=gcc CXX=g++ make -j $(nproc) \
    && CC=gcc CXX=g++ make install \
    && cd ../.. \
	|| exit 1

cd apertium-src && \
    svn checkout http://beta.visl.sdu.dk/svn/visl/tools/vislcg3/trunk vislcg3 && \
    cd vislcg3 && ./get-boost.sh \
    &&  ./cmake.sh -DCMAKE_INSTALL_PREFIX=$MTDIR \
		   -DICU_INCLUDE_DIR=$MTDIR/include \
		   -DICU_LIBRARY=$MTDIR/lib/libicuuc.so \
		   -DICU_IO_LIBRARY=$MTDIR/lib/libicuio.so \
		   -DICU_I18N_LIBRARY=$MTDIR/lib/libicui18n.so \
    && make -j$(nproc) && \
    make install && cd .. || exit 1

cd apertium-src && \
    git clone https://github.com/apertium/lttoolbox && \
    cd lttoolbox && ./autogen.sh --prefix=$MTDIR && make -j $(nproc) && make install && cd ../.. || exit 1

cd apertium-src && \
    git clone https://github.com/apertium/apertium && \
    cd apertium && ./autogen.sh --prefix=$MTDIR && make -j $(nproc) && make install && cd ../.. || exit 1

cd apertium-src && \
    git clone https://github.com/apertium/apertium-lex-tools && \
    cd apertium-lex-tools && ./autogen.sh --prefix=$MTDIR && make -j $(nproc) && make install && cd ../.. || exit 1

cd apertium-src && \
    git clone https://github.com/apertium/apertium-tha && \
    cd apertium-tha && ./autogen.sh --prefix=$MTDIR && make && make install && cd ../.. || exit 1

cd apertium-src && \
    git clone https://github.com/apertium/apertium-tha-eng && \
    cd apertium-tha-eng && ./autogen.sh --prefix=$MTDIR && make && make install && cd .. && \
    cd .. || exit 1
```
Developer Relations @ OneSignal
Tags: podcast, webdev, devrel
Published: 2021-06-16 22:18:18

---
title: Developer Relations @ OneSignal
published: true
date: 2021-06-10 15:30:00 UTC
tags: Podcasts, webdev, devrel
canonical_url: 
---

<iframe width="100%" height="180" frameborder="no" scrolling="no" seamless src="https://share.transistor.fm/e/9ae793f4/dark"></iframe> 

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hwseg3r9zb5cjjlapu30.jpeg)

The [OneSignal podcast](https://onesignal.com/podcasts) aims to help companies build meaningful and lasting relationships with their customers.  Episode 24 welcomes [Jordan Adler](https://www.linkedin.com/in/jordanmadler/), SDK & Developer Relations Leader at OneSignal, to discuss his career path, which has included building developer communities at Google, and how he sees the OneSignal DevRel team evolving.   
  
Please listen to the podcast to hear more of Jordan's insights, and you can follow OneSignal Developer Relations on Twitter [@OneSignalDevs](https://twitter.com/OneSignalDevs).   
  
You can subscribe to the OneSignal Podcast at your preferred podcast directory: [Spotify](https://open.spotify.com/show/2NN2fgyduMCGHkCip2cyZD), [Apple](https://podcasts.apple.com/us/podcast/onesignal-podcast/id1488398392), [Google](https://podcasts.google.com/?feed=aHR0cHM6Ly9mZWVkcy50cmFuc2lzdG9yLmZtL29uZXNpZ25hbA%3D%3D&hl=en), [TuneIn](https://tunein.com/podcasts/Business--Economics-Podcasts/OneSignal-Podcast-p1274139/), among many others.

[OneSignal](https://onesignal.com/) is the most widely used customer messaging and engagement solution, helping over a million businesses deliver over 8 billion messages to their customers each day **.**

[**Sign up for free**](https://app.onesignal.com/signup) today to use OneSignal to grow and retain your customer base.
🔥 Objects in JavaScript 
Tags: javascript, objectsinjavscript
Published: 2021-06-10 15:03:26

☑️ What are Objects? 

1. Objects are collection of property and property values
2. Every object has state and behavior
3. A real time object is mimicked in the programming world
4. A object can contain below things in it. 

   a. variable(integer, decimal, Boolean, character, string)
   b. array 
   c. function
   d. another object 

☑️ How to create objects in JavaScript? 

![image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xrlxbzq4v1wkpimiwk62.png)

Output: 

![image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fjy78fs7xw4h6vk57xve.png)
 
☑️ How to make an object read only? 

![image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0v8min6r8l6cj85ni3ew.png)

Output: 

![image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/14fxut7sxq1z06grlrf7.png)

☑️ How to make an object extensible(un expandable) but modifiable

![image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fg3byzzd8dzc86lxrzh8.png)
 
Output: 
  
![image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/s1ewasqnnow8bnc6j3rr.png)
 
☑️ How to expand an object property ? 

![image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6ml8dcuzcdigud9nooqy.png)

Output: 

![image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/99dy12c2hljf6nrqxv39.png)
  
☑️ How to add an Boolean object property to an Object?

![image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/db0ns64q5jrdyom7jq55.png)
 
Output:

![image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zmzceemq6ymc9n61mzen.png)
 
☑️ Object DE structuring

![image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/b2lgmiccurgsl7yodm89.png)

Output: 

![image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0odngiif6qldqnc5iseb.png)
WAF for ALBs
Tags: aws, waf, alb, security
Published: 2021-06-10 15:02:05

**Overview**

WAF support for ALB is now available in many regions.

Clients want to provide a pattern of using ALB → (Lambda | EC2) to be secured via WAF (and HTTPS).

Clients want to minimise the maintenance footprint of adding WAF for many applications.

**Architecture**

![arch](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cbo4bv0nq1p2x0bfjp5m.png)

**Pricing Details**

**WAF Pricing**

a. WAF
* $5 per web ACL per month
* $1 per rule per web ACL per month (assume one rule = “core-waf-automations — SQL Injection Rule”)
* $0.60 per million web requests

b. F5

* Charge per month in each available region (pro-rated by the hour) $20 / unit
* Charge per million requests in each available region $1.2 / unit

**Estimates**

a. WAF Pricing

* 12 web acls (6x2 acls)
* 10 rules per WebACL = 120 rules total = $120
* 100 million requests = $60
* $2,160 Annual cost

b. Market place pricing — 4x F5 managed rulesets

* $480 for $80 per account per region per month x 6
* $480 for 100 million requests x 4 rulesets (total requests across all accounts / regions)
* $11,520 Annual cost

c. Total pricing estimate

* $13,680 annual total

**Solutions**

a. Author is AWS themselves

b. Without dedicated security team — “web application firewall strategy” can be a hassle (even with one)

c. AWS WAF ACL — central inspection and decision point for incoming requests (for all apps that use it)

* This solution has a bunch of preconfigured rules for use with ALB, CloudFront

* I’m assuming we can easily integrate with marketplace rules, like the F5 ones.

d. Log analysis — more than just “waf rules to apply” — there’s mechanisms for updating rules:

* Both WAF logs and App logs can be parsed by Athena/Lamdba to inform on HTTP Flood, Scanners & Probes

* Scheduled cloudwatch event rule triggers lambda to maintain IP Reputation Lists

* Bot lists also updated via a lambda.

**Types of Rules**

a. White/black listing (manual lists)

* No automation setup around these lists — is the expectation you manage via AWS Console?

b. SQL Injection, XSS (patterns in URI, querystring, request body)

c. HTTP Flood (web-layer DDoS, brute force logins)

* ConfigureRateBasedRule (Custom::ConfigureRateBasedRule — HttpFloodProtectionRateBasedRuleActivated)

d. Scanners & Probes (abnormal amount errors from an origin)

e. IP Reputation Lists (3rd party lists hourly updated)

* spamhaus.org
* torproject.org
* emergingthreats.net

f. Bad Bot (honeypot to attract bots)

* ApiGateway, Lambda
Bora vencer o medo de testes e entrevistas técnicas ?
Tags: braziliandevs
Published: 2021-06-10 14:48:06

Recentemente comecei a procurar novas oportunidades de trabalho e logo me deparei com um medo que nem sabia que tinha: fazer teste técnico ou participar de entrevista técnica. Isso é novo para mim, pois nos meus trabalhos anteriores não cheguei a fazer nada do tipo, era só uma entrevista perguntando sobre as linguagens que conhecia, link de projetos que já havia desenvolvido e portfólio.

Confesso que deixei passar algumas oportunidades por conta desse medo, quando via no e-mail "você será submetida a fazer um teste sobre X assunto" já começava a suar frio rs, até que criei coragem, encarei esse medo e olha, foi muito bom! Comecei a ver esses testes como uma oportunidade de aprender mais e saber até onde tinha conhecimento sobre o assunto.

Os testes técnicos variam muito de empresa para empresa, realizei um que foi desenvolver um projeto a partir das especificações passadas, outro no estilo de desafios do hackerrank ou plataformas de exercícios de programação. Confesso que me senti mais confortável fazendo um projeto porque tive alguns dias para fazer, pesquisar um pouco mais sobre e o processo de desenvolvimento foi divertido, consegui aplicar os conhecimentos de arquitetura que estou aprendendo e acabei descobrindo algo novo que não sabia.

Já nos desafios voltados a programação em si, não me senti tão confortável pois tive mais pressão por ter no máximo 2 horas para resolver, teve um que não tive nem 1h para fazer quase 15 desafios de várias linguagens, esse realmente foi bem frustrante para mim.

Teve algumas entrevistas técnicas que foram em conjunto com desafio, nesse caso eu consegui me sentir mais tranquila pois já tinha conseguindo perder esse medo e foi uma experiência bem legal, os entrevistadores além de passar o desafio, a todo momento conversavam comigo me questionando (de um jeito saudável) o motivo de eu estar construindo o desafio daquele jeito, me ajudando a ver outras soluções para o problema, pontos que preciso me atentar e dicas de como melhorar esses pontos.

Moral da história, não tenham medo dessas fases, ainda mais nós programadores, na maioria das vezes só ter um github ou portfólio não será suficiente para vaga, então se tiverem oportunidade de realizar esses testes, façam! E levem como aprendizado, não apenas voltado para parte técnica, como pessoal também.

A dica que dou passando por essas etapas é: fiquem tranquilos quando forem realizar o teste ou a entrevista; não minta sobre seus conhecimentos, seja o mais claro possível; façam perguntas para o entrevistador técnico também, caso tenha ficado em dúvida ou não saiba algo que o entrevistador falou pergunte, se ele te explicar será uma lição aprendida.

Lembre-se o teste é para saber o quanto de conhecimento você possui sobre o assunto, não se sinta mal caso não alcance o esperado, faça seu melhor e saia tranquilo, terão outras oportunidades que irão se encaixar ao seu perfil, o segredo é não desistir e continuar melhorando o que precisa!