teleren/devto huggingface dataset:
API testing for the win
Tags: testing, automation, jest, javascript
Published: 2023-04-04 19:24:42

Once in a while, depending on your product, you may want to steer towards API tests for a few reasons:

1. If you're working with a small test team, you'll get a pretty big win out of API tests. They're easier to write than UI tests, and you're only dealing with the backend.
2. Execution times are faster (most of the time, anyway).
3. Developers typically don't get involved with UI tests, but there may be a comfort level with API tests that might increase engagement when it comes to adding new tests, troubleshooting failures, and reviewing test results.

Let's get right to it. Overall, testing Restful services has always followed a pretty simple pattern:

1. Depending on the type of request, there may be a payload to send.
2. Send the request via rest library.
3. Assert against the response.

Jest works great as a test runner and assertion library. You can use axios/supertest/request/chai as the rest library (I am personally partial to supertest). Tests are easy to write in Typescript and are (in my opinion) less verbose than using Java. Parsing JSON responses using JS is also a dream. Finally, finding some talent familiar with JS should be fairly easy.

In breaking down the above 3 steps you might want to build out a set of utils/helpers/whatever to help you do them:

1. You may want to follow a pattern where you can build payloads, massage / transform some of it for your scenarios, and return those payloads so they can be sent off to the backend.
2. You'll want to abstract away some of the get/patch/post/delete requests into their own functions so that you don't need to worry about auth and tokens. 
3. Unfortunately some backend responses can be massive. So asserting against dozens of keys and values can be a counterproductive exercise. Asserting on the status code, and then maybe some important IDs, and other keys that might be important to business logic might be a good place to start.

Then all of a sudden tests look very, very simple to write like this:

```
import { createUserPayload } from '../helpers/userPayloadHelper'
import { post } from '../helpers/requestHelper'

describe('users API', () => {
  test('create user', async () => {
    const uri = '/users'
    const user = createUserPayload()
    const response = await post(uri, user)

    expect(response.statusCode).toBe(201)
    expect(response.body.name).toBe(user.name)
    expect(response.body.email).toBe(user.email)
  })
})
```

You'll find a lot of teams that also go with the whole Postman/Newman route that is pretty popular, but I have pretty strong opinions that maintaining code in the long run will always beat out maintaining a Postman collection. Plus you'll be doing your test team a favor getting them to learn to write code, and API tests follow some pretty simple patterns that are pretty hard to screw up even if you try.
Paracetamol.js💊| #212: Explica este código JavaScript
Tags: javascript, webdev, spanish, programming
Published: 2023-04-04 19:23:45

## **<center>Explica este código JavaScript</center>**
#### <center>**Dificultad:** <mark>Intermedio</mark></center>

```js
const numbers = [1, 2, 3, 4, 5];
console.log(numbers.with(2, 6)); 🤔
```

- A. `[ 1, 2, 6, 4, 5 ]`
- B. `[ 1, 2, 3, 4, 5 ]`
- C. `Array.prototype.whit is not a function`
- D. `undefined`

---
How the VLE Works - The Internals of Apache AGE
Tags: postgres, apacheage
Published: 2023-04-04 19:11:44

## **Introduction**
In this article I will give an introduction to the internals of Apache AGE, specifically how the VLE (Variable Length Expressions) works.

## **Prerequisites**
A basic knowledge of PostgreSQL or any other Relational Database Management System (RDBMS), including an understanding of tables, schemas, and commonly used SQL queries such as SELECT, INSERT, DELETE, and UPDATE, is essential. Additionally, proficiency in JSON (JavaScript Object Notation) is also necessary.

## **How Variable-Length Expressions (VLE) Works**
VLE allows users to express variable-length patterns in a graph, which can be useful for a wide range of applications, such as recommendation systems, fraud detection, and social network analysis.

The VLE function in Apache AGE is responsible for loading the relevant parts of the graph into memory and executing the path-finding algorithm. This algorithm is a graph traversal algorithm that works on a graph, not a tree. It searches for all paths of any length from all vertices to all vertices, which can result in a high number of computations, especially for large graphs. The speed of the algorithm is directly related to the size and connectedness of the graph and what it is looking for.

