teleren/devto huggingface dataset:
Merge or Rebase
Tags: git
Published: 2022-04-17 22:22:19

## Git Merge

Using `git merge` from a feature branch will allow you to have those changes become present inside of the main branch. While this method is simple, it does cause a merge commit to be created and can have negative side-effects when working on a team. Generally speaking, it is not advised to use git merge when working with a public branch. Merging is a non-destructive way to merge two branches together and the existing branches won't be changed. But as mentioned earlier, this will lead to congestion in the git log on an active main (public) branch with many other users.

## Git Rebase

Using `git rebase` first and foremost, should not be used on a public branch. Commits on the public branch that is rebased into your repo will have those commits put on top of your commits and continue from there. If you have a team working off of the main (public) branch and rebased it, there would be no way to track other upstream commits that are being made. Additionally, interactive rebasing allows for changes to the incoming changes to be made prior to the rebase taking effect.

```sh
git checkout feature
git rebase -i main
```

This will let you reorder the commits or condense a commit by using `fixup` on an item from the list. In order to rebase from a commit on the list:

```sh
git checkout feature git rebase -i HEAD~<id>
```

This will rebase from the specified commit id. If re-writing the entire feature branch is what you're looking for then the `merge-base` command will be the go-to.

```sh
git merge-base feature main
```

These methods of re-writing the commit history again should only be done within non-public branch that only you are working on, otherwise things will get a bit confusing with the other developers working on the same branch as you.
Step 1: Create a VPC and subnets
Published: 2022-04-17 21:11:23

## Create an IPv4-enabled VPC and subnets using the AWS CLI

The following example uses AWS CLI commands to create a nondefault VPC with an IPv4 CIDR block, and two publics subnets in the VPC, After you've created the VPC and subnets, you can launch two instances in the public subnets and connect to it. To begin, you must first install and configure the AWS CLI. For more information, see [Installing the AWS CLI](https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-getting-set-up.html)

You will create the following AWS resources:

- A VPC
- Two subnets
- An Internet gateway
- A route table
- Two EC2 instances
- An application Load Balancer

### Tasks

- Step 1: Create a VPC and subnets
- Step 2: Make your subnets public
- Step 3: Launch the instances into your subnet
- Step 4: Create your load balancer

---
## Step 1: Create a VPC and subnets

The first is to create a VPC and two subnets. This example uses CIDR block `10.0.0.0/16` for the VPC, but you can choose a different CIDR block. For more information, see [VPC sizing.](https://docs.aws.amazon.com/vpc/latest/userguide/configure-your-vpc.html#vpc-sizing)

### To create a VPC and subnets using the AWS CLI

- Create a VPC with a `10.0.0.0/16` CIDR block using the following [`create-vpc`](https://docs.aws.amazon.com/cli/latest/reference/ec2/create-vpc.html) command.

```bash
$ aws ec2 create-vpc --cidr-block 10.0.0.0/16 --query Vpc.VpcId --output text
```
The command returns the ID of the new VPC. The following is an example.
```bash
vpc-2f09a348
```
- Using the VPC ID from the previous step, create a subnet with a `10.0.1.0/24` CIDR block using the following [`create-subnet`](https://docs.aws.amazon.com/cli/latest/reference/ec2/create-subnet.html) command. Also, specify the Availability Zone of each of the subnets to make sure they are not the same. This is important for the process of creating the application load balancer later on.
```bash
$ aws ec2 create-subnet --availability-zone us-east-1a --vpc-id vpc-2f09a348 --cidr-block 10.0.1.0/24
```
- Create a second subnet in your VPC with a `10.0.0.0/24` CIDR block.

```bash
$ aws ec2 create-subnet --availability-zone use-east-1b --vpc-id vpc-2f09a348 --cidr-block 10.0.0.0/24
```
A suspicion for a long time about Time-Travel?
Tags: spce, welcome, discuss, help
Published: 2022-04-17 20:43:59

I have had a suspicion for a long time🤔? Please **HELP** me.

If an object goes much faster than light it will go to the past.
 
I now have a picture for example.


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

It has <mark>ball-A</mark>  in the center and <mark>ball-B</mark> Circling it. Assume that **ball-B** is orbiting **ball-A** fast at a very large interval.

In which the large **ball-A** in the middle passes from the center faster, i.e. faster than light.

Now that **ball-A** travels past the same speed, but it goes straight without changing direction.

Then that little **ball-B** comes straight to **ball-A**.

---
Now the question is! 💭

Now **ball-A** travels past, past **ball-B** is not in the opposite direction, only then comes closer. (This is the past tense of **Ball-A**)

But in real-time, the **ball-A** collides directly with the ball-B
Is coming (this is the present tense event of ball-B)

Now, will **ball-A** collide with **ball-B**?

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6nhf2q9azyqyhev882nc.gif)

What is the past like in such a conflict?
Delegates
Tags: csharp, programming, tutorial
Published: 2022-04-17 20:34:13

Delegatelar reference tipidagi data type bo'lib, funksiya uchun pointer vazifasini bajaradi. Classning ichida delegate yasaladi va classdan tashqarida yasalgan funksiyani ishlatish uchun delegateni ko'rsatkich qilib olinadi. Funksiya bilan delegate tabaka bilan sous kelishganday qachon kelishadi, qachonki ularning signaturelari bir biriga to'g'ri kelsa!

Signature nima?
Signature bu funksiyaning return tipi va parametri!

Delegat ko'rinishi:

`ACCESSMODIFIER DELEGATE RETURNTYPE NAMEOFDELEGATE(PARAMETERS);`
Misol uchun: 
`public delegate int Division(int firstNum, int secondNum);`

Note: Har qanday delegateni invoke qilib chaqirish lozim


Pastda delegatning ishlatilinishiga bir misol
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/98nddq2b8l1wl0risuwh.png)
pretzels
Tags: recipe, cooking
Published: 2022-04-17 19:46:35

---
title: pretzels
published: true
description: made pretzels
tags: recipe, cooking
cover_image: https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gvjfwfgevcnu4kgrjg0h.jpg
---

I made pretzels this weekend
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gvjfwfgevcnu4kgrjg0h.jpg)

