teleren/devto huggingface dataset:
Create Vertex in Apache AGE
Tags: apacheage, graphdatabase
Published: 2023-02-26 19:30:03

In Apache AGE, data is stored in edges and vertices. In this blog, I will tell you how you can create vertex and how you can store data in it.
Firstly, in vertex we have vertex name, formally we call it label.
Secondly, we can also store data related to the vertex in it. The data is stored in key value pair.
**Gerneral Form**
`SELECT * 
FROM cypher('graph_name', $$
    CREATE (:LabelName {PropertyKey: 'PropertyValue', ...})
$$) as (anyName agtype);`


**Create single vertex**
`SELECT * 
FROM cypher('graph_name', $$
    CREATE (n)
$$) as (v agtype);`


**Create a vertex with a label**
`SELECT * 
FROM cypher('graph_name', $$
    CREATE (:Person)
$$) as (v agtype);`


**Create vertex and add labels and properties**
`SELECT * 
FROM cypher('graph_name', $$
    CREATE (:Person {name: 'Andres', title: 'Developer'})
$$) as (v agtype);`


**Return newly created node**
`SELECT * 
FROM cypher('graph_name', $$
    CREATE (a {name: 'Andres'})
    RETURN a
$$) as (a agtype);`


For more details visit: https://age.apache.org/overview/

**AGE Github Link:** https://github.com/apache/age

**AGE Viewer Github Link:** https://github.com/apache/age-viewer
i18Next's default locale and next build command
Tags: nextjs, i18next, i18n, default
Published: 2023-02-26 19:27:04

Hi there. 

As i18Next has no native way to force the locale as a folder prefix we all use this "default" hack. By doing so "default" is redirected via middleware to "en" (if thats your default lang) to ensure the folder structure stays the same for all the languages. 

Fair enough - feels a little bit hacky and not native  - but why not - it does its job. 

My problem is now that `next build` tries to create pages for "default" as well. How do I suppress this error creating step?


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




Thanks
Just learning...
Tags: javascript, programming, beginners, opensource
Published: 2023-02-26 19:21:59

Hello I am 13 years old boy, and I am now learning web development with JS and HTML_, and CSS, I just want any advice at this and thank you.
Also just to know I am already a very fast learner, and I learned the basics of programming in python, and it makes a lot of sense to me.
Duplication over Abstraction in Unit Tests
Tags: programming, testing, codenewbie
Published: 2023-02-26 19:09:17

---
title: Duplication over Abstraction in Unit Tests
description: In your production code, favor abstraction over duplication. In your unit tests, favor duplication over abstraction.
tags: programming, testing, codenewbie
canonical_url: https://davidadamojr.com/duplication-over-abstraction-in-unit-tests/
---
One of the first things you learn as a software engineer is to avoid code duplication whenever possible. But this same learned aversion to duplication is what causes many software engineers to fill their unit tests with logic and abstractions that cause the tests to become unreliable. 

![Scale from duplication to abstraction](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gexwj52mrf0dslggfa6d.png)

On a scale from duplication to abstraction, your code and its corresponding unit tests should almost never be on the same level. Unit tests are not the place for clever logic, abstractions, and code reuse. Logic and abstractions eventually cause your unit tests to become fragile and difficult to understand. If you're starting to feel like your unit tests need unit tests, then you're probably doing it wrong.

In your production code, it often makes sense to treat duplication like an enemy to be vanquished everywhere it rears its ugly head. But you're much better off treating duplication like a friend in your unit tests. In other words, while you favor abstraction over duplication in your code, you should simultaneously favor duplication over abstraction in your unit tests.
Week 7 Writeup
Published: 2023-02-26 19:02:36

**What is confusing about platforms?** 
Although all content is on the same web platform, much of it doesn't use the platform, it uses frameworks and build tools that pop out of the woodwork and get superseded a few years later by another.

**How could web components and VanillaJS standards be taught in a way that is more approachable?** 
Having web components and vanilla JS be the bulk of the content on the platform that is the web instead of these other frameworks that abstract from the platform heavily.