For instance, look at the following queries: 
`MATCH p=(u)-[*]-(v) RETURN p`
`MATCH (u)-[*]-(v) RETURN u`
`MATCH ()-[*]-() RETURN COUNT(1);`

All of these queries will basically do the same thing - search for all paths of any length from all vertices to all vertices. This means that for a graph of 1 million nodes, this algorithm will be invoked up to 1 trillion times (the number of VxV combinations). Now, add that you are asking for all of the paths between each combination. So, each additional path length can add to the work done.
To minimize the workload, it is best to limit the algorithm's search scope by restricting where and how deeply it needs to look. This means restricting where it needs to look and how deeply it needs to look. Just because you restrict the input vertices doesn't mean that you restrict the interior vertices. The algorithm doesn't care about them, it only cares about interior edges.
It is worth mentioning that the VLE function in Apache AGE generates all valid paths from a start vertex and leaves the match against the terminal vertex to Postgres, due to implementation factors.

Apache AGE repository: https://github.com/apache/age
Apache AGE website: https://age.apache.org
5 of the Most Common Ethical Hacking Attacks?
Tags: cybersecurity, productivity, security, ethicalhacking
Published: 2023-04-04 19:07:53


_The process of harnessing hacking tools for good and identifying flaws before malevolent hackers may abuse them is known as ethical hacking. Even ethical hackers need to be aware of a few typical attacks since they can help avert serious cyberattacks._

