teleren/devto huggingface dataset:
WHY YOU NEED TO SET TOKENS IN WEB APPS FOR AUTHENTICATION IN DJANGO REST AND NOT DJANGO ( 𝘚𝘐𝘔𝘗𝘓𝘐𝘍𝘐𝘌𝘋 )
Tags: django, python, programming, react
Published: 2022-10-06 01:14:00



𝐍𝐎𝐑𝐌𝐀𝐋 𝐃𝐉𝐀𝐍𝐆𝐎 :
All the frontend pages are rendered by the backend, so since the backend knows that the frontend pages are rendered by it, it can easily pass a user object into the template page. The template language can allow you to test for logged in status with 'if user.is_authenticated' right inside the frontend( the html). So it’s like a piece of the backend is sent to the frontend in a format that can be accessed by a special template language e,g Jinja2, not a general format like JSON(take note) as it renders on the user’s browser.

The fact that a piece of the backend is sent with the frontend already puts in a level of security as it would be a bit difficult to tap into the data and change 'is_authenticated' to True. It’s like the frontend is ‘pampered’ here!

𝐃𝐉𝐀𝐍𝐆𝐎 𝐑𝐄𝐒𝐓:
Naa…No pampering here! The frontend is decoupled from the backend! By decoupled, I just mean the rendering work is handled by the frontend as in the case of Javascript frameworks like React which have the concept of 'state'(I'll talk about it someday). The frontend pages are manufactured/handled by React. The Backend just brings the raw data.

The frontend says, ‘Yeah just drop it there, I’ll do the rendering myself. I’m old enough now!’ This attitude is why the backend cannot just trust the frontend by dropping the same 'is_authenticated' attribute. Nope! Instead, it gives a token, which is a very long alphanumeric set of characters that cannot easily be forged. This token will allow the frontend to access data in the backend. The backend can identify the user with the token, even the expiry date info is embedded. You might say, the attitude of the frontend does not deserve this strict behaviour by the backend, but remember, that the pages are no longer brought by the backend.

The 'is_authenticated' attribute if it were used, would come as JSON format as opposed to the special format in normal Django. JSON is like a format many programming languages see as a meeting point. So imagine putting in something as simple as {is_authenticated : true} . From the frontend, using a simple API tool, one can easily tap in and send as JSON, {is_authenticated : true} as an attribute back to the backend and the backend will open its doors wide if that is the pass.
JSON Config Parser
Tags: rust, opensource, codenewbie, testing
Published: 2022-10-06 00:52:01

This week I decided to work on Eakam's `rost_gen` repository again because of the difficulty it gave me last time. This time I thought I would be prepared for it, and boy howdy, was that not the case. This time in fact I had much more difficulty because of the numerous changes they have made since the last cooperative lab.

**NEW FEATURE**
A user could run the SSG by doing either of the following:

```
# Option 1: use command line arguments:
ssg --input ./site --output ./build --stylesheet https://cdn.jsdelivr.net/npm/water.css@2/out/water.css --lang fr

# Option 2: use a config file
ssg --config ./ssg-config.json
```

The config file option means we can have a much shorter command, and instead store our options in a file.

##Writing & Testing code in RUST
After I forked the project, it took a while to write the code due to the new addition of the `clap` crate that was being used in Eakam's repository. So it was in a technical basis trying to relearn how options were selected and parsed. After wrapping my head around the command parsing I created a struct and function to handle config files.

```
use std::io::BufReader;

extern crate serde_with;
extern crate serde_json;
extern crate serde;
use serde::{Deserialize, Serialize};
#[derive(Debug, Deserialize, Serialize)]
#[serde_with::skip_serializing_none]
struct Config{
    input: Option<String>,
    output: Option<String>,
    lang: Option<String>
}
```
I used `serde` in order to parse the JSON into the created struct and then it would call the struct and parse the details into the `handle_conversion()` function which was already made. 
 
But this was before I was made aware that `Option<String>` could not be parsed as a normal string. So I had to find a way to convert it, which I did but it took a while.

##Using Git
It was an interesting experience trying to figure out how to remotely use git. Though it was a lot more simple than I anticipated. I now know how to test pull requests code without clicking my mouse.

##Final Thoughts
It was not easy to work with an unfamiliar language yet, working in open source helps you a lot in terms of learning new rules. I have learnt, the syntax is different in every language. The technique and ideas to build are the same.
🔴 Build Instagram Clone using Django, HTML & CSS - Tutorial
Tags: instagramclone, django, webdev, javascript
Published: 2022-10-06 00:44:12

Hello guys, my name is Destiny and welcome to my **first Post here.** In today's post we'd be Learning how to build an **Instagram Clone using Django, HTML & CSS**. I Just Love to build these to practice my Django Skills and teach you guys too. I made a tutorial video to help beginners to improve there **Django** skills to build **real world projects**.

Watch Complete Tutorial Here
https://youtu.be/qw5ZEvylQBA

{% embed https://www.youtube.com/embed/qw5ZEvylQBA %}


➜ Github: https://github.com/desphixs/Instagram-Clone

Note: Subscribe to My YouTube Channel, I also Build a Netfix Clone using Django, you should check it out.
Constants and Variables
Published: 2022-10-05 23:22:10

Hello world!
The journey today revealed that constants are similar to variables. A constant is a variable that always starts with a capital letter. They are mostly used for variables that aren't going to change.
Example
SHOE=sandal
SHOE is the constant

Also, the discovery revealed that embedded Ruby tags exists. Embedded Ruby tags look like this:
<%=  =%>
<% %>
¿Todos debemos usar un entorno multi-nube o no?
Tags: webdev, cloud, spanish
Published: 2022-10-05 23:18:38

La nube múltiple se está volviendo más popular entre las empresas, pero no está exenta de desafíos. 

Una estrategia de nubes múltiples puede ser costosa y difícil de administrar, y es importante comprender los pros y los contras antes de embarcarse en ese viaje. 

Recalcando lo bueno tebemos: la nube múltiple puede brindarle acceso a una gama más amplia de servicios y tecnologías.

Por otro lado como desventaja es que puede ser muy lento realizar cambios en múltiples proveedores y necesitará un personal capacitado que esté familiarizado con cada plataforma en la nube.

Es importante sopesar cuidadosamente los pros y los contras antes de decidir si la nube múltiple es adecuada para su organización.

---


**Los pros que puedes sacar:**

- Tener muchos servicios disponibles
- Aprovechar tecnologías de primer nivel

**junto con los cons que debes afrontar**

- Un costo más alto
- buscar un personal capacitado en cada cloud provider.
- Lentísimo proceso de cambio
y la lista puede seguir

En definitiva, no estoy diciendo que NO se deba hacer, si no que NO es para todo el mundo.
Si tienes una startup un proceso de cambio tiene que ser rápido, y si estás en múltiples proveedores no podrás hacerlo.

No te lleves tu contenedor a múltiples cloud y digas ¡Mirame mamá estoy en la nube!

La nube es más que eso, y tu que piensas, 
¿El multi-cloud es para todos?



---
¿Te pareció interesante?
¿Te gustaría que estemos en contacto? 

![Hector Fernandez](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bkns07waoe3ixr3uncej.jpg)
Héctor Fernández
AWS Community Builder (Uruguay)
https://hector.builders/
Day 630 : Reset
Tags: hiphop, code, coding, lifelongdev
Published: 2022-10-05 23:06:04

_liner notes_:
- Professional : Got up pretty early to sit in on a talk prep session and give some feedback. Then I went back to sleep. I woke up and got to work. Had another meeting, reached out to some folks to get updates on some things. Started working on some projects. Then got sidetracked trying to get a receipt for a flight I took to attach to my expense report. Apparently my credit card report wasn't enough. It took WAY TOO long to try and find out how to get it. Looked through the airline's app, website and ended up calling a phone number, put on hold, transferred and only to be told that I need to fill out a form and basically make a complaint. Terrible.

- Personal : Last night, decided that I may be able to use the Web Components I'm making for work for a project that I'm working on.  I think by testing it in a real world project, it will help me see how it is to use it and what features to add. I'll be able to test things out before making them public. Tried to figure out how I could possible include a separate library while at the same time made it optional. Played a little with an AI text to image library called Stable Diffusion. Pretty cool stuff. May look into it for an upcoming project. Also got caught up with "Kevin Can F*CK Himself". Show is turning out to be really good. Got a bunch of packages and orders in as well for things that I ran out of before my trips.

![Looking up at the blue sky with some white clouds through the leaves of palm trees in Waikīkī, HI, United States](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/q0gi8d7l91swni24fu7z.png)

So, I got my phone back today that I sent out to get the screen protectors fixed. Looks very nice, but I think they factory reset my phone for some reason. So I've been restoring the data and stuff from my other phone to the one I got back. It was taking a while and it doesn't have all the apps. I intentionally only had certain apps on this one phone. So I'll have to download them and log in again. This is the reason I didn't wipe my phone when I sent it in for repair. So, I'll be doing that and maybe watch "She Hulk" while I work on it and maybe try to get a function working on the Web Components for my side project.

Have a great night!

peace piece
Dwane / conshus
https://dwane.io / https://HIPHOPandCODE.com
{% youtube ApXUkW5oqY8 %}
Collision detection in 2D game development with JavaScript
Tags: javascript, gamedev, webdev
Published: 2022-10-05 21:43:33

**Collision detection** also known as **hit testing** is simply determining when two objects come in **contact** with one another.

The collision of objects underlies most game experiences and user-interfaces.
Baseball bats collide with balls, zombies bump into walls, and Mario lands on platforms and stomps turtles. 

![Mario lands on platforms and stomps turtles](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4vfg121qchih9ic08eaf.png)

####A General Formula For Collision Detection
Detect the positions of each object, compare and calculate if they're overlapping.

####Instances
Examples of collision between two objects:-
1. POINT/POINT
2. CIRCLE/CIRCLE
3. RECTANGLE/RECTANGLE

1. **Point/Point**
The easiest collision to test is between two points, to test if they're colliding, we simply check if their X and Y co-ordinates are the same! (i.e if their positions are same).

```
if (x1 == x2 && y1 == y2) {
  // Points are in the same place: collision
}
else {
// Not colliding
}
```
2. **Circle ⭕ / Circle ⭕**

Imagine you have two circles, each with their own radius. They are placed with a distance between them. The circles would overlap if the **distance** is **smaller** than the **sum** of the **radius** of both circles.

![Calculating the distance between 2 circles](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/j743txz8xkhlt4xhsacn.png)

Calculating the distance between the center of the two circles requires us to remember middle school math and the Pythagorean Theorem:
`Opp² + Adj² = Hyp²` simply `∆x² + ∆y² = d²`;
`d = √(∆x² + ∆y²)`;

Translated to code, it looks like this:

```
d = Math.sqrt((∆x*∆x) + (∆y*∆y))
```
So, if this distance is smaller than or equal to the radius of circle-a plus radius of circle-b, the circles overlap or touch. This principle is used in the next function:

```
const circlesCollide = (x1, y1, r1, x2, y2, r2) => {

    // Calculate the distance between the two circles
    let squareDistance = (x1-x2)*(x1-x2) + (y1-y2)*(y1-y2);

    // When the distance is smaller or equal to the sum
    // of the two radius, the circles touch or overlap
    return squareDistance <= ((r1 + r2) * (r1 + r2))
}
```
As you can see, the formula is tweaked a bit. Multiplication is much faster than getting the square root with 
`Math.sqrt()` so the distance is calculated without getting the root and the sum of the radii is multiplied by itself. The outcome stays the same, but the performance is better.
Class methods vs instance methods, arguments(),return, and constants
Published: 2022-10-05 21:29:41


## 1. Calling class methods VS instance methods
If you have a class, and you have defined a class method like,
class Lasagna
 def Lasagna.prep_time(layers)
 end
end
then, to use that method, you just call
Lasagna.prep_time(4)

If you have a class, but just have a instance method within it like,
class Lasagna
 def preparation_time_in_minutes(layers)
 end
end
then, to use that method, you first create an instance of the class first
x=Lasagna.new
then, call the method on the instance
x.preparation_time_in_minutes(4)

## 2. Positional arguments vs keyword arguments
class Calculator
  # Positional arguments
  def add(num1, num2)
    return num1 + num2 # Explicit return
  end
  # Keyword arguments
  def multiply(num1:, num2:)
    num1 * num2 # Implicit return
  end
end

calc = Calculator.new
calc.add(1, 3)
calc.multiply(num1: 2, num2: 5)

## 3.Return keyword
If you don't say return while making a method, whatever the last line is in the method will be returned. If you say return, the method will return what you specified.(see example above)

## 4.Constants
Constants are assigned once and are written in all caps and underscores
MY_FIRST_CONSTANT = 10
Free Online Courses - October 5, 2022
Tags: javascript, react, beginners, tutorial
Published: 2022-10-05 21:06:50

Free Online Courses for Today

...

Content Marketing 2022. Content that Sells!

.

https://theprogrammingbuddy.club/course/content-marketing-strategy-course/

.

Asteroids with Python PyGame

.

https://theprogrammingbuddy.club/course/asteroids-with-python-pygame/

.

Excel VBA - Make Excel Look Like a Standalone Program 2022

.

https://theprogrammingbuddy.club/course/make-your-excel-look-like-a-standalone-program/

.

Kali Linux Basics Course For Cyber Security

.

https://theprogrammingbuddy.club/course/kali-linux-basics-course-for-cyber-security/

.

Big Data Programming Languages & Big Data Vs Data Science

.

https://theprogrammingbuddy.club/course/big-data-programming-languages-big-data-vs-data-science/

.

SEO - The Complete SEO Course Beginners to Advanced 2022

.

https://theprogrammingbuddy.club/course/seo-the-complete-seo-course-beginners-to-advanced-2022/

.

Microsoft Excel - Excel Only For Beginners 2022

.

https://theprogrammingbuddy.club/course/microsoft-excel-excel-only-for-beginners/

.

Java: Curso profesional de Java 2022 –De cero a Master

.

https://theprogrammingbuddy.club/course/curso-completo-de-java/

.

Make Money From Home As a Transcriptionist: 10 Opportunities

.

https://theprogrammingbuddy.club/course/work-home-transcription-jobs/

.

AWS Certified Cloud Practitioner Practice Exams 2022

.

https://theprogrammingbuddy.club/course/aws-certified-cloud-practitioner-practice-exam-new/

.

Escuela de JavaScript 2022 - De cero a Master en JavaScript

.

https://theprogrammingbuddy.club/course/curso-completo-javascript/

.

First Steps Into Selling Smarter

.

https://theprogrammingbuddy.club/course/first-steps-into-selling-smarter-t/

.

Gradle Essential Training For Java Developers

.

https://theprogrammingbuddy.club/course/gradle-essential-training-for-java-developers/

.

Adobe Premiere Pro CC Essential Video Editing Zero To Hero

.

https://theprogrammingbuddy.club/course/adobe-premiere-pro-cc-essential-video-editing-zero-to-hero/

.

Accredited Certificate in Neuro-Linguistic Programming (NLP)

.

https://theprogrammingbuddy.club/course/accredited-diploma-certificate-neuro-linguistic-programming-nlp/

.

The Complete React Redux Node Express MySQL Developer Course

.

https://theprogrammingbuddy.club/course/the-complete-react-redux-node-express-mysql-developer-course/

.

10 Passive Income Businesses - Earn Passive Income In 2022

.

https://theprogrammingbuddy.club/course/passive-income-business/

.

Make Money Online: Mindset Training + Real-Life Examples

.

https://theprogrammingbuddy.club/course/make-money-online-training/

.

Flutter & Dart Complete Development Course [2022] [Arabic]

.

https://theprogrammingbuddy.club/course/best-and-complete-flutter-course-for-beginners/

.

Flutter & Dart Complete Development Course [2022] [Arabic]

.

https://theprogrammingbuddy.club/course/best-and-complete-flutter-course-for-beginners

#cybersecurity #development #training #cloud #developer #python #seo #opportunities #java #microsoft #money #datascience #aws #like #contentmarketing #javascript
Welcome Thread - v194
Tags: welcome
Published: 2022-10-05 21:03:15

---
title: Welcome Thread - v194
published: true
description: Welcome to DEV! A thread of hellos and intros.
tags: welcome
canonical_url: 
---

![A cat is freaking out, its body spinning around wildly. Suddenly, it lands in a comical pose where it seems to be laid back and relaxed, while the word "Sup." appears on screen](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3d90raqwh6rg0mwdxuwz.gif)

### Welcome to DEV!

1. Leave a comment below to introduce yourself! You can talk about what brought you here, what you're learning, or just a fun fact about yourself.

2. Reply to someone's comment, either with a question or just a hello. 👋 

**Great to have you in the community!**
Representing missing values
Tags: javascript, typescript, webdev, programming
Published: 2022-10-05 20:33:24

We all have to deal with missing values i.e null, which was later said to be [a billion dollar mistake](https://www.infoq.com/presentations/Null-References-The-Billion-Dollar-Mistake-Tony-Hoare/). Missing values are usually represented as `null` or `undefined`, but depending on your application needs, an empty string or zero might also be considered a missing value.

The conventional way is to

```ts
if (someValue !== null && someValue !== undefined) {
}
```

and maybe some more

```ts
if (
  someValue !== null &&
  someValue !== undefined &&
  someValue !== someString.trim()
) {
}

// or

if (someValue && someValue.trim() !== "") {
}
```

or maybe with fancy new JavaScript

```ts
let a = someValue ?? defaultValue;
```

or maybe the old way

```ts
let a = someValue || defaultValue;
```

But in my opinion, they don't give a wholesome way of dealing with missing values.

A better option is to use `Option`als (no pun intended) to denote missing values (the most benefit comes with Typescript) and handle situations where an empty string or zero might be a missing value, by applying a predicate that returns an optional e.g

```ts
let name: Option<string> = O.none; // there's no value for name denoted by a `none`;

if (Option.isSome(name)) {
  // `name` has a value, do something with the value of `name`
}
```

and

```ts
// name must not be an empty string, if it is, return a `none` (no value). If name has a value, we get a `some` (some value)
const transformed = Option.fromPredicate((n) => n.trim() !== "")(name);
```

Which makes more sense from a linguistic point of view, a missing value is nothing/none. Want to learn more? check out [fp-ts](https://gcanti.github.io/fp-ts/modules/Option.ts.html)
RRR
Tags: ruby, rails, routing
Published: 2022-10-05 20:19:57

Today we learned about routing in Ruby and made our first Rails application, a remake of our Rock, Paper, Scissors game from the beginning of the course.  There are many similarities with routing in express so this was a nice review of routing concepts and MVC architecture common to many frameworks. In Ruby on Rails all of our Routes are in our config/routes.rb file and look like this


 get("/", { :controller => "application", :action => "page_you_want"})

The first argument of the get method is a string ("/") in this example. 
The second argument is a Hash, in this example "page_you_want"

Next we have the application_controller (Controller/Action) in this file we find the controller, below is an example

render({ :template => "game_templates/scissors.html.erb"})

In this file we call the separate html file for the page, in this case scissors.html.erb for the basic structure of our page while embedding our logic in our application_controller.rb file. By using instance variables @variable syntax we can now use our variables in both our actual view file as well as our application_controller file making our code nice and DRY!

Here is a link to my GitHub repository [RPS routing exercise](https://github.com/Logan-s-DPI-Account/rps-rcav)
Records en C#
Tags: csharp, dotnet, beginners
Published: 2022-10-05 19:55:09

En recientes versiones de C# se agregó un feature llamado records, ¿qué son y para qué sirven?

Los records entran a formar parte de la familia de tipos de datos personalizados de la familia de C#. De esta familia hacen parte, la hermana mayor class, luego los struct. Los records son tipos de datos complejos creados para cumplir principalmente 2 objetivos.

1. Enfocarse en modelar datos.
2. Evitar la igualdad referencial.
3. Enfocarse en modelar datos.
   Normalmente usamos clases para modelar tanto datos como para describir el comportamiento del objeto que estamos modelando, esto lo hacemos a través de métodos. Sin embargo, los records pasan a ser un tipo de dato que se enfoca sólo en modelar datos, tal vez busquemos mapear una tabla de configuraciones globales que no tienen ninguna implicación en la lógica del negocio, esto abre la posibilidad para usar records.
Introduction to forms in Angular (Part 2)
Tags: angular, beginners
Published: 2022-10-05 19:51:13

# Custom Validations

Custom validations can be achieved by creating a class that expose methods that perform the revision of a control value.

It is worth noticing that if we are working with typescript, the validation method is a static one, in other words, the method can be called without instantiating the class.

```typescript
import { AbstractControl } from '@angular/forms';

export class CustomValidators {
  static isValidPrice(control: AbstractControl) {
    const value = control.value;
    if (value > 1000) {
      return { invalid_price: true };
    }
    return null;
  }
}
```

AbstractControl is use to give us access to our control \(what we want to validate\).

One way we can use our custom validation is by adding them as elements of our validators during form groups creation.

```typescript
  private buildForm() {
    this.form = this.fb.group({
      id: ['', [Validators.required]],
      title: ['', [Validators.required]],
      price: ['', [Validators.required, 
        CustomValidators.isValidPrice]],
      image: '',
      description: ['', [Validators.required]],
    });
  }
```

Then we can add error messages in the view

```markup
<p *ngIf="form.get('price').hasError('invalid_price')">
    Required Price
</p>
<p *ngIf="form.get('price').hasError('required')">
    Invalid Price
</p>
```