teleren/devto huggingface dataset:
Help wanted naming this code
Tags: coding, dontrepeatyourself, codestyle
Published: 2022-08-09 08:15:23

---
title: Help wanted naming this code
published: true
date: 2022-03-12 00:00:00 UTC
tags: coding,dontrepeatyourself,codestyle
canonical_url: https://jhall.io/archive/2022/03/12/help-wanted-naming-this-code/
---

Show of hands.

How many of you have a library, class, or directory in your current project called `helpers` or `utils`?

Bonus points if you have both!

Actually, bonus points if you have neither.

I don’t like this naming pattern, for a few reasons:

1. The name _tells me nothing_. Literally all code exists to help (otherwise it wouldn’t exist). And all code provides utility (otherwise it wouldn’t exist). So from a _naming_ standpoint, we may as well call such a unit of code `code`. Or `stuff` or `whatever` or… well, I’m sure you get the idea.

2. “Catch all” names like this tend to… catch all. That is, they tend to gather all sorts of random, unrelated things over time. This makes it difficult to find what you’re looking for, which leads to the next problem…

3. These names promote code duplication. When you can’t find a function that does your neat little thing, you create a new one in a local `helpers` class, without realizing that it does, indeed, already exist, in some other helpers class. Now you have the same, or nearly the same, functionality in two (or more) places…

4. It’s just kinda lazy. The same as naming a variable `x` or a function `do()`. I’m sure you can do better. What is the variable/function/class doing? Name it accordingly!