1. Phishing (https://en.wikipedia.org/wiki/Phishing): Phishing is a common type of cyber attack in which the attacker poses as a reputable organization in order to obtain sensitive data including login credentials, credit card numbers, and personal information. Attacks using phishing can be carried out via phone calls, instant chats, social media, and even emails.

2. Malware: (https://en.wikipedia.org/wiki/Malware) The word "malware" is a generic one that covers a variety of malevolent software, including viruses, trojans, and ransomware. The term malware also depicts software that, once installed on a computer system, has the ability to undermine security, steal data, or even take over the entire machine.

3. SQL injection (https://en.wikipedia.org/wiki/SQL_injection): When SQL statements are altered, it allows an attacker to access a database without authorization. Data theft, data modification, and data deletion are all possible with it. Attacks involving SQL injection are particularly dangerous since they may frequently be carried out by attackers without the requirement for any privileged access.

4. Denial of Service (DoS): (https://en.wikipedia.org/wiki/Denial-of-service_attack) A DoS attack involves bombarding a system with traffic, leading it to crash or become unresponsive. DoS operations are frequently performed utilizing a botnet, which consists of several compromised devices used to launch the attack.

5. Man-in-the-middle (MitM) attacks (https://en.wikipedia.org/wiki/Man-in-the-middle_attack): Man-in-the-middle attacks include intercepting communication between two parties in order to eavesdrop, change, or even spoof it. Such attacks are especially harmful since they allow attackers to obtain sensitive information such as passwords, credit card numbers, and personal information.

It is apparent that these are some of the most prevalent ethical hacking attacks that bad hackers can use. It's indeed critical to remember these attacks in order to stay safe and secure online. Knowing about these attacks allows ethical hackers to devise mitigation or prevention techniques.

_Thank you for visiting! Don't forget to follow me for more insightful blog posts._
Squiggly idealism
Tags: watercooler, career
Published: 2023-04-04 19:07:43

I think I’m happier now as a programmer than I have ever been. Learning a vital skill, the art of letting go. I’ve shed many ideas that I once held dear about maintainable testable code to be replaced with flexible per case basis.

I used to join companies and annoy royally my seniors with rules and dogma that I believed would make for better code standards and code, eventually realising that the lessons I actually learned where not from practicing my strict idealistic views, no, growth, it came from others.

Warrant Buffet once said “surround yourself with people better than you” which fits in with the classic idea that good leaders lead from the front, you are better than me until we are equals.. now think about your idea of what makes good code and ask, have I tried the contra? Dare I challenge my ideas and see how right I am.

That is what I have tried to do where appropriate and I think it’s a milestone, to some it might appear like not caring but it’s actually the opposite, there are many ways to achieve something and ignoring that fact and pretending your current trajectory is a constant line without change is foolish 

So be flexible, have fun and try wild ideas 💡
Search Feature (Blog Post)
Published: 2023-04-02 07:32:23

### How did you get the relationship between Searching and rendering results working
- I believe our code filters through the different badges but we still haven't found a way to render the results.

### Draw a diagram on draw.io for user interaction pattern. What happens from user input, through machine sending value, to re-rendering on the page

![User Interaction Diagram](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/w89zxy0jyc3rhz60npuw.png)


### Think of a real world use-case from industry (Media streaming, YouTube, corporate, cable company provider, web platform, etc.) where micro-service architecture could fit into their business context. How could we use this approach to solve a real problem at a company currently using a monolithic design architecture?
- Microservices can help businesses leverage other developers' code and make it so that each application process has its own separate logic and databases. For example, a business using a monolithic program would find it difficult to update their software if they ever want to make it more efficient to track the company's growing number of sales.

### More questions you have / things your stuck on
- I'm not sure how we could render the search results. So far, I only have the list but can't find a way to display them on screen.
Instagram Investigation
Published: 2023-04-04 19:06:30

hello friends, I'm trying to do a social data investigation in python, I need to get the reels data, not the reel but the stats, like views, comments and publish date, I was trying to use instaloader but this code doesn't seem to work, it makes insta feel like I have been hacked. the accounts I want the info are infact public so I was wondering if you guys have an idea of how this can be avoided, or if there's a easier way to do this. 

`profile = Profile.from_username(L.context, PROFILE)

# Obtain metadata of the last 50 reels
reels = profile.get_reels()

# Create dictionary to store reels by date
reels_by_date = {}

for reel in reels:
    # Convert timestamp to datetime object
    date = datetime.fromtimestamp(reel.date)
    
    # Add reel to dictionary
    if date.date() not in reels_by_date:
        reels_by_date[date.date()] = [reel]
    else:
        reels_by_date[date.date()].append(reel)

# Print reels by date
for date, reels in reels_by_date.items():
    print(f"Reels for {date}:")
    for reel in reels:
        print(f"  - Reel {reel.shortcode} has {reel.views} views and {reel.comments} comments.")`
Understanding the typeof Operator in JavaScript
Tags: javascript, programming, beginners, makstyle119
Published: 2023-04-04 18:59:16

The ``typeof`` operator is a built-in operator in JavaScript that is used to determine the data type of a value. In this blog post, we will discuss the ``typeof`` operator in detail and provide examples of how to use it in JavaScript.

**Syntax:**

The syntax of the ``typeof`` operator is as follows:

```javascript
typeof value
```

Here, ``value`` is the value whose data type we want to determine.

**Data Types:**

The ``typeof`` operator can return one of the following [data types](https://dev.to/makstyle119/series/22448):

- ``undefined:`` This data type is used to represent a variable that has not been assigned a value.

- ``boolean:`` This data type is used to represent a true or false value.

- ``number:`` This data type is used to represent a numeric value.

- ``string:`` This data type is used to represent a text value.

- ``bigint:`` This data type is used to represent an integer value that is larger than the ``Number.MAX_SAFE_INTEGER`` value.

- ``symbol:`` This data type is used to represent a unique value that is used as an identifier.

- ``object:`` This data type is used to represent a collection of key-value pairs, arrays, functions, and other complex data structures.

**Examples:**

Let's take a look at some examples of how to use the typeof operator in JavaScript:

```javascript
console.log(typeof undefined); // logs "undefined"

console.log(typeof true); // logs "boolean"

console.log(typeof 42); // logs "number"

console.log(typeof "hello"); // logs "string"

console.log(typeof BigInt(9007199254740991)); // logs "bigint"

console.log(typeof Symbol("mySymbol")); // logs "symbol"

console.log(typeof { firstName: "John", lastName: "Doe" }); // logs "object"

console.log(typeof [1, 2, 3]); // logs "object"

console.log(typeof function() {}); // logs "function"
```

In the above examples, we have used the ``typeof`` operator to determine the data type of various values.

**Conclusion:**

The ``typeof`` operator is a powerful tool in JavaScript for determining the data type of a value. By understanding how to use the ``typeof`` operator, you can write more effective and efficient code in your JavaScript programs.
Completed my coding bootcamp..
Tags: beginners, webdev
Published: 2023-04-04 18:55:26

It has been a little more than a month since my coding bootcamp journey has come to a close. I was highly motivated for a month post-bootcamp to seek out jobs, update resumes, and really see what this time commitment added up to. Reflecting back on my time spent after the bootcamp, I know I could have worked a lot harder and added more projects, practiced more algorithms, and apply for more jobs. I just ended up shutting down, filling up my time slots with more odd jobs to get me through my rent and necessities, and all the coding I have done has slowly become a silhouette in some crevice at the back of my mind.

I have let a lot of the doubt that was creeping throughout my bootcamp experience completely overtake me, and felt like I need to branch out to a "safer" route in order to justify my actions when it came to digital literacy. 

I really want to end this post with a bit less of the "oh-woe-is-me" vibe, but am unsure on how to get out of this rut.

As of today, I have today to really structure my hour to hour, and work on being much more intentional on whatever task I have allotted time to.
1st post
Tags: webdev, beginners
Published: 2023-04-04 18:50:32

hey there dev.to community.
im [tyler michael](https://tm.etal.dev). 
welcome to my [dev.to](https://dev.to) page. [dev.to/tdev](https://dev.to/tdev) i'm just starting this page-allow me to get acquainted. i look forward to the many possibilities this already promises.  i've been searching for an online community to assist me or help me learn and grow. can't wait for this!
SwiftUI vs UIKit: Choosing the Best Framework for Your iOS App as a Beginner
Tags: programming, ios, swift, uikit
Published: 2023-04-04 18:50:31

---
title: SwiftUI vs UIKit: Choosing the Best Framework for Your iOS App as a Beginner
published: true
description: 
tags: programming, ios, swift, uikit
#cover_image:https://dev-to-uploads.s3.amazonaws.com/uploads/articles/e342rlilh8j0zybldpj2.jpeg
# Use a ratio of 100:42 for best results.
# published_at: 2023-04-04 18:32 +0000
---
As a Swift learner, you may have come across the terms SwiftUI and UIKit while exploring iOS development. Both are frameworks used to build user interfaces in iOS apps, but they differ in several ways. Here, we will discuss the benefits of using each framework and when to choose one over the other.

SwiftUI is a relatively new framework introduced in iOS 13, and it is a declarative way of building user interfaces. Declarative programming means that you describe what the interface should look like and let the framework handle the details of how it is rendered. This approach simplifies the development process by reducing the amount of code you need to write and makes it easier to create complex UIs.

One of the significant benefits of SwiftUI is that it offers a real-time preview of your app's interface as you develop it, making it easier to test and debug your code. SwiftUI also provides several layout options, such as VStack, HStack, and ZStack, enabling you to easily arrange views in different ways. Additionally, SwiftUI's use of modifiers, such as font and color, allows you to customize your app's UI without needing to create custom classes or methods.

On the other hand, UIKit is a more established framework that has been around since the first iOS release. It is an imperative way of building user interfaces, meaning you write code that creates and manipulates views directly. UIKit offers more control over the UI, allowing for more customized and advanced layouts. UIKit also provides more UI elements and functionality than SwiftUI, which may be useful for apps that require more complex interactions.

In summary, SwiftUI is ideal for creating apps with simple to medium-complexity interfaces that need to be developed quickly. It is excellent for prototyping and testing new ideas and creating simple UIs for your app. UIKit, on the other hand, is ideal for creating more complex interfaces with advanced functionality. It provides more control over the UI and is excellent for creating apps that require custom or more advanced user interactions.

In conclusion, whether you choose to use SwiftUI or UIKit depends on your app's complexity and your development goals. Both frameworks have their strengths and weaknesses, and choosing the right one will depend on your specific use case. However, as a Swift learner, it's important to understand the benefits of each framework to make an informed decision about which one to use.
switch statement
Tags: programming, tutorial, cpp, webdev
Published: 2023-04-04 17:54:42

Salom dasturchi bugun siz bilan switch nima ekanligi va qay holda ishlatiladi . Va if else statement dan nimasi bilan farq qilishi haqida gaplashamiz . 

switch - bu if ga o'xshayd . Lekin har doim ham ishlatilmiydi . switch ni o'rniga if ni ham ishlatsa bo'ladi ammo ba'zi bir holatlarda kerak bo'ladi . Shuningdek uni biror son ga tenglayotgan paytimizda ishlatishimiz kerak . Uni yozilish ko'di if dan ancha farq qiladi ammo qulay va oson . 
Buni hozir ko'd orqali ham ko'rib tushunib olishingiz mumkin . 

```
#include <iostream>
using namespace std ;

int main2( ) {

int son ;
cin >> son ;

switch(son)
  {
    case 10: cout << "Bu son 10 ga teng " ;
    break;
    case 20:
    cout << "Bu son 20 ga teng " ;
    break ;
    default:
    cout << "none" ;
    break;
    
  }
# Bu yerda biza kiritayotgan sonimiz 10 va 20 maga tengmi yo'qmi shuni tekshiradi 
  return 0 ;
}
```
# Agar teng bo'lmay qoladigan bo'lsa "none" chiqadi . 
Bu dastur huddi parol kirgizishga o'xshaydi . 
                           **Tushuntirish**
Bu yerda case - bu kalit . 
break - bu tugaganini anglatadi ya'ni o'sha bo'limni oxirida kelsa ko'd tugagan bo'ladi  . 
default - ese if statement dagi else ya'ni aks holda degan ma'noni anglatadi . 
Bu qanday ishlatilishini ko'd orqali ko'rib oling . 
Birinchi kalit 10 ;
Ikkinchi kalit 20 ;
Switch - uni ichiga if ga o'xshab shart berilmaydi . Faqat variables kiritiladi . 

Bu maqolamdan ancha narsa bilib oldingiz degan umiddaman . Keyingi maqolalargacha hayr sog' bo'ling .
Exploring the Capabilities of Apache AGE: A Comprehensive Overview of Functions and Features
Tags: apacheage, postgres, database
Published: 2023-04-04 17:52:44

Graph databases are becoming increasingly popular for data management and analysis, as they allow for efficient storage and querying of complex interconnected data. Apache AGE is one such graph database that provides a powerful and flexible platform for storing and analyzing graph data.

**Apache AGE** is an extension for PostgreSQL that enables users to leverage a graph database on top of existing relational databases. The basic principle of the project is to create a single storage that handles both the relational and graph data model so that the users can use the standard ANSI SQL along with openCypher, one of the most popular graph query languages today. Inspired by Bitnine's AgensGraph, a multi-model database fork of PostgreSQL, AGE aims to provide an efficient and flexible platform for storing and querying graph data.

**Functions of Apache AGE**

Apache AGE provides a wide range of functions for creating, managing, and querying graphs. Some of the key functions of Apache AGE are:

**Graph Storage:** Apache AGE stores graph data in a PostgreSQL database using the Apache Arrow format, which is designed for efficient processing of large datasets. This allows for fast querying and analysis of graph data.

**Querying:** Apache AGE supports a subset of the Cypher query language used in Neo4j. This allows users to write expressive and powerful queries for graph data. 

One of the core functions of Apache AGE is creating and dropping graphs. The **create_graph()** function takes a graph name as input and creates a graph with that name. If a graph with the same name already exists, an error is generated. On the other hand, the **drop_graph()** function takes the graph name as input and deletes that particular graph if it exists.

Apache AGE also provides functions for performing mathematical operations on agtype variables. For example, **agtype_add()** takes two agtype variables as input, adds them, and returns the result. Similarly, **agtype_sub()** subtracts two agtype variables, agtype_mul() multiplies two agtype variables, and agtype_eq() checks if two agtype variables are equal.

There are also functions for performing arithmetic operations on agtype variables and integers. agtype_any_add() adds an agtype variable and a small integer, while agtype_any_sub() subtracts an agtype variable and a small integer. agtype_any_mul() multiplies an agtype variable and an integer, and agtype_any_eq() checks if an agtype variable and an integer are equal.

[Official Documentation here](https://age.apache.org/age-manual/master/clauses/return.html)