I used this recipe
https://www.allrecipes.com/recipe/6737/mall-pretzels/

I actually followed the recipe instead of randomly changing things as I normally do. 

I did not split the dough into small enough portions though. I think next time I will split into 16 parts. I think it will yield something that looks more like a pretzel instead of what I ended up with.

This recipe also does not require the dough to be boiled and uses a dip into water with baking soda instead of a boil. So much easier setup.

They still tasted good. :)
NDA’s Yes or No?
Tags: discuss, beginners, webdev, nda
Published: 2022-04-17 19:44:30

So today I found that an app I had designed is now live on the App Store. It got me thinking, I wasn’t notified or anything ( I know they don’t have to) but out of curtesy I thought they would have mentioned that it went live with the UI designed. 

NDA’s are they worth it? I signed one for this company to do said work. I’m all honesty I fail to see the need for NDA’s and think they’re not needed 100% of the time but I also see it from the other point of view. 

What’s peoples thoughts on these and do you sign them?
Group Anagrams
Tags: leetcode, blind75, strings
Published: 2022-04-17 19:42:15

---
title:  Group Anagrams
published: true
description: 
tags: leetcode,blind75,strings
//cover_image: https://direct_url_to_image.jpg
---

###
Given an array of strings strs, group the anagrams together. You can return the answer in any order.

An Anagram is a word or phrase formed by rearranging the letters of a different word or phrase, typically using all the original letters exactly once.

```javascript
Input: strs = ["eat","tea","tan","ate","nat","bat"]
Output: [["bat"],["nat","tan"],["ate","eat","tea"]]
```

---

```javascript
var groupAnagrams = function (strs) {
    if (!strs || !strs.length) {
        return null;
    }
    let anagrams = {};
    for (let x = 0; x < strs.length; x++) {
        const sortedWord = strs[x].split('').sort().join();
        if (sortedWord in anagrams) {
            anagrams[sortedWord].push(strs[x])
        } else {
            anagrams[sortedWord] = [strs[x]];
        }
    }
    return Object.values(anagrams);
}
```
*Time Complexity* : O(w*n*log(n))
*Space Complexity* : O(wn)
Django Delete Post
Published: 2022-04-17 19:40:12

**views.py**

```python
from django.shortcuts import render, redirect,get_object_or_404
from .models import Post

def delete_view(request, id):
    obj = get_object_or_404(Post,id=id)
    if obj.author.id == request.user.id:
        if request.method == 'POST':
            obj.delete()
            return redirect("/")
        return render(request, "app/post_confirm_delete.html")
    return redirect('/')
```
**urls.py**

