teleren/devto huggingface dataset:
Ruby On Rails : Encryption With BCrypt
Tags: ruby, rails, beginners, tutorial
Published: 2023-03-06 07:51:21

Keeping user data safe is crucial when developing web applications. In Ruby on Rails, bcrypt is a built-in gem that lets developers secure their applications by encrypting passwords. In this blog, we'll talk about how to use bcrypt in Ruby on Rails to beef up your app's security.

## What is bcrypt?

Bcrypt is a password hashing function that uses a salted key derivation function to secure passwords. It's designed to be slow and computationally expensive, making it difficult for attackers to perform brute-force attacks on hashed passwords. Bcrypt is widely used in web applications to store and authenticate user passwords.

## Using Bcrypt in Ruby on Rails

To get started with bcrypt, you need to add the bcrypt gem to your Rails application by adding this line to your Gemfile:

```
gem 'bcrypt'
```

After adding the bcrypt gem to your application, you can use it to hash user passwords by calling the bcrypt method in your Rails model. For example, say you have a User model with an email and password field. To hash the password before saving it to the database, you can use this code:

```
class User < ApplicationRecord
  has_secure_password
end
```

The has_secure_password method automatically hashes and stores the password in the database when a new user is created.

To authenticate users, you can use the authenticate method provided by the has_secure_password method. For example, say you have a SessionsController that handles user authentication. You can authenticate a user by checking their email and password against the hashed password in the database like so:

```
class SessionsController < ApplicationController
  def create
    user = User.find_by(email: params[:email])
    if user && user.authenticate(params[:password])
      # User is authenticated
    else
      # Authentication failed
    end
  end
end
```

The authenticate method checks the provided password against the hashed password stored in the database. If the passwords match, the user is authenticated.

## Conclusion

Using bcrypt is a powerful way to secure your Ruby on Rails web application. It protects your users' data from attackers and reduces the risk of data breaches. The has_secure_password method provided by Rails makes it easy to use bcrypt in your application. This lets you focus on other aspects of your app while keeping your users' data safe.
[DEV: PHP] Cryptocurrency transferring from selected addresses
Tags: php, beginners, bitcoin, webdev
Published: 2023-03-06 07:40:06

Cryptocurrencies are pseudo-anonymous means of payment. On the one hand, you do not need to pass verification to create a wallet, and on the other hand, you can determine the source of funds from the transaction chain. Exchangers do not want to deal with “dirty” coins, so they conduct KYC processes and check each transaction. 

A crypto wallet contains many addresses. Usually, when transferring, several coins are combined into one, and the change is returned to a new address. If you have a p2p exchange, a trading platform, a telegram bot, or a service related to fiat currency withdrawal, then you need to have isolated transactions within the same address. 

Such a function is unique since no other processing (at the time of this writing) has a similar solution, i. e. does not provide the client with the choice of coins when paying. 

Test wallet: `tbtc-bde1cfc70297e4ff7068334b25986819`
Test Transfer_key: `hyl1aQkd5vwdzT1uExgUCOXOcekUg4Yc`

**Code example: **

```
<?php
  $WalletID = "tbtc-bde1cfc70297e4ff7068334b25986819";
  
  $json_data = '{"transfer_key": "hyl1aQkd5vwdzT1uExgUCOXOcekUg4Yc",
   "addresses": ["2N919xVyDyutwTX87zg1NBQWJQWcFcpVVUf"],
   "destinations": [{"address": "2N4obeEuEidHmuXLCLvWeA4tH9FhB8W8EyD", "amount": 40000}]}';
  
  $api_base = "https://apirone.com/api/v2/wallets/" . $WalletID . "/transfer";

  $curl = curl_init($api_base);
  curl_setopt($curl, CURLOPT_HTTPHEADER, array("Content-Type: application/json"));
  curl_setopt($curl, CURLOPT_POST, 1);
  curl_setopt($curl, CURLOPT_POSTFIELDS, $json_data);
  curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
  $http_status_code = curl_getinfo($curl, CURLINFO_HTTP_CODE);
  $response = curl_exec($curl);
  curl_close($curl);

  $decoded = json_decode($response, true);
  echo "Transaction created: " . $decoded["created"] . "<br>";
  echo "Transaction hash: " . $decoded["txs"]["0"] . "<br>";
  echo "Total amount: " . $decoded["total"] . " Satoshies";
?>
```

Where _addresses_ is an array of one or more addresses from which coins will be taken for the transaction. 
The recipients of _destinations_ can be from 1 to 255, they are also listed in an array. 

