teleren/devto huggingface dataset:
First Complete Rails App
Tags: ruby, rails
Published: 2021-05-31 06:24:57

Having learned from my last few projects, I made sure this time to spend a few moments planning rather than jumping straight into coding. And it saved me a ton of headaches! I drew out my models with each of their attributes and illustrated their relationships. And it was through this process that I realized some initial model ideas weren't going to work out. Eventually I came up with the project idea for allowing users to create galleries where they can save their favorite paintings.

Once each those models were fully concocted, I was ready to start building the rails app.

Another thing I've learned from my past projects is the importance of seed data. It makes testing the app SOOOOO much easier! Previously, I would build the seed data manually. But a friend put me on to the faker gem. And it made generating random attributes so much easier. And way more fun too! Now I've got random StarWars characters as my users and random book titles as the titles of my paintings.

Onto the developing!

Most of the process was pretty smooth. I've grown comfortable with the basic MVC structure and so, building out the foundation of the app was relatively seamless. But once I started building the form views, I challenged myself to use the new form_with actionview helper method rather than the form_for or form_tag helpers that I originally learned. Knowing how the latter two worked definitely helped understand the former, but it did take some time and research to learn how to properly use it.

The fields_for form was also challenging. I hadn't used it much before and it took some time to learn how the data was captured in params. And then also how to submit those params datapoints to a nested model. After many quick trial and errors, I slowly examined the full process and realized that the issue I had was a missing setter method for the nested model. Once I build that new instance method into the model, it was smooth sailing again.

In the end, it was a success :) It sure had its fair share of challenges, but overcoming each hump is such a gratifying feeling!
Authentication and  Authorization using AccessTokens - RefreshTokens | Part 1
Tags: javascript, jwt, authentication, authorization
Published: 2021-05-31 06:24:44

## Authentication VS Authorization
Many people mismatch these terms, but they are two different things.

###Authentication
This is a process of validating the user that sends the request to the server is the same as the one that logged in. This is generally done by checking the password, OTP, biometrics, etc.

###Authorization
This is a process of giving permission and access to a specific resource or function. This is generally done by using tokens sent from auth server to the client.

**I will be using MERN (MongoDB, Express, React, NodeJS) stack to show the implementation of authentication and authorization**

#Authentication
So, the first step of authentication is to encrypt the the user credentials or resources which are very much private and important, like passwords.

Let's say we have a userSchema using mongoose.
We cannot just store plain passwords in the database, so for hashing, we can use `crypto`. It is an inbuilt module that comes with `nodeJS`.
* First of all, we made two methods 
 1. To authenticate or check if the password is correct or not.
 2. To hash the password.
* Then we made a virtual schema to take the plain password and encrypt it using the securePassword method we made and store to store it in database.
* After that, we can import the `authenticate` method to `/signin` route to check for the password that user passed.
```javascript
const mongoose = require("mongoose");
const { createHmac } = require("crypto");

const userSchema = mongoose.Schema(
  {
    name: {
      type: String,
      required: true,
    },
    email: {
      type: String,
      required: true,
      unique: true,
    },
    encrypted_password: {
      type: String,
      required: true,
    },
  },
  { timeStamps: true }
);

userSchema
  .virtual("password")
  .set(function (password) {
    this._password = password;
    this.encrypted_password = this.securePassword(password);
  })
  .get(function () {
    return _password;
  });

userSchema.methods = {
  securePassword: function (plainPassword) {
    if (!plainPassword) {
      return;
    }
    try {
      const secret = "anySecretYouWant";
      return createHmac("sha256", secret).update(plainPassword).digest("hex");
    } catch (error) {
      return;
    }
  },
  authenticate: function (plainPassword) {
    return this.encrypted_password === this.securePassword(plainPassword);
  },
};

module.exports = mongoose.model("User", userSchema);
```
* So basically all the passwords of the user will be stored in a hashed or encrypted format so that none of us can read it and use it directly. It is done by passing a salt (any random long string ) to mix the characters in the password. 
* To decrypt those passwords, we need only that particular salt string.
* As salt strings can decrypt the passwords, hence it is stored in Node environment files (.env files). 

Now the user is authenticated, next move on to authorization part.