```python
from django.urls import path
from . import views

urlpatterns = [

    path('post/<int:id>/delete',views.delete_view,name='delete-post'),

]
```

**post_confirm.delete.html**

```html
{% extends 'app/main.html' %}
{% load crispy_forms_tags %}
{% block content %}
    <form method="POST">
        {% csrf_token %}
        <h1>Are you sure?</h1>
        <button class="btn btn-outline-danger btn-sm mt-1" type="submit" value="Yes">Yes</button>
        <a class="btn btn-outline-info btn-sm mt-1" href="{% url 'home' %}">Cancel</a>
    </form>
{% endblock %}

```
⭐ React JS - A Guide for Beginners ⭐
Tags: react, javascript, beginners, webdev
Published: 2022-04-17 19:37:42

⚝ React is one of the most popular words in the web development space
We will discuss the
✧ WHAT
✧ WHY
✧HOW
✧ & Some basics of ✪ React JS ✪

**➩  What is ReactJS?**
★ A JavaScript library is used for building user interfaces.
★ We can build Simple webpages to Complex web apps using  React
**➩ Why  ReactJS?**
★ Of course, you can build complex web apps using JavaScript, but it will be a heavy task
★ With React you can build small components where a Component is a logically  reusable part of the website
★ And These Components are logically represented in the UI

**➩ Why  ReactJS?**
★ Of course, you can build complex web apps using JavaScript, but it will be a heavy task
★ With React you can build small components where a Component is a logically  reusable part of the website
★ And These Components are logically represented in the UI

**➩Installation **
1) Install NodeJS
2) Run npx create-react-app app_name on the terminal
This will set up the React work folder for you, try editing the App.js file and run npm start
You can see the changes in real-time(a few milliseconds delay for compiling )

**➩ Creating a component**
★ A component is typically a .js or .jsx  file(s) which represents a particular section of the UI
You can write components as
⚝ Class-based Components 
⚝ Functional Components (popular & newest way )

**➩ Functional Component**
★ A functional component is  typically a JavaScript function that returns a React Element
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/010wfyolrpyy2f6uitrw.png)
➩ Minimum Concepts you should Learn in React
★ JSX  
★ Components and Props
★ States
★ Handling Events
★ Forms
★ Hooks
★ State Management
★ Conditional Rendering
and few more

**➩Additional Packages (Libraries) for your help**
★ React Router - Page Routing
★ Axios  - Working with Requests(GET,POST)
★ Redux -State management
★ CSS Libraries and UI Components
**That's it**
★ React, Itself don't provide an overall solution, the community behind react is  one of the best reason for the popularity of React
Spring - @RequestParam
Tags: spring, java, http, programming
Published: 2022-04-17 19:24:24

---
series: [Spring]
---

Simple terms, we can extract query parameters, form parameters, and even files from a request using **@RequestParam**.

Let's say that we have an endpoint /api/product that takes a query parameter called id:

```java
@GetMapping("/api/product")
@ResponseBody
public String getProduct(@RequestParam String id) {
    return "ID: " + id;
}
```

and a simple GET request would invoke getProduct:

```
http://localhost:8080/api/product?id=123
----
ID: 123
```

Both the variable name and the argument name are the same in the previous example. However, there are times when we wish they were different.

In this case we use **name** attribute

```java
@PostMapping("/api/product")
@ResponseBody
public String addProduct(@RequestParam(name = "id") String pId,
 @RequestParam String name) { 
    return "ID: " + pId + " Name: " + name;
}
```
We can also do @RequestParam(value = “id”) or just @RequestParam(“id”).

Moreover, we can configure our @RequestParam to be optional, though, with the **required** attribute:

```java
@GetMapping("/api/product")
@ResponseBody
public String getProduct(@RequestParam(required = false) String id) { 
    return "ID: " + id;
}
```

Finally, we can also have **multiple parameters** without defining their names or count by just using a Map:

```java
@PostMapping("/api/product")
@ResponseBody
public String updateProduct(@RequestParam Map<String,String> allParams) {
    return "Parameters are " + allParams.entrySet();
}
```
"Do not comment on your code, it should be self-documented". Well... I don't agree.
Tags: beginners, webdev, discuss, programming
Published: 2022-04-17 19:03:41

Since I started write my first block of code, I heard from many developers that commenting is useless and it's a type of apology to write a bad code, but after working in a big projects with a big team, the only thing I can say is: Not commenting your code is narcisist and excludes beginners, by the way, who said your code is so good and obvious as you think it is? Yeah, your mind.

