teleren/devto huggingface dataset:
Create Dummy Data Using Tinker In Laravel
Tags: laravel, tinker, command, dummy
Published: 2021-08-06 03:48:55

In this example we will see how to create dummy data/records using tinker in laravel. 

laravel tinker is used for adding dummy records in database. mostly laravel tinker command is use for testing purpose, whenever developers are developing application then they need to test many modules like insert, update, delete is working or not, pagination is working or not , filters are working properly and other functionalities.

So, all these modules we can not add data manually every time it is very boring task to add record one by one, but laravel provide very useful command that is tinker and factory using this command we can add multiple dummy data at a time without using route or any controller, just type some code of command and that's it you can found bunch of records in your database,

So, let's start.

> **_[Read More : Create Dummy Data Using Tinker In Laravel](https://www.techsolutionstuff.com/post/create-dummy-data-using-tinker-in-laravel)_**

---

You May Also Like :

> **_[Read More : Import Export CSV/EXCEL File In Laravel](https://www.techsolutionstuff.com/post/import-export-csv-excel-file-in-laravel)_**
MVC file structure notes
Published: 2021-08-06 02:58:02

Homework: Blog

##New File Structure

server.js > adding in many new packages that will need to be started to run all these files simultaneously 

###Controllers
*Replaces routes*
   index.js (similar, uses router object rather than app)
   home-routes.js (Express code, addition is a snippet that connects the router to a view)
   api > index.js, user-routes.js (ie. this is using Express to save login variables

###Utils
*new*
   helpers.js
In this example, this is adding formatting and pulling in time and date. Separate middleware from routes. If a piece of code is used in multiple routes, can pull that out into it's own file that each route can tap into as needed.

###Views
*new*
Basically these files are creating html code that can pull in data from the database and are strung together using Express.
Pages not nested in other folders here but they are using the file in the layout to complete the page. The partial files are components that are used on multiple pages.

###Public
*new*
"Static" code that the Views files pull from.
   CSS
   Images
   JS > login.js, logout.js

*no change*
Config 
db
Models
Seeds

Documentation:
https://www.npmjs.com/package/express-handlebars << this is the one listed out in the dependencies of the package.json
https://www.npmjs.com/package/express
What happens when updating smart contract ?
Published: 2021-08-06 02:47:25

What happens when updating smart contract ?

I have a question that needs to be clear, sorry I'm new in blockchain

I know when we update the smart contract, we will have a new contract address, so before that our smart contract already has a price on the market and has a transaction. So when a new update, will the price lose or not?

I know there are many projects that have been updated, and the price is not lost, so how do they do it, can anyone explain it to me?
An introduction to React's usestate hook
Tags: react, webdev, codenewbie
Published: 2021-08-06 02:26:57

If you use React you must be knowing that there is a concept of state and props. You can add state to a class component very easily but for adding state in a  functional component you need to use the usestate hook.

## What is a hook ?
>Hooks are a new addition in React 16.8. They let you use state and other React features without writing a class.

This is a quote from the official react documentation.

Hooks basically allow you to use methods which you can use in classes to be used in functional components. Hooks have some rules as well which we will discuss later on.
For now you just take way that hooks are utility functions which allow you to write the code that you can write in class components to be used in functional components.

## The useState hook
In the useState hook you just import a function and then call it
```javascript
import React, {useState} from 'react'
const App = () => {
 const initialCounter = 0
 const hookhere = useState(initialCounter)
 console.log(hookhere)
 return (<></>)
}
```
As you can see the useState hook takes the initalCounter as a parameter.
The output of this function will be a list with the the first item as the state itself and the second item will be function to change the state. So, we can use [object destructuring](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment).
Like this
```javascript
const [counter, setCounter] = useState(initialCounter)
```
Now you can use this counter in the project.

### Manipulating the State
You currently have a setState function you can use that to manipulate the state. It takes another function as a paramter and that function will be changing the state.

This function can take in the prevstate as a paramete r however this is optional.

```javascript
setCounter((prevstate)=> {return prevstate + 1})
```
As you can see here in this code above, the setCounter function takes in another function and that another function returns a value which becomes the new state.
### Rules of hooks
Hooks have a few rules as well such as.
1. You cannot call a hook conditionally
2. Hooks must be called in the same order after every render.

Here is a codesandbox for a basic counter application using react hooks.

{% codesandbox react-counter-z9jbg %}
August 5th, 2021: What did you learn this week?
Tags: weeklylearn, discuss, weeklyretro
Published: 2021-08-06 02:07:14

It's that time of the week again. So wonderful devs, what did you learn this week? It could be programming tips, career advice etc.

<center>

![Information flowing through your brain](https://media.giphy.com/media/qKltgF7Aw515K/giphy.gif)

</center>

Feel free to comment with what you learnt and/or reference your TIL post to give it some more exposure.

{%tag todayilearned %}

And remember, if something you learned was a big win for you, then you know where to drop it as well.👇👇🏻👇🏼👇🏽👇🏾👇🏿

{%link https://dev.to/devteam/what-was-your-win-this-week-2ek3 %}

<center>

![Someone feeling like "Yaaas!"](https://media.giphy.com/media/zBhZiVNNQjfTG/giphy.gif)
</center>
How to retrieve specific documents from MongoDB using filters
Tags: mongodb
Published: 2021-08-06 01:51:21

---
title: How to retrieve specific documents from MongoDB using filters
published: true
date: 2021-08-06 01:47:42 UTC
tags: MongoDB
canonical_url: https://donaldfeury.xyz/how-to-retrieve-specific-documents-from-mongodb-using-filters/
series: "Small Bytes of MongoDB"
---

For a full overview of MongoDB and all my posts on it, check out my [overview](donaldfeury.xyz/introduction-to-mongodb/).

While you can [use the find method to read multiple documents out of MongoDB](https://donaldfeury.xyz/get-all-the-documents-out-of-a-collection-in-mongodb/), it is more likely you only want a subset of that data. The `find` method can take two arguments and the first one determines what data is returned by the cursor. You'll often see or hear this first argument referred to as a "query" rather than a filter.

With the given data in a collection called `users`

```
{
	"name": "John Doe",
	"email": "test@test.com",
	"admin": false
},
{
	"name": "Jane Doe",
	"email": "test2@test2.com",
	"admin": false
}

```

If I wanted to get only the user with the email "test@test.com", you can do this by passing in an object with some expressions that MongoDB will use to determine which data to return.

```
db.users.find({email: "test@test.com"})

```

Will return:

```
{
	"name": "John Doe",
	"email": "test@test.com",
	"admin": false
}

```

To get all the admin users:

```
db.users.find({admin: true})

```

Will return nothing since we have no admin users in that dataset.

You can match on multiple fields as well:

```
db.users.find({admin: false, email: "test2@test2.com"})

```

Will return:

```
{
	"name": "Jane Doe",
	"email": "test2@test2.com",
	"admin": false
}

```
Getting Started Using Redux
Tags: javascript, redux, reactredux, react
Published: 2021-08-06 13:10:40

---
title: Getting Started Using Redux
published: true
date: 2021-08-06 01:42:28 UTC
tags: javascript,redux,reactredux,reactjs
canonical_url: https://medium.com/codex/getting-started-using-redux-4dcf6845535d
---

[![](https://cdn-images-1.medium.com/max/2000/1*jY5YoszgF3fqbjeI_4GspQ.png)](https://medium.com/codex/getting-started-using-redux-4dcf6845535d?source=rss-be00f566a88f------2)

Unidirectional State Management using reducers, actions, and dispatchers

[Continue reading on CodeX »](https://medium.com/codex/getting-started-using-redux-4dcf6845535d?source=rss-be00f566a88f------2)
Función al curry
Tags: javascript, spanish, functional
Published: 2021-08-06 01:31:00

Sí, ya sé, cuando te nombraron lo que llamamos Curry function
(o funciones currificadas) te hizo ruido el estómago. Pero lamentablemente, nada tienen que ver con ese condimento. ¿Y por qué lleva el mismo nombre? Por Haskell Curry, matemático estadounidense. Según Wikipedia fue propuesto el nombre _Schönfinkelisation_ pero no creo que tenga tanto marketing.

## ¿Qué significa que una función sea currificada?

Una función currificada es aquella que está compuesta por dos o más funciones, ejecutadas de forma secuencial. Estas funciones comparten los mismos argumentos ya que componen un mismo closure.

### ¿Cómo se ve una función curry?

```javascript
//Función cotidiana
const suma = (valor1, valor2) => {
    return(valor1 + valor2);
};
suma(1, 2); // 3

//Función Curry
const sumaCurry = (valor1) => {
    return (valor2) => {
        return(valor1 + valor2);
    };
};
sumaCurry(4)(2); // 6
```

## ¿Qué notamos de diferente?

En el snippet de código, podemos ver que la función curry recibe un parámetro (valor1), luego retorna una función que recibe el segundo parámetro (valor2) y esa función retorna la suma de ambos parámetros. Son dos funciones que comparten un mismo scope
y los mismos parámetros.

En el momento de ejecución de la función, tenemos que ejecutarla dos veces: una vez por cada función anidada hasta llegar al resultado. Esto nos permite desacoplar partes de la función y guardarlas en variables

## ¿En qué nos beneficia?

Una característica que a mí me encanta de las funciones curry es que nos permiten reutilizar funciones por partes. Por ejemplo, digamos que nuestra función `sumaCurry ` siempre la usamos para sumar de a 20. Podemos ejecutar la primera parte de la función, y guardar la segunda para más tarde

```javascript
const sumaVeinte = sumaCurry(20)

const sumaVeinte(10) // 30
```

Si nos fijamos en la consola con `console .log ` qué tiene dentro sumaVeinte`, nos mostrará esto:

![Cuerpo de función sumaVeinte](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/q1ktof6s2dfho8642qh3.png)

Pero si utilizamos el método `console .dir` y nos dirigimos a donde dice `[[[Scopes ]]]` podremos ver dentro del closure nuestro valor `20` guardado.

![Información del Closure de la función sumaVeinte](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/apel36jko576sm683ffg.png) 

## Conclusión

La idea de este articulo era mostrarte la existencia de este tipo de funciones y puedas reconocerlas. Tienen muchos usos y se encuentran en muchos lenguajes de programación funcional. Te invito a que explores el concepto y lo pongas en práctica!
Personalizando o README no GitHub 
Tags: github, readme, status, personalizando
Published: 2021-08-06 01:14:35


 Oi galera, tudo bem? Sejam Bem-Vindos.
Meu nome é Leticia Jordão vou ensinar vocês como personalizar seu Readme do GitHub com essas tabelas de estatísticas.

<img height = "150em" src = "https://github-readme-stats.vercel.app/api?username=LeehXD&show_icons=true&theme=radical&include_all_commits=true&count_private=true" />
  <img height = "150em" src = "https://github-readme-stats.vercel.app/api/top-langs/?username=LeehXD&layout=compact&langs_count=16&theme=radical" /> 

**1º PASSO** vocês vão entrar lá no meu perfil do -> [GitHub](https://github.com/LeehXD/LeehXD) repositório LeehXD.



![2021-08-05 (7)](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yuqwb3nn9ao7xfodl0je.png)
 

**2º Passo** Vocês vão clicar em [Update README.md](https://github.com/LeehXD/LeehXD/commit/e2d9878c9cc4da72686cd7955e919c42668fed0a)


![2021-08-05 (3)](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1bepofol78pju4toibiz.png)
 

**3º Passo** Copia a linha grifada e cola no Readme de vocês.

![2021-08-05 (4)](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/15n37g6qkvj6yciyjpew.png)

**4º Passo** Muda o LeehXD para o seu nome no GitHub

![2021-08-05 (6)_LI](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/us9ivrr6k2hknvdf2tvy.jpg)

e pronto!



**Bônus**

![68747470733a2f2f7265732e636c6f7564696e6172792e636f6d2f616e7572616768617a72612f696d6167652f75706c6f61642f76313539353137343533362f6772732d7468656d65735f6c34796e6a612e706e67](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xv5wu9isc8v84ea2mh1i.png)
  
Vou ensinar a mudar a cor da sua tabela.

![2021-08-05 (9)_LI](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/oixqqoq73nxykke06lbt.jpg)
 
Nessa parte **theme=radical** você pode alterar o **radical** para os temas abaixo:

- dark 
- gruvbox
- tokyonight
- onedark
- cobalt
- synthwave
- highcontrast
- dracula


Espero que tenham gostado, me siga no [GitHub](https://github.com/LeehXD/LeehXD) repositório LeehXD.❤️
How to change the selection color when the user selects content using a mouse pointer or cursor in CSS?
Tags: css
Published: 2021-08-06 00:00:00

---
  title: How to change the selection color when the user selects content using a mouse pointer or cursor in CSS?
  published: true
  tags: CSS
  date: Fri Aug 06 2021 05:30:00 GMT+0530 (India Standard Time)
  canonical_url: https://melvingeorge.me/blog/change-selection-color-user-selects-content-cursor-css
  cover_image: https://melvingeorge.me/_next/static/images/main-3f957905f50794b745f8d796f4b53f1a.jpg
  ---
  [Originally posted here!](https://melvingeorge.me/blog/change-selection-color-user-selects-content-cursor-css)
  
To change the color of the selection area when the user selects some content, you can use the `::selection` pseudo-element and write the CSS styles to be applied inside the block in the CSS stylesheet.

### TL;DR

```css
/* Change color of selection when 
   user selects the content */
::selection {
  background-color: blue;
  color: white;
}
```

For example, suppose we have a HTML structure showing some content like this,

```html
<!-- Simple HTML structure -->
<html>
  <body>
    <h1>Hello World!</h1>
  </body>
</html>
```

Normally, in most browsers when the user selects the content `Hello World` with the mouse pointer or the cursor, they will see a blueish background color to indicate that the text has been selected. This color depends on the browser and varies on different browsers.

Normally it may look like this,

![blueish selection color when user selects content](https://melvingeorge.menormal-user-selection-color)

To change this color, we can use the `::selection` pseudo-element in the CSS stylesheet like this,

```css
::selection {
  /* Your CSS styles to apply when 
    user selects content in the HTML */
}
```

Let's say we want to change the background color of the selection to `blue` and the color of the text to `white` when the user selects the content using his mouse pointer or cursor.

So to do that we can define those CSS styles to be applied inside the `::selection` block like this,

```css
::selection {
  /* Your CSS styles to apply when 
    user selects content in the HTML */
  background-color: blue;
  color: white;
}
```

It may look like this,

![custom CSS styles colors when user selects content](https://melvingeorge.mecustom-user-selection-color)

Yay 🎉! We have successfully changed the colors when the user selects the content.

See the above code live in [JSBin](https://jsbin.com/muvuhipafi/3/edit?html,css,output).

That's all 😃!

### Feel free to share if you found this useful 😃.

---
10 deploys per day? BORING!
Tags: devops, cici, continuousdeployment, continuousdelivery
Published: 2021-08-10 20:42:29

---
title: 10 deploys per day?  BORING!
published: true
date: 2021-08-06 00:00:00 UTC
tags: DevOps,CICI,ContinuousDeployment,ContinuousDelivery
canonical_url: https://jhall.io/archive/2021/08/06/10-deploys-per-day-boring/
---

If you’re old like me, you may remember when John Allspaw and Paul Hammond made waves in 2009 with their talk [“10+ Deploys per Day”](https://www.youtube.com/watch?v=LdOe18KhtT4) (well worth the watch if you’ve never seen it).

In 2009, I was working on a team of 3 developers. We were struggling to achieve Joel Spolsky’s suggestion of a [one-step build](https://www.joelonsoftware.com/2000/08/09/the-joel-test-12-steps-to-better-code/). Even the idea of 10 deploys per day seemed utterly ridiculous. Deployment took a minimum of 2 hours on a good day. What voodoo would be required to do 10+ deployments per day? It was inconcievable!

![](https://jhall.io/archive/images/inconcievable.gif)

Now in 2021, the industry has realized that 10, 100, even 1,000+ deploys per day is quite achievable. The question is no longer “can we do this?” but “should we do this?”

If that’s not progress, I don’t know what is!

* * *
_If you enjoyed this message, [subscribe](https://jhall.io/daily) to <u>The Daily Commit</u> to get future messages to your inbox._
How to create a global .gitignore file
Tags: git
Published: 2021-08-31 08:27:53

---
title: How to create a global .gitignore file
published: true
date: 2021-08-06 00:00:00 UTC
tags: git
canonical_url: https://thomasxbanks.com/articles/global-gitignore-file/
cover_image: https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ymkxuwjysvk5jgj5j1ld.jpg
---

Unfortunately, this has happened to the best of us at some point, amirite?!

 ![Screenshot of GitKraken showing a new git ignore file and 30,383 deleted files in the node modules folder](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vli86byoexfsgppa328o.png)

Inspired by this monstrosity, I decided to do some investigation!

Here is how to create a global `.gitignore` file to define a list of rules for ignoring files in _**every single**_ Git repository on your computer…

```

  touch ~/.gitignore_global
  echo node_modules >> ~/.gitignore_global
  echo .DS_Store >> ~/.gitignore_global
  echo .vscode >> ~/.gitignore_global
  git config --global core.excludesfile ~/.gitignore_global

```

For more handy git tips: [RTFM 😉](https://docs.github.com/en/get-started/getting-started-with-git/ignoring-files#configuring-ignored-files-for-all-repositories-on-your-computer)
Solution to html/template: "your-template.tmpl" is undefined

Tags: go, template
Published: 2021-08-05 23:43:34

#TL;DR

First I thought when I execute a template I'm using relative filepath, but I was wrong because it actually using template name, which is the base file name (without the directory).

#Longer explanation

While following the awesome [Golang wiki page assignment](https://golang.org/doc/articles/wiki/), I had hard time with putting the template files into a subdirectory and make them work.

If you are here, you might have some of the following directory:

```
├── IAmNew.txt
├── TestPage.txt
├── go.mod
├── tmpl
│   ├── page-edit.html
│   └── page-view.html
└── wiki.go
```

And you have something similar code to this:

```go
var templates = template.Must(template.ParseGlob("./tmpl/*.html"))
```

or maybe you used the ParseFiles and have a list of files instead:

```go
var templates = template.Must(template.ParseGlob("tmpl/page-view.html", "tmpl/page-edit.html"))
```

:warning: Wrong way of executing templates

```go
err := templates.ExecuteTemplate(w, "tmpl/"+tmpl+".html", p)
```

:white_check_mark: I removed the directory prefix and it worked

```go
err := templates.ExecuteTemplate(w, tmpl+".html", p)
```

##Explanation from the documentation itself

ParseFiles creates a new Template and parses the template definitions from the named files. **The returned template's name will have the (base) name** and (parsed) contents of the first file. There must be at least one file.
If an error occurs, parsing stops and the returned *Template is nil.

##Also another possible reason could be

When parsing multiple files with the same name in different directories, the last one mentioned will be the one that results. For instance, ParseFiles("a/foo", "b/foo") stores "b/foo" as the template named "foo", while "a/foo" is unavailable.
Kotlin, In my regard
Tags: kotlin, java
Published: 2021-08-05 23:17:46

---
title: Kotlin, In my regard
published: true
description: 
tags: kotlin, java
cover_image: https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zs0by3dblfcp7dcx7zo2.png
---
*TLDR; My love/hate relationship with Kotlin.*

Well, as you may know I am quite a long term java developer and I think Java is in surprisingly upside right now since it leave the dark age of the -O- company. I always love to explore the new capacity of the language itself, but can't deny that still feel craving to try another languages such as Go, python and, of course YES, Kotlin.

Since it introduce to public officially in one of events from Google (I am not sure which one), Kotlin always caught heart of many Android developer if not all of them.

But in the scope of backend development, I rarely saw any project that using Kotlin.

But now, I am starting with a new project and when one of our team squad leader so encouraging to put Kotlin into our stack I can't help but honestly feel doubted. Anyway, The team didnt reject the offer and we are going with Java, Kotlin and Go as our backend platform stack. 

In my knowledge before now, Kotlin is quite like an extension of Java. And since we have so many additional language feature recently (which some project still struggling with Java 8) l, my argument for Kotlin are..

1. Switching to Kotlin doesn't help improve performance since it still one on JVM like Java and it need additional compilation steps (every time that we build the project, which means we losing our productivities waiting more time) 

2. Java isn't good with design pattern but it never pushing all over on me. But, Kotlin wants you to understand beforehand about writing a good code. Yes, with good intentions to reduce buggy application but it seems like forever before you got into the point that you understand all Kotlin code in 10 seconds when you see any commit from your college ( Yup, It hurts productivities again )

3. Struggling with 1 tool. Well, IntellJ is no doubt a number one IDE but it isn't free. I am mainly a VSCode user and I can't find any worth to mentioned Kotlin Extension. even for Eclipse IDE, the plugin is abandoned.

Well, after I decided that I (and the team) can accept all arguments above. Give it a shot is not so bad right now.

_I think as if you are experienced Kotlin developer. You got a better tools to handle a lot of situations, writing a shorter and cleaner code. Gradle integration is very good and scope function start to catch my heart more and more._

Well that is it for know. This is kind of like a note to myself in the future 😉

Thank you for reading.