*cover image : https://www.progress.com/*
[News] PolarDB for PostgreSQL Paxos Announces Open Source
Tags: opensource, database, postgres, cloudnative
Published: 2021-05-31 06:22:24

Recently we open sourced PolarDB for PostgreSQL Paxos, and it was announced on "Alibaba Cloud Developer Conference" in Beijing for the first time by Dr. Feifei Li the day before yesterday. 
[Watch On YouTube >](https://youtu.be/FHXqmSMjN64)
[![](https://img.alicdn.com/imgextra/i1/O1CN01sV6wxe268dW0vbs6J_!!6000000007617-0-tps-2876-1498.jpg)](https://youtu.be/FHXqmSMjN64" type="video/mp4)

If you want to download the source code, contribute or get documentations about this new open source project, please save the link below. And don't forget to give a star to support and follow.

【GitHub - PolarDB for PostgreSQL】
[Check Now >](https://github.com/alibaba/PolarDB-for-PostgreSQL)

【Always Free PolarDB】
[Apply Now >](https://www.alibabacloud.com/product/polardb#J_5764451150)
[![](https://img.alicdn.com/imgextra/i2/O1CN01nuTVt41VJ2jUhpIEc_!!6000000002631-2-tps-1872-944.png)](https://www.alibabacloud.com/product/polardb#J_5764451150)
LeetCode 1169. Invalid Transactions
(javascript solution)
Tags: algorithms, javascript
Published: 2021-05-31 06:17:26

###Description:
A transaction is possibly invalid if:

the amount exceeds $1000, or;
if it occurs within (and including) 60 minutes of another transaction with the same name in a different city.
You are given an array of strings transaction where transactions[i] consists of comma-separated values representing the name, time (in minutes), amount, and city of the transaction.

Return a list of transactions that are possibly invalid. You may return the answer in any order.

###Solution:
Time Complexity : O(n^2)
Space Complexity: O(n)

```javascript
const isInvalid = (transaction, map) => {
  const [name, time, amount, city] = transaction.split(',')

  if (amount > 1000) return true

  const prevTrans = map[name]

  for (const trans of prevTrans) {
    if (city !== trans.city && Math.abs(time - trans.time) <= 60) return true
  }

    return false
}

const invalidTransactions = transactions => {
  const invalid = []
  const map = {}
  
  // Sepearate transactions by name
  for (const trans of transactions) {
    const [name, time, amount, city] = trans.split(',')
    
    // Create a list of transactions under each name
    if (name in map) map[name].push({ time, city })
    else map[name] = [{ time, city }]
  }
  
  // Validate transactions
  for (const trans of transactions) {    
    if (isInvalid(trans, map)) invalid.push(trans)
  }
  
  return invalid
};
```
PHP Variables
Published: 2021-05-31 06:00:43

Type-1
Local variable or user defined variable.
Syntax- $VARIABLE_NAME
Ex - $demo, $cust_name,$pic1 etc
------------------------------
Type-2
Global variables or pre-defined variables
a) $GLOBAL => To create a php global variable.

b) $_POST => To access value from a HTML form using 'post' method.

c) $_GET => To access value from a HTML form using 'get' method.

d) $_REQUEST => To access value from a HTML form using any method.

e) $_SERVER => To get data related to server.

f) $_SESSION => To create session storage.

g) $_COOKIE => To create a local storage.

h) $_ENV => To get or update data in PHP environment.

i. $_FILES => To access file details from a HTML form and upload to the server.



#php #webdev #development
Case Study: KeyWest Networks improves developer productivity by 25%
Tags: cicd, devops, observability, casestudy
Published: 2021-05-31 05:58:40

*Original Post: https://www.opsera.io/blog/keywest-networks-improves-developer-productivity-by-25*