## Business logic can be as followed:
Payment is sent to you, and it is confirmed on the network 
You check it for purity, for example, in the Crystal Blockchain service 
In case of insufficient purity of the origin of funds, they are to be returned to the sender without affecting other clients 

In the amount parameter, you can specify the value “100%”, so the network commission will be subtracted from the amount and the balance of the indicated address(es) will be zero.
HAVING Clause
Tags: opengauss
Published: 2023-03-06 07:38:19

The **HAVING** clause filters data after grouping.

The **WHERE** clause sets conditions on selected columns, while the **HAVING** clause sets conditions on groups created by the **GROUP BY** clause.

**Syntax**

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

**Parameter Description**
**· HAVING clause**

Selects special groups by working with the **GROUP BY** clause. The **HAVING** clause compares some attributes of groups with a constant. Only groups that match the logical expression in the **HAVING** clause are extracted.

**Examples**
In the following example, data is grouped based on the value of **c_first_name** which is less than 2.

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

The result is as follows:

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

In the following example, data is grouped based on the value of **c_first_name** which is greater than 1.

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

The result is as follows:

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jbu401rf5jp34383cn0n.png)
GROUP BY Clause
Tags: opengauss
Published: 2023-03-06 07:33:41

The **GROUP BY** clause is used together with the SELECT statement to group the same data. You can group one or more columns, but the columns to be grouped must exist.

**Syntax**

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

**Parameter Description**
**· GROUP BY clause**

Groups the query results based on the values of one or more columns. The query results with the same value are in the same group.

The **GROUP BY** clause is placed after the **WHRER** clause and before the **ORDER BY** clause in the SELECT statement.

**Examples**
The **customer_t1** table contains duplicate values of **c_first_name**. The duplicate values of **c_first_name** are in the same group, and the sum of the values of **Amount** is calculated.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3tsjh5ekx2yygc11q56r.png)
The Importance of Humility in Interviewing
Tags: interview, interviewing, interviewer
Published: 2023-03-06 07:33:11

Interviewing is a crucial process in any hiring process, and it is essential that the interviewer possesses certain characteristics that will lead to success. After interviewing numerous developers over the past years, I have come to the conclusion that humility is the most important characteristic an interviewer can possess.

The interview process can create a power dynamic where the interviewer is in a position of authority, while the interviewee is put in a vulnerable position. This dynamic can cause the interviewer to become overly confident and less open to ideas, while causing the interviewee to feel insecure and unable to fully demonstrate their potential.

To counteract this dynamic, it is crucial for the interviewer to remain humble throughout the process. This humility will allow the interviewer to be open to the interviewee’s ideas and thought processes, enabling them to assess the candidate’s potential as accurately as possible.

One effective way to cultivate humility is for the interviewer to assume that the interviewee is senior to them. By adopting this mindset, the interviewer places themselves in a position of learning and humility, which will allow them to truly listen to the interviewee’s responses.

Assuming that the interviewee is senior to the interviewer also has the added benefit of disarming any feelings of insecurity the interviewee may have. By demonstrating respect and a willingness to learn from the interviewee, the interviewer creates an environment where the interviewee can feel comfortable and confident in showcasing their skills and expertise.

In conclusion, humility is a crucial characteristic for any interviewer to possess. By remaining humble throughout the interview process, the interviewer can create an environment that is conducive to showcasing the interviewee’s full potential. By assuming the interviewee is senior to them, the interviewer can create a power dynamic that encourages open communication and mutual respect, leading to a successful hiring process.
DISTINCT
Tags: opengauss
Published: 2023-03-06 07:24:41

The **DISTINCT** keyword is used together with the SELECT statement to remove duplicate records and obtain only unique records.

When there are multiple duplicate records in a table, the **DISTINCT** keyword is used to obtain only unique records instead of duplicate records.

**Syntax**

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

**Parameter Description**

**DISTINCT [ ON ( expression [, …] ) ]**

Removes all duplicate rows from the result set of the SELECT statement so that each row in the result set is unique.

Retains only the first row in the set of rows that have the same result computed on the given expression.

**Examples**

Insert the following data into the **customer_t1** table:

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

The current data is as follows:

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

Query all values of c_first_name in the customer_t1 table. There are two Lily and three Grace.

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

Use the **DISTINCT** keyword in the SELECT statement. The result shows that duplicate data has been deleted.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/byzfywly55ufdwqyv4pa.png)
ORDER BY Clause
Tags: opengauss
Published: 2023-03-06 07:19:15

