teleren/devto huggingface dataset:
Data class in Kotlin
Tags: kotlin, android, dataclass, programming
Published: 2021-09-08 19:08:31

The main purpose of  `data class` is hold data , in koltin compiler automatically creates following 
 
- 
getters and setters for the constructor parameters -
- hashCode()
- equals()
- toString()
- copy()
- componentN() function 

following condition should be fullfilled to create a data class

- 
primary constructor needs to have at least one parameter.
- All primary constructor parameters need to be marked as **val or var**.
- Data classes cannot be abstract, open, sealed or inner.

to exclude a property for generated implementation declare it inside data class 

```kotlin
 data class Person(val name:String?=null, val age:Int? = null ){

    var excludeProp:Int = 34

    fun personDetails():String?{
        return "name=$name Age=$age"
    }
 }
``` 

```kotlin
fun main(args: Array<String>) {
    
    // val p1 = Person ()
    var  p1 = Person ("Justin", 27)
    val p2 = Person ("Justin", 27)
    val p3 = Person ("Justin", 26)

    println(p1) // 
    println(p1 == p2) // true 
    println(p1 == p3) // false
    
    p1.excludeProp = 90
    println(p1.excludeProp) // 90 
    println(p2.excludeProp) // 34 

    // use copy() when want to change some of properties of object , rest properties are unchanged 

    val newPerson = Person("Karl Bruce", 18)
    val oldPerson = newPerson.copy(age = 90)
    println(oldPerson) // Person(name=Karl Bruce, age=90)

    //Data classes and destructuring declarations

    val p5 =  Person("Chris", 45)
    val (name , age ) = p5
    print("name = $name  age =$age") //name = Chris  age =45

    //call function
   print( p5.personDetails() ) // name=Chris Age=45 
 
}

```
Every React Developer should know these libraries
Tags: javascript, react, webdev, beginners
Published: 2021-09-08 19:01:43

Hey, Devs! I'm here to share some best `React component libraries` that are popular among developers for their usability and accessibility.

Picking the correct library for an application can be tricky, When it comes to creating modern React applications, these component libraries save us ample time and effort.

So, let’s begin.

#React Libraries