[Watch the video to see how Opsera helped KeyWest networks achieve a 25% increase in productivity](https://marketing.opsera.io/contact-demo-request-0?hs_preview=KgOEhzwr-35466066206)

KeyWest Networks is a wireless products company, providing point-to-point and multipoint network solutions for smart city initiations and the service provider market.

KeyWest Networks was started by an industry veteran who has over 20 years of engineering expertise in broadband and wireless products.

#The Challenge
KeyWest Networks customizes its products for all the major infrastructure clients and the process requires a high velocity of software releases. For each deployment, KeyWest Networks has a dedicated release manager responsible for the program management, coordination, and success of both the process and deployment.

Everyday, the release manager's responsibilities include reviewing code quality scans, ensuring the build and deployments are successful, and performing a sanity test before the release is handed to the QA team for further quality checks.

Being a start-up and providing a dedicated resource to each product within each vertical, the overhead quickly begins to cumulate. KeyWest Networks was in need of an automated solution to provide leverage across all teams involved within the deployment process.

> "With Opsera's end-to-end automation, we were able to increase the productivity of our developers and get visibility into all our pipelines and releases." - Kishore Gandham, Founder & CEO of KeyWest Networks.

#The Solution
With Opsera, KeyWest Networks designed, configured, and built their first CI/CD pipeline within a single day. Opsera’s Declarative Pipelines enabled KeyWest Networks to automate their complete release process, including:  

* Building
* Testing
* Code deployment

Today, KeyWest Networks has all of its project pipelines and logs viewable from a single dashboard by using Opsera.
>“Now, I can see the development and quality metrics of individual contributors”. - Kishore Gandham, Founder & CEO of KeyWest Networks

#The Result
KeyWest Networks has benefited from the time they are saving daily with the help of Opsera. With the automation of the KeyWest Network's complex release process, the productivity of developers increased by 25%. Opsera Unified Insights has also enabled end-to-end visibility into multiple project pipelines.

Opsera successfully provided:

* Increase in developer productivity by 25%.
* End-to-end visibility of logs and pipelines.
* Metrics and dashboards by individual developer and release.
How to build a real-world application with React and Node (Foal)
Tags: react, typescript, javascript, node
Published: 2021-05-31 05:57:01

---
title: How to build a real-world application with React and Node (Foal)
published: true
description: This tutorial shows how to build a real-world application with React and Node.
tags: react, typescript, javascript, nodejs
cover_image: https://dev-to-uploads.s3.amazonaws.com/uploads/articles/914c8mqrrwztg32uqqsg.png
---

This tutorial shows how to build a real-world application with React and Foal. It assumes that you have already read the guide *[How to build a Simple To-Do List](https://foalts.org/docs/tutorials/simple-todo-list/1-installation)* and that you have a basic knowledge of React and Node.

In this tutorial, you will learn to:
- establish a connection with MySQL or Postgres,
- provide credentials to the application in a secure way,
- create models with many-to-one relations,
- use a query builder,
- generate an interface to test your API (Swagger UI),
- fix same-origin policy errors,
- allow users to log in and register with an email and a password,
- authenticate users on the frontend and the backend,
- manage access control,
- protect against CSRF attacks,
- upload and save files,
- allow users to connect with a social provider (Google),
- and build the application for production.

> *For the sake of simplicity, the front-end application will not use a state management library (such as [redux](https://redux.js.org/)). But you can of course add one if you wish. The logic to follow will remain mainly the same.*

## Application Overview

The application you will create is a social website where users can share interesting links to tutorials. All posts will be public, so no authentication will be required to view them. Publishing a post, on the other hand, will require the creation of an account.

*Feed page*
![Feed page](https://foalts.org/assets/images/feed-cafaeeea52a28612177a5a70e6c1cf12.png)

*Profile page*
![Profile page](https://foalts.org/assets/images/profile-d12409506e2332f8a2ef8391801ef85d.png)

*Registration and login pages*
![Registration and login pages](https://foalts.org/assets/images/sign-up-and-log-in-ea14815a2f012118eef7e058bd93c500.png)

## Get Started

Let's get started. First of all, create a new directory.

```bash
mkdir foal-react-tuto
```

Generate the backend appplication.

```bash
cd foal-react-tuto
npm install -g @foal/cli
foal createapp backend-app
```

And then start the development server.

```bash
cd backend-app
npm run develop
```

Go to [http://localhost:3001](http://localhost:3001) in your browser. You should see the *Welcome on board* message.

The rest of the tutorial is [here](https://foalts.org/docs/tutorials/real-world-example-with-react/2-database-set-up).
Create a Digital Clock Using Python - Beginner Python Project(11)
Tags: python, opensource, programming, beginners
Published: 2021-05-31 05:30:52

Hello,
Another article on the [Python Projects for Beginner Series](https://dev.to/larymak/series/12034) 💻. 
> A beginner looking for an Open Source to contribute to: Check out this [REPO](https://github.com/larymak/Python-project-Scripts) and add your <mark>CONTRIBUTION</mark> and give it a Star⭐  

In this article we will see how to create a digital clock using python and the tkinter library. 
#### What we will learn:
- How to use the tkinter module to create a GUI
- How to write a basic python function
- How to use the time module
- How to write a simple if statement 

#### Lets Get Started: 
Watch Video Below:
[![Digital Clock](http://i3.ytimg.com/vi/i1TYbklLAPk/maxresdefault.jpg)](https://www.youtube.com/watch?v=i1TYbklLAPk&t) 
Check Source code [HERE](https://github.com/larymak/Python-project-Scripts) 

Connect With me at [Twitter](https://twitter.com/larymak1) | [Insta](https://www.instagram.com/nextgencoders/) | [YouTube](https://www.youtube.com/channel/UCrT1ARRZfLOuf6nc_97eXEg) | [LinkedIn](https://www.linkedin.com/in/hillary-nyakundi-3a64b11ab/) | [GitHub](https://github.com/larymak)

Enjoy Coding ❤
VSCode-Your IP Address in a Glance
Tags: vscode, programming, devjournal, webdev
Published: 2021-05-31 05:28:43

As a developer:

💤 Are you bored of opening up the command prompt to get the IP Address?

🔥 Is it frustrating to repeat the flow if you lose the internet connection?

🔎 Were you looking for a cross-platform solution that would save your precious time?

👉🏼 You've landed on the right spot, here's the [solution](https://levelup.gitconnected.com/vscode-your-ip-address-in-a-glance-4992d22b5c8e).
Day 4: Class vs. Instance
Tags: javascript
Published: 2021-05-31 05:12:01

    process.stdin.resume();
    process.stdin.setEncoding('ascii');
    var input_stdin = "";
    var input_stdin_array = "";
    var input_currentline = 0;

    process.stdin.on('data', function (data) {
     input_stdin += data;
    });

    process.stdin.on('end', function () {
    input_stdin_array = input_stdin.split("\n");
    main();    
    });

      function readLine() {
      return input_stdin_array[input_currentline++];
     }

    function Person(initialAge){
    // Add some more code to run some checks on initialAge
    var age = initialAge;
    this.amIOld=function(){
    // Do some computations in here and print out the correct 
      statement to the console
      if(age < 13 && age > -1 )
        console.log("You are young.");
       
        else if(age < 18 && age > 12) 
            console.log("You are a teenager.");
        
        else if (age >17)
            console.log("You are old.");
        
        else {
            console.log("Age is not valid, setting age to 0.");
            age = 0;
            this.amIOld();
        }    
      };
      this.yearPasses=function(){
          // Increment the age of the person in here
          age++;
      };
      }

     function main() {

     var T=parseInt(readLine());
     for(i=0;i<T;i++){
     var age=parseInt(readLine());
     var p=new Person(age);
      p.amIOld();
       for(j=0;j<3;j++){
        p.yearPasses();
        
     }
     p.amIOld();
     console.log("");   
     }
     }
Here is how I found my path as a software engineer
Tags: blog, career, thoughts
Published: 2021-05-31 04:58:57

As a teenager in the 90s, I was living in a small and cold town in France. I was doing not much of my life: going to school, playing video games, watching TV, ... My family’s revenue was pretty modest, so I never had the latest fancy game consoles or toys. On top of that, I was not very confident, and I was going on a bad path in terms of weight which accentuated my lack of self-confidence.

Early high school, both my parents went through depression. My mom got sick and had to stay in bed for months. It hit me too. I failed my year. Life was pretty pointless at the time. Everything was falling apart, and I couldn’t do anything. I felt lonely and powerless. I felt I was not belonging here.

Then I got fed up with the situation, and I decided to change that. At that time the Internet has been my greatest companion. This window on the world allowed me to get in touch with people from all around the world. I started to be part of communities and bounded with several people remotely. This brought me to think that I could be part of that world. And that I started to feel that I wanted to contribute. This is where I decided to try to make websites for the communities I was part of.

At the time, the easiest to make websites was with PHP. And this is what I just did. I started my journey by documenting myself. I gathered information and good resources. On a second step, I printed tutorials and documentation on paper, and I read them carefully. I tried to read everything, line by line, to understand the essence of each concept. But I still left some difficult concepts aside like object-oriented programming (OOP). On a third step, I started to experiment with all the theoretical knowledge I acquired.

The last and final step that really got me into the rabbit hole of programming has been to contribute to the world. I made websites for online communities I participated in. And I started to get something amazing: recognition. I was not just a random name, a random loser. I was the programmer or the webmaster.

Sometimes in life, you feel like you don’t belong here. Sometimes in life, you feel lost and the world around you is pulling you down even more. But don't forget, there are so many exciting things, and whenever you find one thing you really enjoy you should try to stick to it. It can be programming like me, it can be dancing, it can be writing, it can be anything. Go through the obstacles. Pull yourself up. Be the best of yourself. Contribute to that world. At some point, you will get recognition, and you will understand that you belong here. You just hadn’t realized it yet.

-------------- 

Photo by <a href="https://unsplash.com/@stephenleo1982?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText">Stephen Leonardi</a> on <a href="https://unsplash.com/s/photos/path?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText">Unsplash</a>
Nhà Cái VN88
Published: 2021-05-31 04:58:00

@VN88nhacai là nhà cái VN88( /m/01lq3 ) trực tuyến uy tín nhất Việt Nam, tặng tiền trải nghiệm người chơi và nhiều chương trình khuyến mãi thành viên mới. Chúng tôi có đa dạng những dịch vụ trực tiếp bóng đá, trò chơi casino trực tuyến hấp dẫn, game bài, bắn cá.

Email: vninfo@vn88.com

Hotline: (+84) 705908837

Địa chỉ: 56 Nguyễn Văn Săng, P. Tân Sơn Nhì, Q. Tân Phú, TPHCM 

Website: https://vn88.com.co/
Laravel 8 Multiple User Comments CRUD With hasMany Eloquent Relationship Example

Tags: laravel, programming, php, tutorial
Published: 2021-05-31 04:44:04

Hi Artisan

Today i will explain you example tutorial of Laravel 8 Multiple User Comments CRUD With hasMany Eloquent Relationship Example. you will learn . I will give simple example for how to use and implement hasMany Eloquent relationship using multiple user comment and as you can delete this comment as you wish.i will fully explain how to work this tutorial follow my all step

Here i will give you full example for Multiple user comments Crud operation using has many relationship. So let's visually perceive bellow step by step:

more..
https://codingtracker.blogspot.com/2021/05/laravel-8-multiple-user-comments-crud.html
Matrix Factorization Approaches to Topic Modeling
Tags: python, machinelearning, nlp, techtalks
Published: 2021-05-31 04:42:22

At the IWD Event organized by Google Developer Groups(GDG) & Women Tech Makers(WTM), Casablanca, I presented a tutorial on Matrix Factorization approaches to Topic Modeling.

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/iyzi9tf19d44udm49g4b.jpg)

Here's the link to the entire event.My talk starts at around 4:01:00.

{% youtube iUGiwmE2hwo %}


Post Cover Image: Photo by <a href="https://unsplash.com/@keilahoetzel?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText">Keila Hötzel</a> on <a href="https://unsplash.com/s/photos/drafts?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText">Unsplash</a>
Use Redux Thunk along with Axios service in React (CRA)
Tags: react, redux, thunk, axios
Published: 2021-05-31 04:23:39

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/iw7esljuf5aaj2h5ibuf.png)

### Load data from API using Axios and store data in Redux Thunk in React (create-react-app)

**YouTube** - https://youtu.be/a6uC2EauAZ4
**Source code** - https://github.com/mehtanilay10/React-Redux-Thunks-Axios-Hooks

**Timestamps:**
0:00:00​ Intro
0:00:13​ What is Redux?
0:03:15​ First Look at Final Project
0:04:03​ Subscribe channel
0:04:25​ Creating App with Redux & Axios
0:05:33​ Adding .env file
0:05:58​ Creating Axios Instance
0:06:54​ Create Service
0:07:48​ Create ActionTypes & Actions
0:10:20 Create Initial State & Reducer
0:13:18 Create Thunk
0:14:56 Create Root Reducer
0:16:09 Create Store & Provider
0:19:03 Use in component
0:22:15 Run app & solve issues
0:24:18 Conclusion