The **ORDER BY** clause sorts the data in one or more columns retrieved by the SELECT statement in ascending (**ASC**) or descending (**DESC**) order.

**Syntax**

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

**Parameter Description**
**· ORDER BY clause**

Sorts data retrieved by the SELECT statement in descending or ascending order. If the **ORDER BY** expression contains multiple columns:

· If two columns are equal according to the leftmost expression, they are compared according to the next expression and so on.
· If they are equal according to all specified expressions, they are returned in an implementation-dependent order.

**Examples**
Sort the result in ascending order based on the value of **c_customer_sk**.

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

· Sort the result in descending order based on the value of **c_customer_sk**.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ulbsk6gp3lepc3ti4fmm.png)
ZOD is Typescript for Runtime - Less code but more Reliable
Tags: webdev, react, javascript, typescript
Published: 2023-03-06 07:13:49

[Zod](https://github.com/colinhacks/zod) is a schema validator, it means you give your object to it and it checks that if it is exactly the same as the interface that you defined or not, and if it isn't, it gives you an error!

What does it mean? It means that you don't need to use `if-elses` anymore like before, e.g.

```js
if(name=== null || name==="")
...
if(name.length>5 && name.length<10)
...
if(number && number !==0 || number >0 ...)
```

It does all this by itself only with the following command:

```js
z.safeParse(formdata);
```


### more examples: 

[IP check example](https://zod.dev/?id=ip-addresses)


# Introduction ~7min 👌

To get to know it better, watch this video from WebDevelopSimplified:

[7min ZOD introduction](https://youtu.be/9UVPk0Ulm6U)

# Learn it completely ~30 min 🤩✨

To learn it completely, and use it to save alot of time from yourself and also shipping reliable code watch this video

[ZOD in 30 min](https://youtu.be/L6BE-U3oy80)



-------------------------------------------
### VSCode Pro for Frontend developers: 🎖️
[ZPack](https://marketplace.visualstudio.com/items?itemName=SeyyedKhandon.zpack)
WHERE Clause
Tags: opengauss
Published: 2023-03-06 07:00:27

When you need to query data from a table based on specified conditions, you can add a WHERE clause to the SELECT statement to filter out unnecessary data. The WHERE clause forms an expression for row selection and is used to obtain data based on specified conditions. Values in the table are returned only when the specified conditions are met.

**Syntax**

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

**Parameter Description**

**· WHERE clause**

The **WHERE** clause forms an expression for row selection to narrow down the query range of the SELECT statement. Comparison operators or logical operators, such as >, <, =, LIKE, or NOT, can be used in the **WHERE** clause.

**· condition**

**condition** indicates any expression that returns a value of Boolean type. Rows that do not meet this condition will not be retrieved.

**Examples**

Use logical operators to read data from the customer_t1 table.

**· AND**

Locate the row where the value of **c_customer_id** is hello and that of **c_customer_sk** is 3869.

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

**· OR**

Locate the row where the value of **c_customer_sk** is greater than 6985 or that of **c_customer_id** is hello.

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

**· NOT NULL**

Locate the row where the value of **c_last_name** is not empty in **the customer_t1 table**.

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

**· BETWEEN**

Locate the row where the value of **c_customer_sk** is between 4000 and**9000**.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/og1u0emwv2o9tmq9js8f.png)
6 DIMENSI BERPIKIR UNTUK MAKSIMALKAN OTAK KAMU
Tags: webdev, javascript, beginners, tutorial
Published: 2023-03-06 06:45:19


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

Rahasia aku dalam Knowledge Management😛Yuk belajar bareng serta diskusi dikolom komentar, serta di save biar ga lupa💬😝

🌱Follow : @appardana
💭Stay Young, Be Innovative and Keep Learning

#Content #Tips #Trick #Knwoledge #Management #Java #PHP #Javascript #Phyton #Web #Skills #IT #Backend #Developer #Roadmap #SelfImprovement #Growth #Aditria #Pardana #AditriaPardana #appardana #iAppTech ⚛️💻


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ozjuvxqknyc4e714wj6j.jpg)
Validations in Rails
Published: 2023-03-06 06:45:00


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

**What are Validations in Ruby on Rails?**

Validations are a set of rules that are defined for the model's attributes to ensure that data is entered into the application in the correct format and meets certain criteria. In Ruby on Rails, validations are used to ensure that the data entered into the database is valid and meets certain conditions. These validations can be defined on a per-attribute basis, or they can be defined for an entire model.

Types of Validations

There are several types of validations that can be used in Ruby on Rails:

**Presence Validation**: This validation ensures that a particular attribute is not blank or nil.

**Length Validation**: This validation ensures that a particular attribute has a minimum and/or maximum length.

**Format Validation**: This validation ensures that a particular attribute matches a particular format, such as a phone number or email address.

**Numericality Validation**: This validation ensures that a particular attribute is a number.

**Inclusion Validation**: This validation ensures that a particular attribute is included in a specific set of values.

**Uniqueness Validation**: This validation ensures that a particular attribute is unique within the model.

Using Validations in Ruby on Rails

To use validations in Ruby on Rails, you need to define them in your model. Here's an example of how to use validations to ensure that a user's username is present and unique:

```
class User < ApplicationRecord
  validates :username, uniqueness: true
end


```

In the above example, we've added a validation for the username attribute of the User model. The uniqueness validation ensures that each username is unique in the database.

If a user tries to create a new record with a username that already exists, the validation will fail and the record won't be saved to the database. Instead, the user will see an error message indicating that the username must be unique.

You can also customize the error message by adding the message option, like this:

```
class User < ApplicationRecord
  validates :username, uniqueness: { message: "has already been taken" }
end


```

In the above example, we've customized the error messages for each validation to provide more specific feedback to the user.

**Conclusion**

Validations are an essential part of any web application, as they help ensure that the data entered into the application is valid and meets certain criteria. In Ruby on Rails, validations can be defined on a per-attribute basis or for an entire model, and there are several types of validations that can be used to ensure data is entered correctly. By using validations effectively in your Ruby on Rails applications, you can improve the user experience and reduce the risk of errors and data inconsistencies.
Установка nvm (NodeJS) на linux
Tags: node, linux
Published: 2023-03-06 06:38:06

Чтобы установить nodejs сначала установим nvm, для удобной установки разных версий ноды

```
wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh | bash
```

После обновляем .bashrc командой
```
source ~/.bashrc
```
перезапустите консоль.
и теперь у вас работает nvm, чтобы установить самую новую версию ноды просто напишите

```
nvm install node
```
А чтобы установить определенную версию сначала посмотрим доступные версии ноды

Эта команда выведет все версии, будьте готовы к очень длинному списку
```
nvm ls-remote
```
А чтобы посмотреть все подверсии к примеру 18 ноды то пишем

```
nvm ls-remote 18
```
Тогда он покажет все 18 версии ноды

К примеру нам нужна v18.14.2 (Latest LTS: Hydrogen)
Пишем просто
```
nvm install 18.14.2
```
и готово, теперь у вас стоит нода версии 18.14.2
Uber shifts to the cloud, state of Kubernetes in 2023, AI and low-code/no-code - Amnic Monthly Newsletter
Tags: cloud, kubernetes, devops, ai
Published: 2023-03-06 06:22:53

In this month’s Building Blocks, join us as we unpack Uber’s
choice to move from on-prem to cloud, the state of Kubernetes in 2023, and AI's impact on the low-code/no-code landscape. Also, check out our monthly recommendations.

https://blog.amnic.com/building-blocks-march-2023/


Looking to stay informed on all major news and trends in the developer community? Subscribe to our newsletter today.
https://blog.amnic.com/
The Five Best Home and Interior Design Software Programs
Tags: productivity, technology, homeandinteriordeisgns
Published: 2023-03-06 06:11:56

Are you in the process of moving out to your new house? Want to extend your kitchen? Or to change the interior of your lounge? Do you want to design your house according to your comfort and style but don’t have its tools? Well, we all secretly want to turn our homes into extraordinary places. That’s why we have come up with the five **[best home and interior design software programs](https://gadgetsandaccessories.com/the-five-best-home-and-interior-design-software-programs/)**.

Dreaming to have a stylish room, bathroom, lounge, and house is more fun now. Interior software programs help you to visualize how your new home will look. This software uses simple tools to make a layout according to your likes.

We have reviewed tons of interior design software programs for you to make your task of searching easy. We have created a list of the five best home and interior design software programs so you can select easily according to your requirements (features that suit your needs.) So, let’s dive into the plethora of information.

**

## Easyhome Homestyler Software

**
Dream big and relax when you have Easyhome Homestyler software. Budget-friendly and easy-to-use software help you to visualize more creative designs for your home. The staff is very keen to help you out is designing.

We recommend this software for beginners as it is easy to use. The beginners can also look at the gallery where millions of designs are available for Homestyle users. Moreover, Homestyler offers not only interior design but also exterior designing.