* * *
_If you enjoyed this message, [subscribe](https://jhall.io/daily) to <u>The Daily Commit</u> to get future messages to your inbox._
[Fedora 35] Asus Tuf Laptop internal speakers/mic not working on fresh install
Tags: fedora35, asus, audio, linux
Published: 2022-03-12 08:11:43

I have an ASUS Tuf FX-705DT laptop. I dual booted fedora 35 alongside Windows 10 recently, and I was having a audio issue.

The issue was that neither the internal speakers nor the mic worked. There was no audio, and the system had the volume option disabled.

I found the fix here, in a stackoverflow answer: [https://askubuntu.com/a/1277167](https://askubuntu.com/a/1277167)

I basically created a file called `/etc/modprobe.d/alsa-base.conf`, with the text: `options snd-hda-intel model=asus-tuf`.

I still don't understand what the actual issue was or what this file or the text mean. I hope to understand one day. But until then, this solution will have to do
A Fun Programming Joke To Start Your Day
Tags: jokes, dailydeveloperjokes
Published: 2022-03-12 08:00:10

---
title: "A Fun Programming Joke To Start Your Day"
description: "Check out today's daily developer joke! (a project by Fred Adams at xtrp.io)"
series: "Daily Developer Jokes"
published: true
tags: #jokes, #dailydeveloperjokes
---

Hi there! Here's today's Daily Developer Joke. We hope you enjoy it; it's a good one.

![Joke Image](https://private.xtrp.io/projects/DailyDeveloperJokes/public_image_server/images/5e1258c00f974.png)

---

For more jokes, and to submit your own joke to get featured, check out the [Daily Developer Jokes Website](https://dailydeveloperjokes.github.io/). We're also open sourced, so feel free to view [our GitHub Profile](https://github.com/dailydeveloperjokes).

### Leave this post a ❤️ if you liked today's joke, and stay tuned for tomorrow's joke too!

_This joke comes from [Dad-Jokes GitHub Repo by Wes Bos](https://github.com/wesbos/dad-jokes) (thank you!), whose owner has given me permission to use this joke with credit._

<!--
Joke text:
___Q:___ What does a baby computer call his father?

___A:___ Data!
 -->
Dich vu chuyen nha kien vang
Tags: chuyennhatrongoi, dichvuchuyennha, dichvuvanchuyennha, dichvuchuyennhatrongoi
Published: 2022-03-12 07:26:06

Dịch vụ chuyển nhà trọn gói Kiến Vàng ⭐ Uy tín và Chuyên nghiệp ⭐ Đảm bảo an toàn 100% Tài sản ⭕ Tư vấn & Khảo sát Miễn phí 24/24 ☎️ 0868.365.119 
Website: [https://chuyennhatrongoikienvang.vn/chuyen-nha-tron-goi/](https://chuyennhatrongoikienvang.vn/chuyen-nha-tron-goi/)
[https://en.wikipedia.org/wiki/Moving_company](https://en.wikipedia.org/wiki/Moving_company)
Kết nối với @dvcnkienvangvn qua mạng xã hội:
[https://www.debate.org/dvcnkienvangvn/](https://www.debate.org/dvcnkienvangvn/)
[https://www.debwan.com/dvcnkienvangvn](https://www.debwan.com/dvcnkienvangvn)
[https://dembuon.vn/members/dvcnkienvangvn.139300/](https://dembuon.vn/members/dvcnkienvangvn.139300/
)
[https://www.designspiration.com/dvcnkienvangvn/saves/](https://www.designspiration.com/dvcnkienvangvn/saves/)
[https://my.desktopnexus.com/dvcnkienvangvn/](https://my.desktopnexus.com/dvcnkienvangvn/)
[https://dev.to/dich_kien](https://dev.to/dich_kien)
This week’s newsletter is out! (12-03-2022) - Kindness on the rocks
Tags: javascript, tech, webdev, discuss
Published: 2022-03-12 07:19:16

---
title: This week’s newsletter is out! (12-03-2022) - Kindness on the rocks
published: true
description: Another week of great javascript, tech and web development links.
tags: javascript, tech, webdev, discuss
---

Kindness on the rocks

https://markjgsmith.substack.com/p/mark-smiths-newsletter-12-03-2022?s=w

Would love to hear any comments and feedback you have.

[@markjgsmith](https://twitter.com/markjgsmith)
Linked Lists
Tags: java
Published: 2022-03-12 06:46:14

You may have worked with arrays before jumping on linked lists. Arrays are one of the most popular and simplest data structures. Both arrays and linked lists are linear data structures. But they have certain advantages and disadvantages over one another, that's the reason why they exist.
![Untitled-2021-12-02-1413.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1647064410973/VtIu-1wWo.png)
This is how we represent an array, they store elements in a contagious fashion. If you haven't heard of arrays then check out the following link. It covers everything you need to know about arrays.

All about Arrays

As you know, elements in an array are stored in contiguous memory locations. Here is a representation:
![image.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1647065246408/HZi651SuT.png)
If we want to store say 5 elements in an array then we can do that 

![image.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1647065740228/MeA7Hk1Nj.png)
But what if we want to continuously update the number of elements in the array and the chunk of contiguous space available is less. Or even if the space is available we will have to copy elements from one location to another. That will cost us a lot of memory, So linked lists come to the rescue.

This doesn't mean that arrays are of no use, there are certain advantages of arrays. Let's look at the first then we will discuss linked lists and the disadvantages of arrays.
Arrays are stored contiguously that's why each element are easily accessed. So if you have a case where you set the data once and you don't have to update it. You just need to access it, then there is no better solution than storing them in an array.

But if you want to add some data to the existing one or delete some, then arrays are not efficient in this case. This is one of the major disadvantages of arrays.
For this reason, linked lists come into the picture.

![linkedlist head.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1647066532990/On4Wp_8LN.png)
One node of the linked list contains a data element and the address of the next node. Both data part and address part combined are known as a 'node'.

![image.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1647066893041/AVJQWS6xb.png)
Nodes can be at any place in the memory, the previous node will contain the address to the next node. Hence the insertion and deletion are easily done because we just need to update the address.

![image.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1647067095805/2sYXXaR_x.png)
Based on the address of the nodes they contain there are 3 types of linked lists.
1. Singly Linked Lists
2. Doubly Linked Lists
3. Circular Linked Lists
Jest
Tags: testing, mock
Published: 2022-03-12 06:44:06

---
title: Jest 
published: true
description:
tags: #Testing #Mock
//cover_image: https://direct_url_to_image.jpg
---
Jest is the framework developed and maintaining by Facebook. It is basically used for unit test cases and integration test cases. It's best part is to mock the real API calls, Database queries and methods etc.
Foreach loops on multidimensional arrays in PHP
Tags: php
Published: 2022-03-12 06:17:26

<small>Inspired by [https://bit.ly/3psMXqD](https://bit.ly/3psMXqD)</small>

If you have a multidimensional array you don’t have to procced it like this:

```php
<?php
    $array = [
        ["AA", "AB", 
            ["ACA", "ACD"]
        ],
        ["BA", "BB", 
            ["BCA", "BCD"]
        ],
        ["CA", "CB", 
            ["CCA", "CCD"]
        ],
    ];

    foreach($array as $a){
        foreach($a as $b){
            if(is_array($b)){
                foreach($b as $c){
                    echo "$c ";
                }
            }else{
                echo "$b ";
            }
        }
    }
?>
```
You can simply make it like this:
```php
<?php
    $array = [
        ["AA", "AB", 
            ["ACA", "ACD"]
        ],
        ["BA", "BB", 
            ["BCA", "BCD"]
        ],
        ["CA", "CB", 
            ["CCA", "CCD"]
        ],
    ];

    foreach($array as list($a, $b, list($c, $d))) {
        echo "$a $b $c $d ";
    };
?>
```
For every new dimension you just need to add a new dimension of the `list()` function.
Laravel 8 Collection with first() and firstWhere() Methods Example
Tags: laravel, php
Published: 2022-03-12 06:03:35

Originally posted @ [https://codeanddeploy.com](https://codeanddeploy.com) visit and download the sample code:  [https://codeanddeploy.com/blog/laravel/laravel-8-collection-with-first-and-firstwhere-methods-example](https://codeanddeploy.com/blog/laravel/laravel-8-collection-with-first-and-firstwhere-methods-example)

[![Advanced Laravel SAAS Starter Kit with CRUD Generator](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wyjyev8tz3r8vi2w3on1.png)](https://1.envato.market/5g5QAn)

[Advanced Laravel SAAS Starter Kit with CRUD Generator - GET YOUR COPY NOW!](https://1.envato.market/5g5QAn)

In this example, I will show you how to implement the Laravel 8 Collection with `first()` and `firstWhere()` methods. When doing a Laravel project we should use Laravel collection for easier to process our array data. We will use the `collect` helper function of Laravel to create a new collection instance from our array.

 

And sometimes you need to get the first element or with a condition query that will display the first result of our Laravel collection. With the use of `first()` and `firstWhere()` methods will make it easier for us.

## Example 1: Laravel Collection first() Method Example

```php
public function index()
{
    $collection = collect([
        ['id'=>	1, 'name'=>'Juan Dela Cruz', 'age' => 25],
        ['id'=>	2, 'name'=>'Juana Vasquez', 'age' => 31],
        ['id'=>	3, 'name'=>'Jason Reyes', 'age' => 27],
        ['id'=>	4, 'name'=>'Jake Ramos', 'age' => 43],
    ]);
  
    $first = $collection->first();
  
    dd($first);
}
```

_Output:_

```
array:3 [▼
  "id" => 1
  "name" => "Juan Dela Cruz"
  "age" => 25
]
```

## Example 2: Laravel Collection first() Method Example

```php
public function index()
{
    $collection = collect([
        ['id'=>	1, 'name'=>'Juan Dela Cruz', 'age' => 25, 'gender' => 'Male'],
        ['id'=>	2, 'name'=>'Juana Vasquez', 'age' => 31, 'gender' => 'Female'],
        ['id'=>	3, 'name'=>'Jason Reyes', 'age' => 27, 'gender' => 'Male'],
        ['id'=>	4, 'name'=>'Jake Ramos', 'age' => 43, 'gender' => 'Male'],
    ]);
  
    $first = $collection->firstWhere('name', 'Juan Dela Cruz');
  
    dd($first);
}
```



_Output:_

![Laravel 8 Collection](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/27j9jsil2el1rx3b8s60.png)

That's it I hope you learn how to get the first element of the Laravel collection using first() and firstWhere() methods.

[![Advanced Laravel SAAS Starter Kit with CRUD Generator](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wyjyev8tz3r8vi2w3on1.png)](https://1.envato.market/5g5QAn)

[Advanced Laravel SAAS Starter Kit with CRUD Generator - GET YOUR COPY NOW!](https://1.envato.market/5g5QAn)

Thank you for reading :)
A new way to reduce JSON API output without all the hassles of graphql | Restmap
Tags: node, opensource, tutorial, api
Published: 2022-03-12 06:03:28

To create a simple way to query only the required data from a Rest API without relying on a lot of external tools or code.

---

## What's all the fuss about?

The problem is, Frontend devs have to constantly deal with lots of data in each API request & they have no way of limiting this response according to their needs. So consider they only need 1 key, they still have to get all the keys in the response.

The earliest solution and still a very good solution is using, GraphQl which is a query language for your API (read more [here](https://graphql.org)).

## So have you created a GraphQl alternative?
NO !!!

In no way is **Restmap** a replacement for GraphQl which is a very extensive query language that does a lot of things.

> Restmap solely aims to limit your data without lots of development time on fronend/backend. All you need is just few lines of code on server side

* Graphql requires you to configure/change a lot of your frontend & backend.
* For Graphql in frontend especially you need a new way to consume data by configuring a new library other than the existing REST API which put additional strain on frontend devs.

> Restmap simply plugs & play in your existing system !!!

---

## Sounds Good? Well let me introduce you to Restmap
* Restmap simply works in the existing API by making a slight tweak on the server-side
* Just import the library and call the `reduceData` method on the final output of your API
* Clients can send restmap string via header, query, or body (however you wish to have it on the server-side)

### Do you want examples?

```
{
	"rest" : {
		"query: {
			"lang" : "",
			"map" : "",
			"name" : "",
			"age" : 2
		}
	}
}
```
Now if I just want 2 keys inside query, we can write a special **restmap string**

> **`{rest{query{lang,map}}}`** 

which will return only the required data
```
{
	"rest" : {
		"query: {
			"lang" : "",
			"map" : ""
		}
	}
}
```

#### Example 2 (escape)
```
{
	"rest" : {
		"query": {
			"lang" : "",
			"map" : "",
			"name" : "",
			"age" : 2,
			"something" : {
				"good": true,
				"is" : true,
				"here" : true
			}
		},		
	}
}
```
What is we need to remove just 1 or 2 keys and return all other keys. 
Suppose I need all keys inside `rest.query` except `lang` & `map` while also reducing `rest.query.something`

> **`{rest{query{-lang,-map,something{good}}}}`** 
`-` marks the key as an escape key (you can also customize it; read more below)

which will return only the required data
```
{
	"rest" : {
		"query: {
			"name" : "",
			"age" : 2,
			"something" : {
				"good": true
			}
		},		
	}
}
```

You can also test out more on our [Playground](https://restmap.vercel.app/playground)

---

## So how to get started, properly?
For that, you have to check out the github profile to learn how to use this in your existing system.

{% embed https://github.com/restmap/restmap-node %}
---

Thanks for checking out this article, hope it helps you :)
Create Chatbot with CSS JavaScript #1 | Learn CSS JavaScript
Tags: javascript, webdev, css, beginners
Published: 2022-03-12 05:55:51

Explained how to create Chatbot using Html CSS and JavaScript.
----------------------------------------------------------------
Timeline :
00:00 Teaser
01:06 Create HTML Markup - Lets Get Started
02:45 Style Markup with CSS
07:00 JavaScript Code Starts
12:06 Render Chatbot Response
17:24 Delay Chatbot Response with setTimeOut
18:06 Set Scroll Position

{%youtube C2bKXt1yuPE%}
Web 3.0 Day: 2
Published: 2022-03-12 05:47:10

Today let us learn about basic understanding of  ehthereum, what is ethereum, why we use it 

## What is ethereum ?
Ethereum is a decentralized,open-source blockchain with smart contract functionality, moreover ethereum is a decentralized computer network that executes programs called as smart contract.
Using these smart contracts developers are able to create or develop digital assets it includes creating digital artworks and collectables,video game assets like weapon skins,interesting it also includes digital representation of real world entities like tickets to real world concert,events or movie or even one create their own cryptocurrency, or token, that can be purchased with Ether.
Now Combining these smart contracts with user interfaces developers are able to create variety of decentralised applications, basically dapps includes games,marketplaces and so on.

## what are technological benefits of Dapps ?
These technical benefits are very closely related to the backbone of ethereum architecture as whole
1. There is zero downtime : since it has peer to peer network there is no single point of failure.
2. Privacy : Developers or any user doesn't really reveal their real world identities in order to build these dapps or to use them

## ETHER 
Ether is a cryptocurrency of the ethereum network , it is basically a decentralised token.
Ether is mainly used for two purpose : 
1. It is traded as digital currency in exchange of other cryptocurrencies 
2. Ether is like a fuel for running commands on ethereum platforms and is used by developers to build and run application on the platform
JAVASCRIPT_NOTES
Tags: javascript, webdev, beginners, react
Published: 2022-03-12 05:20:59

Some Awesome notes containing almost all important topics in a well handwritten way.

**For Interview Preparations these are BEST******

Have already been quite popular on LinkedIn


It will help you 

- Revising all concepts 

- Concept clearity of advance topics like promises,closure,async/await


I am sharing the github link here ,It will be worth downloading
Kind of like cheatsheet for javascript interviews
check this link

https://github.com/deepa314/JAVASCRIPT_NOTES
React-js-Identifier-has-Already-been-Declared-(solution)
Tags: react, errors, reacterror, javascripterrror
Published: 2022-03-12 05:02:17

i have been working in a React js small project the project purpose is Build QrCode Geneator.
So when i go to run this project i got an error which is **Identifier-Text-has-Already-been-Declared**
the errors screen shot is like bellow:

![React js Identifier already declared error (solution) ](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dti6tsbbd3oao3meaqg4.PNG)
after seen this type of error i fell wonder and think why this is happen and then i try to find where is the problem, why this is happening. after thinking some time i realize and find what i did and that's all of my mistake. When i solve the issue i think it's very funny and interesting so i decide to share this with all of you internet people.

So why **Identifier-Text-has-Already-been-Declared** error happen: this all of my mistake **i have declared my Component File Name is Text.js but Text is a React Component which i also call from React-bootstrap**.. ha ha ... what a funny mistake i did. so what was the actual scenario. Please see The error scenario in below Screen shot:

![Identifier already declared error](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/utjrgzj7iz43b6r6hcz9.PNG)
So i solve this, How i solve this:
it's very easy i think you already understand how i was solve this.. ha ha ....
**i just rename my component file from Text.js to Handler.js . cause Text is Component of React js and its a React js Own Component and we cant import any Component twice in React js.**
and this is the Reason why i am getting React js **Identifier already declared error**
after solve the issue my source code scenario is like bellow screen shot:

![Identifier-Text-has-Already-been-Declared-solution](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qpz0bqh5honezc5ovd19.png)
and that's it
Happy Coding
.
osman forhad
Full-Stack Developer💻 (Mobile App & Web App)
developer.osmanforhad@gmail.com
🍅Tomato Timer, A True BFF⏳
Tags: 100wordsaday, inkedin, beginners, programming
Published: 2022-03-12 04:17:27

First, you might be wondering why they called it Tomato timer, well as you can see from the pictures Above, this is how the original timer used by this method whose originally was developed by Francesco Cirillo in the later years of nineteen Eighties. This is a proven to Work Technique by many people, even myself, I have seen the result of using this method to improve productivity or simply get more done during the day. 

## Pomodoro Technique 
 The Pomodoro Technique is A Time Management method that uses a timer To break tasks or work into sections or intervals, most people call this Time Boxing or Time blocking. 

- First: We Set a Timer for 25 minutes, and we focus on a single task or work to be done. 
- Second: We take a short break of 5 minutes (walk, rehydrate, stretch, snacks)
- Third: That's 1 Pomodoro You just complete a long with a break, keep in mind that each 25-min block known as pomodoro. 
- As you have completed 4 pomodoro blocks. Meaning 4 25-min pomodoro sections, you can take a long break of 20-30 minutes. 

> This is a Pretty simple, a useful technique ta could help you improve productivity and get you to do more.

**👇 Please Check out the Wikipedia Resource as it's a quick Read that give you all the Detail needed quickly 👇**
>**REFERENCES:**
> [Wikipedia](https://en.wikipedia.org/wiki/Pomodoro_Technique)
> [Lifehacker Article](https://lifehacker.com/productivity-101-a-primer-to-the-pomodoro-technique-1598992730)
> [Pomolectron Timer app I used](https://github.com/amitmerchant1990/pomolectron) been using this one for years, simple and get the job done.**Most Important to me, It's Open Source.**

> - **NOTE: This is one of 30 blogs that I would be attempting to write over the next 30 days to improve my writing skills.**
How to display DOM elements with ForEach()
Tags: javascript, beginners, programming, developer
Published: 2022-03-12 03:19:24

So I'm digging into ForEach() using JS and decided to make a quick way to display your Array index to the DOM in JavaScript.
*side note I already have a blank UL created in my html like this you'll need this at the end of you forEach method.
`<body>
    <h1>ForEach</h1>
        
    <ul>

    </ul>
    <script src="app.js"></script>
</body>`
 first you want to create an Array

```
const todos = [
    "clean room",
    "study JS",
    "work out",
    "eat healthy"
];
```

 create your forEach() method forEach takes in todos like this (I like using arrow functions btw) and pass in your argument todo:

```
todos.forEach((todo)=>{
// do something here
})
```

 start creating your elements and classNames inside of the forEach function.

```
todos.forEach((todo)=>{
    const li = document.createElement("li");
   const liText = document.createElement("span");
   let newDiv = document.createElement("div");`



    li.className = "list";
   liText.className = "items";

 
 liText.innerHTML = todo;


   li.appendChild(liText);

   
   newDiv.appendChild(li);

   
document.querySelector("ul").appendChild(li);

})

```