During your work, probably you faced a function that you asked yourself: "_-What the hell is even that_?". Many of us experienced this situation, even with our own code after some weeks far from the project. Now, imagine if instead of you have to waste your time, searching through the houndreds of files for the right function you need to put hands on, you could have just comment your code telling the function purpose, its params and what it should return. Life could be a dream, right?

Also, we cannot asume the everybody think like us and we are being so obvious. People have different ways to analyze things, we have people that are less experienced or even have mental health conditions like, anxiety and ADDH, and that makes the process of understand some pieces of code even harder. Should we just exclude them because we can't use one single minute to comment our complexity? I think we shouldn't.

> The question is not about if you should comment your code or not, but is what you need to comment in your code and how it should be done. 

Write a clean and easily readable code is unegotiable, and you get better on this with experience, but you can also write clean and good comments, so it can be used as a reference for you and the others, and it do not make you a bad programmer, on the contrary!, It makes you a better professional,your code will be easily maintainable, plus, you're ensuring that no matter the level of who enters on your team, they'll get it faster and start working on the project, and if you have to leave your job, the devs that comes after you will be grateful and thanks you everyday before they going to bed. (okay, I'm not so sure about this last part).


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

> “Programs must be written for people to read and only incidentally for machines to execute.” - Hal Abelson - MIT Professor.


Recommended reads:
[Best practices for writing code comments](https://stackoverflow.blog/2021/12/23/best-practices-for-writing-code-comments/)

[What's the best way to document JavaScript?](https://gomakethings.com/whats-the-best-way-to-document-javascript/#:~:text=You%20should%20absolutely%20do%20it,Always%20document%20your%20code.)
Solana Anchor convert AccountInfo to Account<'info,T>
Tags: rust, anchor, solana, tutorial
Published: 2022-04-17 18:33:35

Hey there! 

In this short article I'll show you how to convert `AccountInfo` or `UncheckedAccount` to `Account`. We assume that the given account is an PDA.

For a given struct:
```rust
pub struct User {
    pub account: Pubkey,
}
```

And in our instructions we have an:
```rust
#[derive(Accounts)]
#[instruction()]
pub struct UserInstruction<'info> {
    #[account()]
    /// CHECK:
    pub user: AccountInfo<'info>,
```

```rust
pub fn get_user(ctx: Context<UserInstruction>) -> Result<()> {
    let user: Account<User> = Account::try_from(&ctx.accounts.user)?;
    // do something here
    Ok(())
}
```
Best practices for one-time passwords
Tags: security, otp, passwordless
Published: 2022-11-01 06:28:55

---
title: Best practices for one-time passwords
published: true
date: 2022-04-17 18:30:01 UTC
tags: security,OTP,passwordless
canonical_url: https://mojoauth.com/blog/best-practices-for-otp-authentication/
---

Signing users is a process to prove that the person trying to sign in is the same person who originally registered on your application, and many applications are using passwords to do so. However, traditional, user-created, static, or fixed passwords are known to be vulnerable. There are many traps waiting for your users and application. To maintain security, business owners have started to consider switching from passwords to OTPs. What is an OTP An OTP or One-time Password is a password that is valid for a short period of time and can be used only once to verify a single login session or transaction.

<a href="https://mojoauth.com/blog/best-practices-for-otp-authentication/">Read On</a>
BERT Architecture
Tags: bert, encoders, nlp, nlu
Published: 2022-04-17 18:13:02

BERT radically changed the NLP landscape when it was created by google. With bert, you can have a single model that is trained on a large unlabelled dataset to achieve State-of-the-Art results on 11 different NLP based use cases. Google’s TransformerXL, OpenAI’s GPT-2, XLNet, ERNIE2.0, RoBERTa have evolved over BERT.

“BERT Acronym stands for Bidirectional Encoder Representations from Transformers. BERT can be used for pertaining bidirectional representations from unlableled text  using conditioning on the joint left and right context.

The BERT architecture is based on  Transformers. Two variants available are listed below:
* BERT Base: 12 layers (transformer blocks), 12 attention heads, and 110 million parameters
* BERT Large: 24 layers (transformer blocks), 16 attention heads and, 340 million parameters

Bert's Transformer layers are Encoder-only blocks.
Leetcode problems with solution in JavaScript.
Tags: javascript, webdev, algorithms, computerscience
Published: 2022-04-17 18:09:37

I have created this **[repo ](https://github.com/iamzeeali/JavaScript-DSA-Programs)**where I will be adding **[Leetcode ](https://leetcode.com/)**easy to hard problems with solution in JavaScript on daily basis. You can fork/watch this repo.
Consider starring the repo if you find it useful and _[follow ](https://github.com/iamzeeali)_me on Github for more FAANG level  DSA contents in JavaScript.
📣 [ 21 April ] Rapyd's Hack the Galaxy series is almost here. Million in prizes. 🚀
Tags: fintech, hackthegalaxy, developercommunities, hackathon
Published: 2022-04-17 17:54:00

https://community.rapyd.net/t/build-the-universes-best-checkout-rapyd-hack-the-galaxy-series/1560

**THE MISSION**
70% of online carts are abandoned and businesses are leaving $260 billion dollars a year on the table because of bad checkout experiences.

This is an astronomical opportunity for developers who can build a better checkout.

We're challenging developers to use [Rapyd's Hosted Checkout Toolkit](https://docs.rapyd.net/build-with-rapyd/docs/checkout-toolkit) to **rethink checkout** and we're giving away **really big prizes** to make it happen.

From embedding checkout into ads and invoices to adding checkout to new applications and creating better experiences –  assemble your team (max 4) and see if you have the right stuff.

**WHAT'S IN IT FOR YOU?**
Cash prizes are just the beginning. Winners also get to present their ideas at **Rapyd Demo Days** for a chance to win an even bigger prize!

Rapyd Hack the Galaxy is a series of hackathons and challenges that give fintech developers the competitive pitch to showcase your work/code (it is your code and IP btw) to win a really amazing prize. – plus dozens of other prizes throughout the year. 

Get your team. Get to coding. And get ready to Hack the Galaxy!

P.S. Registration site will go live **21 April** but you can always explore our [developer community](https://community.rapyd.net) to learn more about the challenge.
Updating node to the latest version
Tags: linux, webdev, node, javascript
Published: 2022-04-17 17:48:16

At times, when you install node using the command
`sudo apt-get install nodejs`, a lower version is installed.
E.g when you type
 `nodejs --version`
It shows
`0.10.26`

Therefore, to update node to the latest stable version, use n module from npm. The following commands help.
```
sudo npm cache clean -f
sudo npm install -g n
sudo n stable
```
Sample Issue template and Pull request template for Github/Gitlab
Published: 2022-04-17 17:42:22

---
title: Sample Issue template and Pull request template for Github/Gitlab
published: true
description: Issue template and pull request template for Github/Gitlab
tags: 
//cover_image: https://direct_url_to_image.jpg
---

Here's a slightly modified issue template and pull request template I came up with. Based on [Issue and Pull Request Template Generator](https://www.talater.com/open-source-templates/#/).

Pull request template
```markdown
*(Provide a general summary of the issue in the Title above)*

## Detailed Description
*(Provide a detailed description of the change or addition you are proposing)*<br><br>

## Context
*(Why is this change important to you? How would you use it?<br>
How can it benefit other users?)*<br><br>

## Possible Implementation
*(Not obligatory, but suggest an idea for implementing addition or change)*<br><br>

## Your Environment
*(Include as many relevant details about the environment you experienced the bug in)*
* Version used:
* Environment name and version (e.g. Chrome 39, node.js 5.4):
* Operating System and version (desktop or mobile):
* Link to your project:
```

Issue template
```markdown
*(Provide a general summary of the issue in the Title above)*

## Description
*(Provide a more detailed introduction to the issue itself, and why you consider it to be a bug)*<br><br>

## Expected Behavior
*(Tell us what should happen)*<br><br>

## Actual Behavior
*(Tell us what happens instead)*<br><br>

## Possible Fix
*(Not obligatory, but suggest a fix or reason for the bug)*<br><br>

## Steps to Reproduce
*(Provide a link to a live example, or an unambiguous set of steps to<br>
reproduce this bug. Include code to reproduce, if relevant)*<br>
1. Step 1
2. Step 2
3.
4.

## Context
*(How has this bug affected you? What were you trying to accomplish?)*<br><br>

## Your Environment
*(Include as many relevant details about the environment you experienced the bug in)*
* Version used:
* Environment name and version (e.g. Chrome 39, node.js 5.4):
* Operating System and version (desktop or mobile):
* Link to your project:
```