teleren/devto huggingface dataset:
SQL Course: Self Join
Tags: sql
Published: 2024-07-01 21:45:41

It’s time to add followers to our database application. 

We will establish one more many-to-many relationship. Our join table will be the followers table. 

The interesting thing with this table is that is the two foreign keys are referencing the same table, the users table. Therefore we need to query the followers with a self join. 

[Read more about self joins.](https://www.w3schools.com/sql/sql_join_self.asp) 

## Create the join table 

* The OwnerID is the user who follow another user.
* The FollowingID is the user who is being followed. 
```
CREATE TABLE Follows
  (
  ID INTEGER PRIMARY KEY AUTOINCREMENT,
  OwnerID INTEGER,
  FollowingID INTEGER,
  FOREIGN KEY (OwnerID) REFERENCES Users(ID),
  FOREIGN KEY (FollowingID) REFERENCES Users(ID)
  );
```

## Insert data 

Ex user with ID 1, Ben follow user with ID 2, Jim.

```
INSERT INTO Follows (OwnerID, FollowingID) VALUES
  (1, 2),
  (2, 1),
  (2, 3);
```

## Query with self join. 

In this query we retrieve all users and the users they follow and then group by user.

```
SELECT 
owner.username, followsUser.Username
FROM Follows f
JOIN Users owner ON f.OwnerID = owner.ID
JOIN Users followsUser ON f.FollowingID = followsUser.ID
GROUP BY owner.username, followsUser.Username;
```

We can also get all the users a particular user is following.

```
SELECT 
owner.username, followsUser.Username
FROM Follows f
JOIN Users owner ON f.OwnerID = owner.ID
JOIN Users followsUser ON f.FollowingID = followsUser.ID
WHERE owner.Username = 'Ben';
```
Don't be a jack of all trades: The incredible importance of domain knowledge for software testers.
Tags: webdev, productivity, softwaretesting, career
Published: 2024-07-01 21:44:32

**_As a software tester, diving deep into the domain you’re working in isn’t just a nice-to-have—it’s a game-changer! Here’s why:
_**

1. Know What to Test: Understanding the domain means you know exactly what aspects of the product to test. You can pinpoint critical functionalities and ensure they work seamlessly.

2. Where to Test: Domain knowledge helps you identify the key areas of the application that need thorough testing. You’ll know where the potential pain points are and can focus your efforts there.

3. How the Product Works: A solid grasp of the domain means you understand the product inside out. This knowledge allows you to simulate real-world usage scenarios and catch bugs that might otherwise be missed.

4. Feature Expectations: Knowing the domain means you’re aware of the essential features the product should have. You can ensure these features are present and functioning as expected.

5. User Interaction: You can evaluate how the product should interact with users, ensuring a smooth and intuitive user experience. Your insights can help design a product that users love.

6. Critical Decisions: Domain expertise helps you make informed decisions about what the product should and shouldn’t include. You can guide the development process to ensure the final product meets user needs.

7. Developer Support: Even if developers aren’t familiar with the domain, your knowledge can bridge the gap. You can highlight potential issues and areas for improvement that developers might overlook.


**But wait, there’s more! 🌟**

- Faster Issue Identification: With domain knowledge, you can quickly identify and address issues. You’ll know what to look for and can catch defects early in the development cycle.

- Improved Communication: You can communicate more effectively with stakeholders. Whether you’re discussing requirements with clients or collaborating with developers, your domain expertise makes you a valuable interlocutor.

- Increased Credibility: Having domain knowledge boosts your credibility. Teams will trust your insights and rely on your expertise to ensure the product’s success.

- Continuous Improvement: Domain knowledge isn’t static. As you continue learning and growing within the domain, you’ll bring fresh perspectives and innovative solutions to the table.

In a nutshell, being a knowledgeable software tester means being a domain expert. Your insights drive quality, enhance user experience, and ensure the product not only meets but exceeds expectations.

So, fellow testers, dive deep into your domains and let’s keep making amazing products! 💡✨
Setup para Ruby / Rails: Sistema Operacional
Tags: beginners, ruby, rails, braziliandevs
Published: 2024-07-01 21:38:52

Essa série é um guia para quem quer preparar um ambiente de desenvolvimento [Ruby](https://www.ruby-lang.org/en/) / [Rails](https://rubyonrails.org/). 

O objetivo é apresentar um passo a passo com o mínimo necessário para que você possa começar a desenvolver com Ruby o mais rápido possível.

Escolha o seu sistema operacional e siga as instruções.

- [Windows 11](https://dev.to/serradura/setup-para-ruby-rails-windows-wsl-479l)
- [Linux Ubuntu](https://dev.to/serradura/setup-para-ruby-rails-ubuntu-2ip8)
- MacOS (em breve)

---

Já ouviu falar do **ada.rb - Arquitetura e Design de Aplicações em Ruby**? É um grupo focado em práticas de engenharia de software com Ruby. Acesse o <a href="https://t.me/ruby_arch_design_br" target="_blank">canal no telegram</a> e junte-se a nós em nossos <a href="https://meetup.com/pt-BR/arquitetura-e-design-de-aplicacoes-ruby/" target="_blank">meetups</a> 100% on-line.

---
Resumo Kubernetes
Tags: kubernetes, k8s, kubectl, aks
Published: 2024-07-01 21:29:31

---
title: Resumo Kubernetes
published: true
description: x
tags: kubernetes, k8s, kubectl, aks
---

## Configurar cluster

Configurar kubectl para acessar um Azure AKS

```sh
az aks get-credentials -g ${GROUP} -n ${CLUSTER}
```

Ver configurações do kubectl

```sh
kubectl config view
```

Adicionando um novo cluster ao kubectl

```sh
# Add a user/principal that will be used when connecting to the cluster
kubectl config set-credentials kubeuser/foo.com --username=kubeuser --password=kubepassword

# Point to a cluster
kubectl config set-cluster foo.com --insecure-skip-tls-verify=true --server=https://foo.com

# This context points to the cluster with a specific user
kubectl config set-context default/foo.com/kubeuser --user=kubeuser/foo.com --namespace=default --cluster=foo.com

# Use this specific context
kubectl config use-context default/foo.com/kubeuser
```

Trocando de cluster

```sh
#  Mostrando os clusters configurados no ~/.kube
kubectl config get-contexts

# Mostrando o contexto atual
kubectl config current-context

# Trocando de contexto
kubectl config use-context CONTEXT_NAME
```

## Namespaces

Criando um namespace

```sh
kubectl create namespace ${NAMESPACE}
```

Trocando o namespace corrente

```sh
kubectl config set-context --current --namespace=${NAMESPACE}
```

## Pods

Procurar (por label)
```sh
kubectl get pods -l app=MY-APP

POD_NAME=$(kubectl get pods -o=jsonpath='{.items[?(@.metadata.labels.app=="MY-APP")].metadata.name}')
```

Describe (ver eventos)
```sh
kubectl describe pod $POD_NAME
```

Logs (da aplicação)
```sh
kubectl logs $POD_NAME
```

Mostrar os nodes de execução dos pods
```sh
kubectl get pods -o=wide

# Filtrar pelo nome do node
kubectl get pods --field-selector spec.nodeName=$NODE_NAME
```

## Terminal

Abrir terminal num pod

```sh
kubectl exec --stdin --tty $POD_NAME -- /bin/bash
```

> Se estiver usando um terminal Git-bash ou MinGW, colocar a variável `MSYS_NO_PATHCONV`:
> ```sh
> MSYS_NO_PATHCONV=1 kubectl exec --stdin --tty $POD_NAME -- /bin/bash
> ```

## Service

Acessando um serviço

```sh
kubectl get svc ${SERVICE_NAME}

EXTERNAL_IP=$(kubectl get svc ${SERVICE_NAME} -o=jsonpath='{.status.loadBalancer.ingress[0].ip}')

curl http: ${EXTERNAL_IP}/api/v1/hello
```

Expondo um endereço:

```sh
kubectl port-forward service/${SERVICE_NAME} 9200:9200
```

## Logs

```sh
kubectl logs -p $POD --all-containers --previous=false
```

## Restart pods

Sem downtime:
```sh
kubectl rollout restart deployment <deployment_name>
```

Parando todos pods e depois reiniciando todos:
```sh
kubectl scale deployment <deployment name> - replicas=0
kubectl scale deployment <deployment name> - replicas=1
```

Alterando uma variável associada ao pod:
```sh
kubectl set env deployment <deployment name> LAST_START_DATE="$(date)"
```

Selecionando um pod específico:
```sh
kubectl delete pod <pod_name>
```

Selecionando todos pods com label:
```sh
kubectl delete pod -l "app:myapp"
```

## Performance

Mostra consumo de CPU e MEMORY de pods

```sh
kubectl top pod
kubectl top pod POD_ID
```
A simple guide to React.js and Next.js
Published: 2024-07-01 21:05:41

React.js and Next.js are popular frontend technologies or tools used to build websites or web applications, particularly in the front end. If you're new to web applications this write-up can be useful in understanding what these technologies do and their differences. 
React.js, also called React, is a javascript library created by the popular Facebook. It makes things easier for developers by breaking down user interfaces(UIs) into feasible, reusable parts known as components, enabling programmers or developers to create UIs. Components are just like puzzles or LEGO blocks that we can put together to create a complete website or web application.
Next.js is a javascript framework built on top of React. Created by Vercel, it basically makes React better by adding extra features that make building complex websites easier. It handles issues like rendering web pages on the server and generating static pages ahead of time.
React.js is more flexible than Next.js meaning React allows you to configure and set up the project the way you like it making it possible to choose different libraries and tools that you need meanwhile Next.js comes with a lot of built-in features and conventions, limiting the use of manual setup and configuration. Next.js helps to render services like simple routing, server-side rendering, and static site generation making the creation of SEO-friendly websites. 
I am excited about participating in the HNG internship to enhance my React.js skills and gain proper experience in front-end development. React.js's powerful features and its known flexibility make it an excellent choice for building websites or web applications and I'm excited to use this wonderful technology to contribute and build meaningful projects during the internship at HNG. Click the link to join the HNG internship [(https://hng.tech/internship,)]. You can also hire elite developers, click the link below to hire ;[(https://hng.tech/hire)].
READING RECENT DOCUMENTATION CAN SAVE YOU A LOT OF TIME: MY EXPERIENCE TRYING TO UPSERT VECTORS TO MY PINECONE DATABASE
Published: 2024-07-01 21:04:42

My name is Ezenwa Victory Chibuikem, a recent graduate of Electrical and Electronics Engineering from FUTO. I am a data scientist looking to extend my expertise to machine learning engineering. I view machine learning engineering as a role designed for software engineers who can build machine learning models. Recently, I signed up for and was accepted into HNG Internship 11, where I joined the Backend track to gain experience as a software engineer, particularly in Backend development. If you are seeking valuable experience in fields like mobile development, DevOps, backend, frontend, or data analysis, HNG is an excellent starting point. You can explore more at HNG internship (https://hng.tech/internship) or HNG hire(https://hng.tech/hire).

Today, I will be writing about my most recent backend roadblock. Although I wouldn’t call it a difficult backend problem, it was certainly one I couldn’t have solved on my own. I was building an e-commerce product recommendation system that used inputted texts and images to recommend products to users. This was done using Flask, and Pinecone served as my vectorized database. After setting up a connection, I couldn’t seem to upsert any records. The error message displayed wasn’t helpful either, as it didn’t point to a failed insertion but rather to incorrect dimensions of my vectors.

At first, I thought the issue was with my vectorization. I even changed the vectorization scheme twice (hard lesson: check your function arguments before changing your entire logic). After hours of debugging and searching, I was able to narrow it down to the upsert line of code and began rechecking it with examples on the internet. I found someone with a similar problem on Stack Overflow, and my issue was solved. The error resulted from assigning a value to a deprecated argument. Initially, I was angry at the energy spent trying to overcome this, but in the end, I couldn’t be happier that I got to move on to other parts of the project.

I hope this was an insightful read. I’m looking forward to seeing how much my software engineering skills will improve after this internship. Till next time!
Mental Challenges
Tags: creative, challenge, hard75, beforeandafter
Published: 2024-07-01 20:36:14

As a person in tech for over 2 decades, I have always seen how well I had done with development but never took it to the next level.   The same can be said to physical activity or sports.   There is a thought that I get pretty close to good, then get board and I need to have a challenge.   With physical activity, I have taken apon me to do 30/60 day challenges, and am currently doing a 75 day challengs.

The Challenge is as follows and I have made it hybrid
1. Gallon of water each day for 75 days(pure water, nothing mixed)
2. 300 Grams of protein under 2000 calories
3. write a python script everyday, it needs to encompass a new API type, a new ML function and a complex calculation based on the information written
4. Workout twice a day(45 minutes inside 45 minute outside)
5. Read a non-fiction book for 15 pages


This is the start to day 1
A technical article about front-end technologies
Published: 2024-07-01 20:30:47


Introduction
Frontend technologies are a set of technologies used to develop the user interface of web pages and applications.
Developers can create anything from design, structure to animation we see when opening a website, web applications or a mobile app.
The primary goal of front-end development technologies is to improve efficiency during the web development process.

A list of front-end technologies which has surfaced the rise of libraries and framework includes. 
Vue JS: which was created by Evan You. 
Vue JS is widely used to develop interactive user interface and SPAs. It is one of the best suited JavaScript for creating a lightweight and adaptive interactive UI elements.It is also very easy to implement because of the model view-view model(MVVM) architectural pattern.

Flutter:
This is one of the most rapidly growing front-end framework for developing effective and flexible web design.It assist a developing flexible and native-like apps with a singular code base. With flutter,developers can quickly create cross-platform apps using the dart programming language.

React.JS:
 This is a popular open source JavaScript front-end library that enables the creation of dynamic and interactive applications while also improving the UI/UX designs. React.JS has a declarative UI, which makes react code easily read and fixed.
Conclusion
 Knowing fully well that HNG is a React only based front-end internship, I will really love to forge ahead with this opportunity given to me to learn React as a front-end technique for web development.

 https://hng.tech/internship
https://hng.tech/hire
SQL Course: Many-to-many relationship and Nested Joins.
Tags: sql
Published: 2024-07-01 20:24:21

You have learned about one-to-one and one-to-many relationships and they are quite straight forward. Many-to-Many works a bit different because you need an extra table, so called join table. 

In this example we will let users like posts in the database. To achieve this functionality we need to create a many-to-many relationship because a user can like many posts and a post can have many likes.

To establish this relationship we need a join table that holds a reference to the user who likes the post and the post that is being liked. 

### Create a likes table that function as a join table. 

```
CREATE TABLE Likes
(
  ID INTEGER PRIMARY KEY AUTOINCREMENT,
  PostID INTEGER,
  UserID INTEGER, 
  FOREIGN KEY (PostID) REFERENCES Posts(ID),
  FOREIGN KEY (UserID) REFERENCES Users(ID)
);
```

## Insert data to the likes table.

We add the user’s ID and the post’s ID. Ex user 1, Ben likes post 1 about sql.
```
INSERT INTO Likes (UserID, PostID) VALUES
  (1, 1),
  (2, 1),
  (3, 1), 
  (1, 2),
  (2, 2),
  (3, 3);
```

## Nested Join 
To be able to query data from a many-to-many relationship we need nested joins.

1. Select the fields to retrieve.
2. Use the join table as starting point, our likes table. 
3. Join the related data, in our case the users and the posts.

```
SELECT 
u.Username, p.Title, p.Content
FROM Likes l
JOIN Users u ON l.UserID = u.ID
JOIN Posts p ON l.PostID = p.ID;
```

To make the result more readable let’s group users and the posts they liked together.

```
SELECT 
u.Username, p.Title, p.Content
FROM Likes l
JOIN Users u ON l.UserID = u.ID
JOIN Posts p ON l.PostID = p.ID
GROUP BY u.ID, p.ID;
```

Result:

Ben | sql | sql content
Ben | java | java content
Jim | sql | sql content
Jim | java | java content
Luk | sql | sql content
Luk | NLP | NLP content
Add Filter choices to resources
Published: 2024-07-01 19:17:38

I worked on the project Add Filter Choices to Resources as my first task, focusing on implementing filterable actions for both users and administrators. This enhancement ensures a user-friendly interface for managing Share Networks by utilizing filters and workflows.

The ShareNetworksView class is central to this functionality, displaying a list of share networks using a table. It retrieves detailed data from the Manila API and applies user-defined filters to refine the results. The get_filters method enables filtering based on criteria such as name or description, making it easier to manage large sets of data.

For updating share networks, the Update class provides a guided workflow that sets the necessary initial data and context for the process. Similarly, the Create class streamlines the creation of new share networks, defining the required forms and URLs.

The Detail class offers an in-depth view of a specific share network, showcasing its properties and related information. It gathers additional details from the Neutron API, offering a comprehensive overview of the network’s subnets and availability zones. The get_data method further enriches the share network data with security services and share server information.

Overall, this project enhances the functionality of the Horizon dashboard, making it more intuitive and efficient for managing Share Networks.

The image attached here is the sample of the test.
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jj8vu1nktyf6yvuypld6.png)
How to deploy React App to GitHub Pages - Caveman Style 🌋 🔥🦴
Tags: webdev, github, react, staticwebapps
Published: 2024-07-01 19:10:10

Like a good caveman you have to do everything by hand and with as little automation as possible.

## Create the New Repo
Create the repo on your GitHub Account
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jchhkd2w19vist0a1hoy.png)

Create a public repo named `<user-name.github.io>`
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gjdrpmjnt7yb3od0wjs3.png)

## Configure the GitHub Pages to Deploy From Branch
Go to Settings tab:  

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

On the left side menu choose Pages

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

In the building and deploy options choose Deploy from branch and select the branch you want to use.

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

Now your have configured everything by hand to make your GitHub Pages Site able to receive files for deploy.

## Create a your React App Static Website
You my have it finished already and don't need to create. I used `vite` and `pnpm` and choose a typescript template. So it would look like:  

```pnpm create vite```

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

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

Well, do your thing react and push it to GitHub.  
It may involve:  
```bash
git add .
git commit -m "react app first commit"
git remote add origin git@github.com:<user>/<repo>.git
git push -u origin main
```
 
## Be the Caveman
In the configured branch you only need the files generated by React's build, and your App will be live at https://<your-username>.github.io/. The root of your branch should look like this:

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

To generate the files use:  
```bash
pnpm run build
``` 
or whatever is your package manager.

Then delete all files except the *dist* folder(be careful if you don't have a backup in another branch you can lose everything), copy *dist* folder's content to the root folder and delete *dist* folder. You can do it by hand or use a script since we're not going to remain caveman forever, and I want to start automating things in the next posts:  

```bash
find . -mindepth 1 -maxdepth 1 ! -name 'dist' ! -name '.git' -exec rm -rf {} +
cp -r dist/* .
rm -r dist
```

Commit and push to the configured branch.

## Not Caveman Forever
The process I just showed is error prone and cumbersome. In another post I will discuss how I automated it, for those impatient here is the code of the automation https://github.com/uxjp/uxjp.github.io/pull/5/files.
SQL Course: One-to-many Relationships and Left Joins
Tags: sql
Published: 2024-07-01 19:05:57

In the last chapter we learned about one-to-one fields and inner joins. In this chapter we learn about one-to-many relationships and left joins. If you followed the last chapter this should be easy. 

We will create a `posts table` and a `post is related to one user` and a `user can have many posts`. That is why it is called a one-to-many relationship.

## Prerequisites with links
* [Left Joins](https://www.w3schools.com/sql/sql_join_left.asp)

## Create the posts table

We create the post table with its own primary key and a foreign key to the user's table. 

By letting the posts table have an independent primary key there is no restriction of multiple posts having the same foreign key. 

```
CREATE TABLE Posts
(
  ID INTEGER PRIMARY KEY AUTOINCREMENT,
  UserID INTEGER NOT NULL,
  Title VARCHAR(255) NOT NULL,
  Content TEXT NOT NULL,
  FOREIGN KEY (UserID) REFERENCES Users(ID)
);
```

### Insert data to the posts table

```
INSERT INTO Posts (UserID, Title, Content) VALUES 
   (1, 'sql', 'sql content'),
   (1, 'java', 'java content'),
   (2, 'NLP', 'NLP content'),
   (2, 'rust', 'rust content');
```

## Query with a left join.

We will make a query where we get all the users and if the user has a post we retrieve that post.
```
SELECT u.Username, p.Title, p.Content
FROM Users u
LEFT JOIN Posts p ON u.ID = p.UserID;
```

Result: 
Ben | java | java content
Ben | sql  | sql content
Jim | NLP  | NLP Content
Jim | rust | rust content
Luk |      |
API Gateways
Tags: networking, webdev
Published: 2024-07-01 18:52:28


## The What 
API Gateways to extract bunch of code that would otherwise be inside your servers and  extract it out to a different server. 

##The Why / Advantages

Authorization: User authentication can be done before sending the request to your microservices. 

Transformation & Validation : Client would have the liberty to send data in a clean uniform format, API gateway would transform the data and validation then pass it to the microservice in a customized format. 

Client can avoid DNS lookup: responsibility of routing to server and load balancing can be situated in API Gateway. 

Rate limiting: API gateway can supervise the requests from the clients and prevent DDOS attacks.