###1. Forms & Validation
* [Formik & Yup](https://formik.org/)
* [React Hook Form](https://react-hook-form.com/)
* [React Final Form](https://final-form.org/react)

###2. State Management
* [Redux](https://react-redux.js.org/)
* [Apollo Client](https://www.apollographql.com/docs/react/local-state/local-state-management/)
* [Mobx](https://mobx.js.org/getting-started)
* [Recoil](https://recoiljs.org/)

###3. Routing & Type Checking
* [React-Router](https://reactrouter.com/)
* [Flow](https://flow.org/en/docs/react/)
* [Typescript](https://www.typescriptlang.org/docs/handbook/react.html)

###4. Styling
* [Styled Components](https://styled-components.com/)
* [CSS Module](https://create-react-app.dev/docs/adding-a-css-modules-stylesheet/) 
* [Tailwind Css](https://tailwindcss.com/)

###5. UI Components libs
* [Reactstrap](https://reactstrap.github.io/)
* [Material UI](https://material-ui.com/)
* [Ant Design](https://ant.design/)
* [Chakra UI](https://chakra-ui.com/)
* [Tailwind UI](https://tailwindui.com/)

###6. API Client
* [Axios](https://www.npmjs.com/package/axios)
* [GraphQL](https://graphql.org/)

##Wrapping Up!
That’s all from my side. Although there are multiple other React libraries that developers find helpful, I have mentioned only best ones.

Let me know if you found this post helpful!
Have any suggestions? Reach out to me on [Twitter](https://twitter.com/undefinedhere)
Changing Organizations With Plausible Promises
Tags: management, career, leadership
Published: 2021-09-08 18:42:15

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rxqrjf6akujzwsyg7bxk.png)
It is inevitable that, at some point, a passionate practitioner  wants things to be *better*. Whether that is improved API design quality, greater developer autonomy, or increased product focus, these change agents want to nudge their organizations in new directions.

Knowing where to start, however, can be overwhelming. Feeling, on a deep, fundamental level, that a course of action is right can seem insignificant compared to the size and entrenchment of a complex system. 

Clay Shirky wrote about the term *plausible promise* in his book, [Here Comes Everybody](https://www.amazon.com/Here-Comes-Everybody-Organizing-Organizations/dp/0143114948). He defined it as "a message framed in big enough terms to inspire interest, yet achievable enough to inspire confidence." 

That sounds straightforward on the surface:
* Aim too high, and people will dismiss you as a liar, hopelessly naïve, or someone looking to sell something. Examples include "End World Hunger Tomorrow!", "6-Pack Abs In 6 Days", or "Generate Beloved APIs From Your Database Schema". It is hard to rally people to your cause if it seems unobtainable.
* Aim too low, and nobody will be inspired to take up the cause. There's either too much specific detail or too little perceived reward to make it attractive. Urging that "Every field name must be written as kabab-case" is not the bold rallying cry you might think it is. 

The challenge is to find the Goldilocks middle message: not too pie in the sky, not too in the weeds, but *just right*. 

John Cutler is a product evangelist and coach. [In his guide on sustainable change agency](https://drive.google.com/file/d/1eQMpc1gfO2wOxBE9UzwZt1k0GZhcXkj8/view?usp=sharing), he defines several ways you'll know when your plausible promise is working:

* People begin to invite you to meetings to learn more about it
* Other parts of the organization begin to adopt it
* You'll have volunteers helping to grow the idea in new ways
* Someone will try to take credit for it (a good sign!)
* People will reach out to thank you

You want change. Identify what about that change will achieve broad acceptance. Articulate how the process for change is not only possible but probable in the current organization. Gaining critical mass is still challenging. If you start with a plausible promise, however, you'll have taken an essential first step.

> "Never believe that a few caring people can't change the world. For, indeed, that's all who ever have." - Margaret Mead
About Scope Inside , Javascript 
Tags: javascript, webdev
Published: 2021-09-08 18:36:29

Today we are talking about scope. Which tricky things in javascript. Actually, javascript is a tricky language. javascript one of the Tricky things is Scope. If we are want to deeply understand javascript, we need to understand the scope. That is the most common interview question too.
Javascript have 2 scope, which is : 
1. Global scope 
2. block scope.
3. Local scope/function scope
4. lexical scope


1.Global scope : 
when we define a variable with a value outside any block that variable creates an environment. everywhere we can access this variable as a window object but we do not need to write a window. variable. 
code example : 
```javascript
var a = 10;
function f() {
console.log(a) // access global variable
}
console.log(a) // access global variable
```
2. block scope : 
all js blocks create with scond brackets.
we understand about global scope. Now are going for the local scope. When we define a variable with value inside a block like  for loop, etc and that variable can not access outside from this block. This environment calls block scope in javascript.
```javascript
function f() {
let a = 10;
console.log(a) // access global variable
}
console.log(a) // can not acess this variable
```
3.function scope / local scope : 
when we are define a variable inside a functioin and we can get access the variable only inside the function. We can not get access the acess outside the function . Thats why its called block scope and functional scope.
4. lexical scope :
when we are using a function, If any variable define inside the function we can got this variable inside all child function. like a chain .That is called lexical scope .
AMAZON updates its Terms of Service: PROHIBITS using AWS in case of a Zombie Apocalypse🧟‍♂️
Tags: productivity, discuss, learning, programming
Published: 2021-09-08 18:32:00

Who reads the terms of service? Yes, those hundreds of pages in which they explain the conditions of use of a service. Well, let’s start with someone who has read them to them. If not, this article would not have existed.


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

Just recently, AWS has updated its terms of service and well, the usual. What you can and cannot do, but the funny thing is point **42.10**, which in a nutshell, says that they prohibit the use of their Lumberyard services in case of a zombie apocalypse.


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


You do not believe it? See for yourself by reading the [AWS Terms of Service.](https://aws.amazon.com/es/aispl/service-terms/)

The official information specifies:

> “**Lumberyard** is a cross-platform game engine where you can create games for most modern platforms for free: PC, Mac, iOS / Android, all consoles, including VR glasses.”

**Sure, for many of us, it reminds us of the typical nonsense like “don’t wash your cat” in the washing machine instructions, but here… Just read it again and think about it!**

> “…of a widespread viral infection transmitted via bites or contact with bodily fluids that causes human corpses to reanimate and seek to consume living human flesh, blood, brain or nerve tissue and is likely to result in the fall of organized civilization.”

And why, if this happens, the restriction “will not apply”?

As I said before, it is difficult to understand what is written in this paragraph of the “Amazon” document. But it looks really creepy and raises a lot of questions…


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

Internet users have already begun to debate this problem and the comments are very weird…

People who laugh from irony, ironically claiming that it is a joke


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



Some already proposing new Zombies tax rates


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



Others congratulating the intern

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



Others that give a lot to think about what happened “the last time”


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



And others that we will never know what he had written


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



To finish I leave this important information:

> “When zombies are hungry, they won’t stop until they find food for them, which means you need to disappear from the city as quickly as possible.”
Containers & Docker {DevOps}
Tags: devops, sharingknowledge
Published: 2021-09-08 18:28:10




**What is Containers?**
➡️ A container is a standard unit of software that packages up code and all its dependencies so the application runs quickly and reliably from one computing environment to another.
(In simple language,container is a block/box in which we keep our code,all required dependencies.Package those requirements as a one block known as image and we run those image it is called as Container).

**What is Docker?**
➡️ Docker is an open platform for developing, shipping, and running applications. Docker enables you to separate your applications from your infrastructure so you can deliver software quickly. 
(In simple words, Docker(tool) helps us to make image of our project and run it on Docker engine as a Container.)


**Docker containers that run on Docker Engine:**

**Standard:** Docker created the industry standard for containers, so they could be portable anywhere
**Lightweight:** Containers share the machine’s OS system kernel and therefore do not require an OS per application, driving higher server efficiencies and reducing server and licensing costs
**Secure:** Applications are safer in containers and Docker provides the strongest default isolation capabilities in the industry
JavaScript error messages can be deceptive
Tags: javascript, debugging
Published: 2021-09-08 18:08:35

I was working on a project where an item can be many things. Currently it's just for characters, but in the future it might be used for other things later. So in order to keep things general, I named the class "Object":

```
import { IObject } from "../interfaces/IObject";

class Object {

  getImage(object: IObject): string {
      const imagePath = process.env.VUE_APP_BACKEND + '/images/characters/';
      const image = imagePath + object.name + '.png';

      return image;
    }
}

export default new Object();
```

This is how I made the call to the method:
```
for(var i=0; i<allObjects.length; i++){
      let image = Object.getImage(allObjects[i]);
}
```

When running the code in Firefox, I got the following error:

```
Uncaught InternalError: too much recursion
    Object webpack-internal:///./src/classes/Object.ts:11
    ...
```

At first I thought something was wrong with the for loop. So my first step in debugging was to see what happens when calling the method only a single time (not in a loop). After it still happened, it finally occurred to me, that Object is probably a reserved name in JavaScript. After renaming the class to ObjectClass, the error disappeared. 

I don't know why the JavaScript compiler or even VS Code didn't highlight this issue. If you know of a way to avoid these kind of errors (although rare), please let me know in the comments.
Before adding a new validation, one thing you should notice
Tags: rails
Published: 2021-09-08 17:43:29


When we develop a new feature, it's common to add a new column that needs some validations in the model. So, we might write something like this:

```ruby
class Book < ApplicationRecord
  #...
  validates :barcode, presence: true
end
```

To increase the test coverage, adding the test example is necessary:
```ruby
RSpec.describe Book, type: :model do
  #...
  it { is_expected.to validate_presence_of(:barcode) }
end
```

Everything seems to make sense. All the test examples have passed. 
However, something wrong happened after deploying to the production. Rollbar showed warnings that were related to this validation. Some Book records failed to update.
At that time, I suddenly realized I need to think more about 'adding a new validation'.

### How to avoid the same situation
The first thing is to ask:
> After adding this new validation, can old records pass this new validation when they need  updating something?

If the answer is no, that means there are two things we need to think about:
1. When does this validation need executing?  Whenever a record is updated? Or, the validation can be executed only when the column value to an old record is different from before?
2. What if the new column has to be presence: true ? My opinion is that we only validate the new record. Because neither should we ask users to update the value themselves, nor inserting the value for them.

```ruby
class Book < ApplicationRecord
  #...
  validates :barcode, presence: true, if: :new_record?
end
```

After adding the validation, we should add the test examples to make sure the timing of the validation execution is as we expect.

---

Thanks for this experience to remind me:
> Even though adding a validation is a simple thing, it's important to estimate if it will cause side effects.


*Originally posted on [lynnbright.com](https://www.lynnbright.com/before-adding-a-new-validation-one-thing-should-notice/)*
How to get kivy working
Published: 2021-09-08 17:34:22

sudo apt install apt-transport-https curl

sudo curl -fsSLo /usr/share/keyrings/brave-browser-archive-keyring.gpg https://brave-browser-apt-release.s3.brave.com/brave-browser-archive-keyring.gpg

echo "deb [signed-by=/usr/share/keyrings/brave-browser-archive-keyring.gpg arch=amd64] https://brave-browser-apt-release.s3.brave.com/ stable main"|sudo tee /etc/apt/sources.list.d/brave-browser-release.list

sudo apt update

sudo apt install brave-browser
Starting my Journey in OpenSource  
Tags: opensource, javascript, github
Published: 2021-09-08 17:27:30

Hello readers, welcome to my first post! I am Luigi Zaccagnini and I am a software developer currently located in Ontario, Canada. I started programming seven years ago while I was in high school with the goal of creating awesome software. I am also currently a student at Seneca College taking a course on OpenSource development. I am taking this course because I want to learn more about different aspects of programming (Emulators, Tools, Frameworks, etc.) and want to gain experience working on professional code. OpenSource has always attracted me because a lot of the software I use is OpenSource and it is awesome! I haven’t fully committed to continually contributing to OpenSource software but, started when <a href="https://github.com/humphd">David Humphrey</a> introduced me to <a href="https://github.com/Seneca-CDOT/telescope">Telescope</a> a couple of years ago. My goal for this term is to learn new things, explore topics that interest me and improve my programming skills. I mainly work with web technologies as that is my comfort space but, I would like to try to also work on emulators and other interesting softwares. The first project I researched was a tool called <a href="https://github.com/khanhas/spicetify-cli">Spicetify</a>. Spicetify is a command-line tool that allows you to customize your Spotify client. I picked this project because I use Spotify very frequently and would like the ability to change and add functionality. Now that I shared everything about me, I would like to hear from you! Comment some of your favourite OpenSource projects and tell me what got you into OpenSource? If you haven’t tried or researched OpenSource find one project that interests you and share it!
Create a Netflix clone from Scratch: JavaScript PHP + MySQL Day 44
Tags: php, javascript, webdev, tutorial
Published: 2021-09-08 17:25:09

Netflix provides streaming movies and TV shows to over 75 million subscribers across
the globe. Customers can watch as many shows/ movies as they want as long as they are
connected to the internet for a monthly subscription fee of about ten dollars. Netflix produces
original content and also pays for the rights to stream feature films and shows.


In this video,we will be creating addVideo Page

{% youtube 2Tx6nYOSlYk %}

In this video,we will be Inserting Video Data into database
{% youtube bEBktbrr8Ko %}

If you like my work, please consider
[![Buy me a coffee](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jm11knj7d8zwcvo150q2.png)](https://www.buymeacoffee.com/cglikpo)
so that I can bring more projects, more articles for you

If you want to learn more about Web Development, feel free to [follow me on Youtube!](https://www.youtube.com/c/ChristopherGlikpo)
TO Do List {Day -25}
Tags: 100daysofcode, javascript, programming, webdev
Published: 2021-09-08 16:56:29

#100daysofcode {Day -25}

A to-do list has been created and the special feature of this to-do list is that it will not remove items after reloading or exiting the browser. Because I used local storage to store inventory items. It hasn't been designed yet but I'll update it soon. Check quickly ..

Preview: https://smart-todo-lists.netlify.app

Code: https://github.com/alsiamworld/todo-list
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hdmppvvnxqrz25mgrn4b.png)
How to style an input file with some help from Bootstrap and FontAwesome
Tags: bootstrap, fontawesome, css, beginners
Published: 2021-09-08 16:49:39

You know, styling an <input type="file"> is hard, basically due to some standard behaviors of the browsers that keeps this kind of input aspect a bit ugly.

So, i'll show you a simple method to use when you have to enchance a form with this kind of input, assuming you're using [Bootstrap](https://getbootstrap.com/) in your project.



#### PS: You can check the final markup [here con this Pen](https://codepen.io/Miralo/pen/LYLxgzx)



Here is the main markup (as you can see this is a "basic" bootstrap form-group, except for the "file-field" class that we will use it to customize our field):

```html
<div class="form-group file-field">
    <input class="form-control" type="file" name="attachment" id="contact-attachment">
    <label class="form-label" for="contact-attachment">Select the  file...</label>
</div>
```

The key for our porpuse will be style the `<label>` to "cover" the `<input>`. Let's see how to do this:

```css
.file-field label {
    cursor: pointer;
    /* Here we will "duplicate" a bootstrap basic style */
    height: 36px;
    border: 1px solid #ced4da;
    border-radius: .25rem;
    padding: .375rem .75rem;
    width: 100%;
    /* Style as you please, it will become the visible UI component. */
}
.file-field input[type="file"] {
    opacity: 0;
    position: absolute;
    z-index: -1;
}
```
 
 
#### Here it is! We've just created a basic workaround to "cover" the ugly part of the borowser aspect of the input.

But we can do slightly better adding an icon with my favourite service [FontAwesome](https://fontawesome.com/).

We can add a `<i class="faS fa-folder mr-2"></i>` inside our `<label>`:

```html
<div class="form-group file-field">
    <input class="form-control" type="file" name="attachment" id="contact-attachment">
    <label class="form-label" for="contact-attachment"><i class="fas fa-folder mr-2"></i>Select the  file...</label>
</div>
```

We can also style the icon on the label "hover":
```css
.file-field label:hover i {
    color: purple; /* or whatever color you want */
}
```

#### Pretty easy, isn't it?. Let me know if you have any trouble, I left a bug on the code etc... ( and forgive me for my english of course :-) )


 
## Have a nice day!



Photo by <a href="https://unsplash.com/@jstrippa?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText">James Harrison</a> on <a href="https://unsplash.com/s/photos/developer?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText">Unsplash</a>