**What did you find easiest to work with on 1st stab? (You don't have to say web components, this is an honest take, if it was Vue cool, but justify it)** Web components, as mentioned in the question following this one, it clicked with me instantly and seemed a lot simpler than some of the other options we toyed around with. Maybe this is because it's more simple? I don't know.

**Think back on the tooling. What parts were confusing? What clicked with you immediately?** 
Some parts I found confusing were the repository structures, file locations and formats, and the procedures used to render the HTML and include the script for the component in the main webpage. One thing that clicked immediately was open-wcs simple repo structure and concise, easy to understand files.

**What additional readings did you have to do in order to make sense of things.**
- https://elisehe.in/2021/08/22/using-the-platform
Creating Custom RxJS Operators
Tags: rxjs, angular, frontend, javascript
Published: 2023-02-26 18:50:04

Since [Angular](https://angular.io/) has become a popular framework, RxJS is becoming increasingly popular. In this post I would like to write about a very nice feature in this fantastic library: **custom operators**!

A few months ago I have been trying to keep the chaining logic more readable in my RxJS code. It's very easy to write confusing code when we don't pay attention to how the operators are being composed.

In this post, I would like to show how to write an RxJS code using custom operators to keep the logic readable and easier to maintain over time.

## How to create a custom operator? 🤔

It's very easy, really!

An RxJS operator is just a function that receives an [observable](https://rxjs.dev/guide/observable "observable") as a parameter and returns a new [observable](https://rxjs.dev/guide/observable "observable").

For instance:

![custom-rxjs-operators-1](https://www.henriquecustodia.dev/images/uploads/creating-custom-rxjs-operators-1.png)

Generally, it's common to create factory operators (operators that return another function), because it'll become more intuitive for the developers to understand the operators' chain.

Here's an example of a factory operator:

![custom-rxjs-operators-2](https://www.henriquecustodia.dev/images/uploads/creating-custom-rxjs-operators-2.png)

Now, let's see some examples of how to use custom operators to create more readable code!

## Creating an operator to filter odd numbers 🦄

It's simple to filter odd numbers, isn't it?

But creating a custom operator to name it'll become your code cleaner and more obvious. The readability will improve.

Let's see the code:

![custom-rxjs-operators-3](https://www.henriquecustodia.dev/images/uploads/creating-custom-rxjs-operators-3.png)

## Creating an operator to search by text 🕵🏾‍♂️

Searching by text into an array might be easy, but generally doing it with RxJS turns the code a bit hard to understand over time.

But, before using a custom operator, let's see how the code would look when not using custom operators:

![custom-rxjs-operators-5](https://www.henriquecustodia.dev/images/uploads/creating-custom-rxjs-operators-5.png)

It's not impossible to understand the code logic, but it's difficult to get what it's doing when taking a quick look.

Because of that, naming the code logic is important. 

That said, let's refactor the code above using custom operators: 

![custom-rxjs-operators-6](https://www.henriquecustodia.dev/images/uploads/creating-custom-rxjs-operators-6.png)

`toLowerCase` and `searchByText` are operators that can be used to reuse the code, and it's much easier to understand what they're doing. 

## Conclusion  🥷

Using custom operators can help us to make the code more readable and easier to reuse across the projects. 

It was a quick post about custom operators. That feature is helping me a lot to enforce the reusability in my Angular projects. 

Thank you for reading!  ✨
WHAT IS UNISWAP
Tags: webdev, web3, blockchain
Published: 2023-02-26 18:48:48

**Uniswap**

Uniswap is a decentralized token exchange protocol built on Ethereum that allows the direct swapping of tokens without the need to use a centralized exchange.

On Uniswap, you can simply swap your tokens directly from your wallet without depositing tokens to an exchange, place an order on the order book, and then withdraw the swapped tokens as it is in the case of Centralized Exchanges.


All you need to do is send your tokens from your wallet to Uniswap’s smart contract address, you will receive your desired token in return in your wallet. There is no order book and the token exchange rate is determined algorithmically. All this is achieved via liquidity pools and the automated market maker mechanism.


**Liquidity Pools**

Liquidity pools are token reserves that sit on Uniswap’s smart contracts and are available for users to exchange tokens with. For example, using the ETHDAI trading pair with 100 ETH and 20,000 DAI in the liquidity reserves, a user that wants to buy ETH using DAI may send 202.02 DAI to the Uniswap smart contract to get 1 ETH in return. Once the swap has taken place, the liquidity pool is left with 99 ETH and 20,202.02 DAI.
If someone buys ETH using DAI, ETH will be removed from the liquidity pool while DAI will be added into the liquidity pool.


What is Automated Market Maker Mechanism

Prices of assets in the pool are algorithmically determined using the Automated Market Maker (AMM) algorithm. AMM works by maintaining a Constant Product based on the amount of liquidity on both sides of the pool.


**How to get a token added on Uniswap?** 

Unlike centralized exchanges, Uniswap as a decentralized exchange does not have a team or gatekeepers to evaluate and decide on which tokens to list. Instead, any ERC-20 token can be listed on Uniswap by anyone and be traded as long as liquidity exists for the given pair. All a user needs to do is interact with the platform to register the new token and a new market will be initialized for this token.
Know about Decentralized Exchanges
Tags: webdev, web3, defi, blockchain
Published: 2023-02-26 18:35:21

  While Centralized Exchanges (CEXs) have plenty of liquidity and allow large trades to happen, it still carries many risks because users do not hold custody of their assets in exchanges, due to the introduction of Decentralized Finance, Decentralized exchanges were developed.

**What Decentralized Exchange  (Dex)**: A Dex uses Smart contracts and on-chain transactions to reduce or eliminate the need for an intermediary.
Dex includes, Uniswap, Kyber Network, Curve Finance, dYdX, and SushiSwap.

**Types of DEX**?

There are two types of DEXs: • Order book-based DEXs • Liquidity pool-based DEXs.

 
**Order book-based DEXs**:  These  types  DEXs like dYdX and Deversifi   operate similarly to CEXs where users can set buy and sell orders at either their chosen limit prices or at market prices

**liquidity pool DEXs:** 

liquidity pool DEXs such as Uniswap and Balancer let users become the market makers by providing liquidity to a pair or pool of assets. Users deposit their assets and become liquidity providers, earning a small fee for each swap transaction performed for that particular pool.


**Differences between Centralized Exchanges and Decentralized Exchanges**



The main difference between the two is that for CEXs, assets for the trade would be
held on the exchanges’ wallets, whereas for DEXs, assets for the trade would be held in users’ wallets.


**Limitations of Dex**

**Lower liquidity**:

The majority of crypto trade still takes place in centralized exchanges. Historically, order books on CEXs have been deeper when compared to DEXs, and traders can thus get better prices when making trades on CEXs.


Limited features Centralized exchanges include many advanced trading features such as limit orders, stop-loss orders, trailing stops, and so on. Most of these trading features are not available on DEXs.
 Some DEXs now offer limit orders, allowing for a better trading experience. However, a growing number of DEXs are looking to introduce these advanced trading features to compete more effectively against CEXs.


**Blockchain Interoperability** Most DEXs today only allow traders to swap tokens within the same blockchain ecosystem. Ethereum-based DEXs, for example, only allow users to trade Ethereum and ERC-20 tokens. It does not permit traders to trade tokens issued on other blockchains like Polkadot or Cosmos. CEXs allows users to trade tokens on various blockchains easily. There are efforts to build cross-chain DEXs, and in the future, trading tokens across multiple blockchains on a DEX will be possible.
Use Bundler in a Ruby script
Tags: ruby, beginners, todayilearned
Published: 2023-02-26 18:31:42

Sometimes when we write a Ruby script we need to use external gems to integrate with a third party API, or to facilitate the connection to a database. 

For example, if you want to add coloring to produce messages

```ruby
require 'rainbow'

puts Rainbow("My very important message in red").red
```

But when deploying this script, how can we ensure that these dependencies will be present? And will they be installed in the expected version for which our script has been tested?

What to do then? Creating a gem seems too heavy for our script, and it's not advisable to expect users to do the installation by themselves (it's okay for a gem but for a script that would start having 4-5 of them it's a lot).

Fortunately, Bundler is there for us, in fact, the installer offers a module that we can include in our script and that offers all the features of a *Gemfile* but to define our gems inside the script.

```ruby
require 'bundler/inline'

gemfile do
  source 'https://rubygems.org'

  gem 'rainbow', '~> 3.0.0'
end

puts Rainbow("My very important message in red").red
```

Thus, when the script is launched, Bundler will check that the declared gems are installed, download them if necessary, and then load them automatically for use.
Using & configuring zitadel for integration with AWS
Tags: aws, lambda, zitade, clientcredentials
Published: 2023-02-26 18:04:20

## Introduction

This blog post is primarily related to setting up zitadel cloud account for the post - where I will be explaining the JWT authorizer.

I will skip the obvious setting up a zitadel account part, setting up of zitadel account is very straightforward and simple. Thanks to their great documentation on their site and great discussions over their discord server.

## Configuration for client_credentials grant & Jwt type access token

1. Setup a service user.
![Setup a service user](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wtjismmv9mruy3d5nk3r.png)
2. Fill in the user details and **access token type JWT**
![access token type JWT](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4is7u79w25306n3okh6i.png)
3. Generate Client credentials
![Generate Client credentials](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yi6cg3x2qrtnnbo2qbam.png)
4. Copy the client credentials
![Call the token endpoint as below](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/x2i6azk77z2r0op7xqbm.png)
5. Call the token endpoint as below
![Call the token endpoint as below](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/je01tcthsypybh8jcsio.png)

---

Please feel free to reach out to me over Linkedin [here](https://www.linkedin.com/in/krnbr/) for further questions, doubts or suggestions.
Fix Cloud run resource locations constraint error (Error 412)
Tags: gcp, googlecloud, docker
Published: 2023-02-26 17:58:50


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

You have a project that you would like to deploy on Google Cloud using Cloud run, but due to some organisation's restrictions, you get an error like below:

> ERROR: (gcloud.run.deploy) HTTPError 412: '$region' violates constraint 'constraints/gcpresourceLocations'

This error could come from the fact that you should use a low carbon region, and not all Google Cloud regions satisfy this condition. 
Even if you pass the region as an argument, you have some steps of the deployment process that you don't manage because they are automated. So, you have to do it another way.
In this article, I will explain step by step how to solve that problem.

**

## 1 - Create the repository yourself 

**

If we use the default gcloud run command, It will create a repository in the artifact registry, and use it to create the image to deploy.
That image is by default multiregion and it includes prohibited regions. So, you have to build the image yourself manually and specify it as an argument in the command. To do so, you have to create a repository in the Artifact Registry as shown below:

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

When creating the repository, make sure to select a low carbon region. Once the repository is created, open it and copy its path.

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


**

## 2 - Let's build the image

**

At this step, you should have created a repository. Now, let's build the image. Paste the command below in your cloud shell at the same level with your Dockerfile:
```
gcloud builds submit --region=$region --gcs-source-staging-dir=$path_to_the_cloud_storage_bucket --tag $path_to_the_repo/image_name:version

``` 

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

The image was successfully built! Copy the image URL, you will need it at the next step.

**

## 3 - Deploy your image

**
Now your image is created, let's deploy it on **Cloud Run**. Paste the command below in your cloud shell

```
gcloud run deploy $service_name --image $image_url:tag
``` 
Now you should have your app link in your cloud shell!

Hope this article will help 🚀
Week-7 Follow Up as a New Developer
Published: 2023-02-26 17:49:21

One thing that is particularly confusing to me about platforms is how many different moving parts there are in them, especially with the everchanging use of various libraries. It seems that some instances such as React can often make things appear to be more overcomplicated than they actually are/need to be, when trying to enhance performance. Another thing that is confusing about platforms is the fact that they are constantly being updated, leaving some people confused about different terminologies and use cases. Integrating these already complex platforms, with other everchanging platforms, can cause quite a mess if not done properly.

One way that web components and VanillaJS standards could be taught in a way that is more approachable is by rather than just throwing students into a web development environment like VSCode, allow them to experiment in alternatives like CodePen as it is more friendly to syntax errors, etc. It is also very easy for them to see the changes they are making live, which can truly help understanding the languages (at least it did for me). Another way that could make it more approachable is by showing students live examples of coding, explaining why each and every step is being taken.. 

One thing that I found the easiest to work with on my first stab was actually implementing the CSS into the HTML. While first figuring out the HTML layout was a little confusing for me, being able to tie the CSS into specific portions of HTML and see changes happen live on CodePen just made sense to me and was a good learning experience.

One thing in tooling that was particularly confusing to me was setting up things outside of CodePen. I had never used VSCode before, so it took me sometime to finally understand the layout of it, I also did not realize that there was a built in terminal (even though it was staring me in the face) right away, so seeing this really allowed me to speed up my command line use. Another thing that confused me at first was Github, what a fork was, why we needed to do it, and how to actually get it into VSCode. I didn't really know the point of Github, but discovering it really opened my eyes into how the Web Development world functions effectively, instead of downloading ZIPS like we did in my previous courses. One thing that clicked with me immediately was how Github Desktop worked, although it is very simple, I found it very easy to navigate as well as a big time saver when it comes to transitioning Github operations into VSCode.

Although I did not use many readings, as I learn better from Visuals, one type of reading I used was ChatGPT. I used ChatGPT to get quick answers to some sort of syntaxes I did not get when looking up examples of code on other websites such as StackOverflow. Outside of this I really found YouTube Videos to be helpful, as well as some W3 workshops. I discovered that the internet often can provide solutions to many specific coding issues, although they may not be exactly identical.