teleren/devto huggingface dataset:
TIL you can specify the level of flattening of an array in Ruby
Tags: todayilearned, ruby, rails
Published: 2022-05-30 18:17:07

Flattening an Array is a common Leetcode and interview question. And for the most part I never thought I would meet it at my day job (as with most questions you meet during the interview). However, I am doing an interating search through a DB in rails and I am using the pluck method.

The pluck method will return an array of the items you want to pluck, for instance
```
User.find_by(category: "director").pluck(:email, :user_name)
=> [["johndoe@example.com", "John Doe"], ["janedoe@example.com", "Jane Doe"]]

```
But since I am doing an iterative search, (not the most efficient, but I am yet to optimize), I store the results of each fetch in an array variable which means I end up with a deeply nested array. (Again, not the most efficient, I know.)

Enter the `flatten` command. Flatten will ***return a new array that is a one-dimensional flattening of self***

But I didn't want a one dimensional array. I want to preserve the results of the pluck command. So if you go through the [docs](https://ruby-doc.org/core-2.7.0/Array.html#method-i-flatten), you find that flatten actually takes in an integer that determines the level of recursion to flatten. 

This then means that we can do this
```
[[[1,2],[3,4]]].flatten(1)
=> [[1,2],[3,4]]

[[[1,2],[3,4]]].flatten(2)
=> [1,2,3,4]

```

This was pretty useful, because if you have a multidimensional array where each element is an array of 2 elements, you can pass the `to_h` methods and convert it to a hash which is pretty neat. 
```
[["johndoe@example.com", "John Doe"], ["janedoe@example.com", "Jane Doe"]].to_h
=> {"johndoe@example.com"=>"John Doe", "janedoe@example.com"=>"Jane Doe"}

```

There you have it, the Array#flatten method can take in an integer to specify the level of recursion to flatten
Latana - Smarter tools. Better marketing decisions
Tags: brands, brandbuilding, brandmarketing, brandstrategy
Published: 2022-05-30 18:06:54

Latana is an advanced brand tracker for fast-growing consumer brands who want to make better marketing decisions. 

Use Latana to: 

Understand how consumers think and feel about your brand
With Latana, you can measure the effectiveness of your marketing strategy by understanding your consumers' brand perception and how it changes over time. 

Get insights on your target audiences
Our solution provides high-quality insights into your brand's most valuable customer groups. Our machine learning technology provides the ability to zoom in on the audiences that drive your business.

Gain access to cutting-edge research expertise 
Get industry-leading analytics that drives your brand forward. Our team of experienced researchers provides end-to-end support, using tried and tested methodologies to ensure data you can trust. 

Track your brand in just one city or across the world 
Benefit from unlimited geographic granularity and scalability, allowing you to track brand performance anywhere from your local city to 100+ countries worldwide.

**https://latana.com**
What’s you’re dev setup?
Published: 2022-05-30 17:24:11

I finally started using Vim + Tmux full time! I can’t believe I waited that long to switch. 

I’m using LunarVim for a reasonable Vim configuration, and this Repo to config Tmux https://github.com/gpakosz/.tmux 

I also mainly use Iterm2 for my main Terminal (and trying to get Alacritty to behave well with Tmux)

For Rust development, I’m using Rust Analyzer, and for Typescript I’m using Typescript bin, typescript-language-server, Eslint and Prettier. 

What’s your current dev setup? Would love to see some photos! 
Cheers.
[Video] What's the point of async/await in an ASP.NET Core application?
Tags: dotnet, csharp
Published: 2022-05-30 17:22:28

---
title: [Video] What's the point of async/await in an ASP.NET Core application?
published: true
date: 2022-05-30 17:00:00 UTC
tags: dotnet,csharp
canonical_url: https://blog.codingmilitia.com/2022/05/30/whats-the-point-of-async-await-in-an-aspnetcore-application/
cover_image: https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ds7cgrb9690nhe85scdh.png
---

Hey folks! 👋

📢 New one available through the tubes!

I’ve been noticing in recent chats that folks have difficulty explaining why do we use async/await, tasks and related, when building ASP.NET Core applications.

I hope that this video, very high-level and narrowly focused by design, can help in increasing the understanding of the importance of using these features.

{% youtube COeg6UoPe_Q%}

Here are a couple of related links:

- [“There Is No Thread” by Stephen Cleary](https://blog.stephencleary.com/2013/11/there-is-no-thread.html)
- [async guidance doc by David Fowler](https://github.com/davidfowl/AspNetCoreDiagnosticScenarios/blob/master/AsyncGuidance.md)
- [Dotnetos Async Expert course](https://asyncexpert.com/)
- [Async all the things](https://www.youtube.com/watch?v=CGi1bQgaqwg)

Thanks for stopping by, cyaz! 👋
Scroll to top button with JQuery
Tags: html, css, beginners, tutorial
Published: 2022-05-30 16:42:22

Hello 👋 dear techie friends, I am [Atul](https://atulcodex.com)

Yesterday i have made a 🍭 simple scroll to top button with just HTML CSS. 

{% link https://dev.to/atulcodex/scroll-to-top-button-with-just-html-css-1c2 %}

🤫 Today I have made another scroll to top button with some extra features. HTML + CSS + JQuery

#### show hide feature

{% codepen https://codepen.io/atulcodex/pen/ZErrjNa %}

Share your feedback's in comment section, I would love reply :)
What is GitHub Copilot ?.
Tags: github, githubcopilot, ai, suggestions
Published: 2022-05-30 16:26:30

## Introduction

- GitHub Copilot is used to write code faster and with less work. 
- Individual lines and whole functions are suggested instantly by the Copilot. 
- `OpenAI Codex` is a new artificial intelligence system.


## Working of GitHub Copilot

- `OpenAI Codex` was trained on publicly available source code and natural language so it understands both programming and human languages. 
- The GitHub Copilot editor extension sends your comments and code to the service, which uses OpenAI Codex to suggest individual lines and whole functions.

GitHub Copilot has been trained on a selection of `English language` and source code from publicly available sources.


## Suggestions of code


- The code it suggests may not always work, or even make sense, as it tries to understand your intent and to generate the best code it can. 
- Code suggested by GitHub Copilot should be carefully tested, reviewed, and checked out, like any other code. You are always in charge as a developer.

## Exploring the developer Jobs

- Change to the developer experience can be brought about by bringing in more intelligent systems. 
- Existing engineers will be able to be more productive, reduce manual tasks and focus on interesting work.
- GitHub Copilot has the potential to lower barriers to entry and allow more people to explore software development and join the next generation of developers.


## Usage of Data collection in GitHub Copilot

- In order to generate suggestions, you must transmit part of the file you are editing to the service. 
- This context is used to make suggestions. The suggestions are recorded on the Copilot. 
- This data is used to improve future versions of the system so that Copilot can make better suggestions for users in the future. Users will be able to control how their data is used in the future.

**Supported development environments** are

- Visual Studio Code 
- Neovim
- IntelliJ-based IDEs like JetBrains IntelliJ IDEA, Android Studio or PyCharm.


Gratitude for perusing my article till end.I hope you realized something unique today. If you enjoyed this article then please share to your buddies and if you have suggestions or thoughts to share with me then please write in the comment box.
Virtual Coffee Lunch & Learn: Asking Coding Questions with Bekah Hawrot Weigel & Nick Taylor
Tags: career, codenewbie
Published: 2022-05-30 16:19:27

The Virtual Coffee Lunch & Learn: Asking Coding Questions with [Bekah Hawrot Weigel](https://twitter.com/BekahHW) and [Nick Taylor](https://twitter.com/nickytonline), that took place May 27th, 2022, is now available on YouTube.

{% embed https://youtu.be/DVqtr3iwkwQ %}

Thanks to everyone that responded to the discussion posts leading up to the Lunch & Learn, and thanks to everyone that attended. 😎

Photo by [Towfiqu barbhuiya](https://unsplash.com/@towfiqu999999?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText) on [Unsplash](https://unsplash.com/s/photos/questions?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText)
Error with Serverless Deployment
Tags: serverless, beginners
Published: 2022-05-30 16:18:23

### Error: Deployment bucket has been removed manually
When you try to serverless deploy and you see this error on your terminal.
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/faxadbou0tueje3588uz.png)
This is usually because you tried to delete your CloudFormation stack manually on the aws console but the Delete has failed.
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/31qz5gys299dajpsiq6p.png)

### Solution: Delete again properly
Click on your stack name that will lead you to the stack info tab.
Click delete at the top.
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/t1oju98tqiyc1mld19b1.png)
You will see a pop up:
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/w48xd3q6927ppzzxn5c4.png)
Check and click delete Stack and it will delete the stack properly now.

Now you can run 'serverless deploy' with no errors!

### Reference
DO visit this awesome [POST](https://www.stackery.io/blog/top-10-deployment-errors/) for more common serverless errors.
Lunes de música... ¿Qué estás escuchando? 🎵 (30-mayo)
Tags: music, spanish, discuss, lunes
Published: 2022-05-30 16:09:57

> **"La música puede cambiar el mundo porque puede cambiar a las personas"**
_Bono_

La música es parte importante de la vida de la mayoría de las personas y una vida no basta para poder escuchar todas las canciones que quisiéramos o conocer a todos los artistas, solistas o bandas.

Últimamente mis gustos musicales han sido muy estáticos y siento que necesito abrir mis horizontes y poder conocer nueva música interesante. 

Este post es la sexta entrega de una serie semanal que lanzaré todos los lunes para que como comunidad podamos compartir y por qué no conocer nuevas melodías. 🎶

Puedes compartir tus sugerencias usando los *liquid tags* de Dev.to, por ejemplo:

* Para compartir un video desde youtube:
```js
{% youtube dQw4w9WgXcQ %} // dQw4w9WgXcQ es el id del video
```

* Para compartir una canción desde spotify:
```js
{% spotify https://open.spotify.com/track/7GBwTrOpTtsLdJN3Dc0U1C?si=ea737b51f47043b6 %} 
```

Mi sugerencia para esta semana es de la banda argentina Bandalos Chinos y su tema **La final**.
 
{% youtube 34ihNZccDh8 %}

---

La versión original de este post esta escrito por mi amigo 
@michaeltharrington ve y salúdalo de mi parte con una canción 🎵

{% link https://dev.to/michaeltharrington/music-monday-what-are-you-listening-to-may-23-104p %}

Los respectivos créditos a él por ser tan buena onda. 

{% user michaeltharrington %}

Y dime, ¿qué estás escuchando ahora? Te leo en los comentarios.
Paracetamol.js💊| #128: Explica este código JavaScript
Tags: javascript, webdev, programming, spanish
Published: 2022-05-30 16:00:18

## **<center>Explica este código JavaScript</center>**
#### <center>**Dificultad:** <mark>Intermedio</mark></center>

```js
const f = async() => {
  return await 5;
}
console.log(f())
```

A. `Promise { <pending> }`
B. `Promise { <fulfill> }`
C. `Promise { <reject> }`
D. `5`

Respuesta en el primer comentario.

---
Lawn weeds and Technical debt
Published: 2022-05-30 15:51:52

I was spending some time this weekend (as usual) clearing out weeds on my lawn when I suddenly realized how similar weeds are to technical debt. 

---

Clearing weeds as they appear and before they spread requires time and patience, but it is manageable if tackled continuously.

The same applies to technical debt, which is much cheaper and faster to pay back in the early stages of a software project.

---

Let weeds spiral out of control, and the cost and time to fix the problem increase to a point where you begin to wonder whether it’s more cost-effective to start over from scratch. 

This is also true for technical debt. 

---

_How do you prefer to tackle technical debt?_
Hot plug
Tags: opensource, microservices, systems, luos
Published: 2022-05-30 15:48:41

What happens if you want to add new components to your embedded design in the middle of its operation? Normally, you would reboot your system.
⏩ https://www.luos.io/docs/luos-technology/services/routing-table
With Luos, you can "hot plug" a new board, which will communicate directly with your network.
EXCLU: Public cloud carbon footprint score map
Tags: carbonfootprint, greenit, cloud, ecocloudscore
Published: 2022-05-30 15:39:27

Did you know that each public cloud/region has its own carbon footprint ? -> Discover on our interactive map the carbon scores of the different clouds/regions [https://co2score.scaledynamics.site](https://co2score.scaledynamics.site).

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

At ScaleDynamics, we provide solutions to estimate cloud container workflows carbon footprint in realtime and to reduce it [https://scaledynamics.com](https://scaledynamics.com)
tutorial - Delete a contract using selfdestruct()
Tags: solidity, programming, tutorial
Published: 2022-05-30 15:35:06

> This tutorial is meant for those with a basic knowledge of Ethereum and smart contracts, who have some knowledge of Solidity.
> The purpose of building this blog is to write down the detailed operation history and my memo for learning the dApps.
> If you are also interested and want to get hands dirty, just follow these steps below and have fun!~

#### Prerequisites
- Remix

## getting started
#### Contract description
There is a function called `selfdestruct()` in solidity. When the function is being called, the contract that contains the function selfdestruct() will be deleted from the blockchain. The function then forces send ETH back ether to the contract owner, or to a contract address specified by the owner, even if the contract doesn't have a fallback function.

See the following example:
```solidity

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.13;

contract Kill {
    constructor () payable {}
    fallback() external payable {}
    receive() external payable {}

    function kill () external {
        selfdestruct(payable(msg.sender));
    }
    function testCall() external pure returns (string memory) {
        return "Tst called";
    }
    function contractBal() external view returns (uint) {
        return address(this).balance;
    }
    function ownerBal() external view returns (uint) {
        return msg.sender.balance;
    }
}

contract Helper {
    function getBalance() external view returns (uint) {
        return address(this).balance;
    }
    function kill(Kill _kill) external {
        _kill.kill();
    }
}
```

> The first contract **Kill** has `receive()` and `fallback()` function, which enable the contract to send and transfer ETH to another address. function `kill()` contains `selfdestruct()`, which will 'kill' the contract **Kill**. Function `testCall()`, `contractBal()` and `ownerBal()` return a string, contract ETH balance and owner ETH balance respectively. But the three function will be disfuntional after `kill()` being executed. 

> The second contract **Helper** can be able to 'kill' the contract **Kill** without having a fallback function, and Helper will receive the ETH balance of contract Kill after it being terminated.

#### Test contract using Remix

- 1. Contract **Kill**

Before `kill()` being executed:

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zbqxv1liqwsqg67oo1n4.png)
After `kill()` being executed:

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


- 2. Contract **Helper**


After `kill()` being executed, the balance of contract **Kill** is transfered to **Helper**:

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/39mp1jyyndrd1z1k4yc2.png)
Creating a command line tool
Tags: programming, productivity, opensource
Published: 2022-05-30 15:26:18

For a long time now I have been using various website to (for example) generate guids, and I thought to myself "why am I all ways searching the same thing when I can create a tool that generates guid

Well I have finally done it :D

{% embed https://github.com/joro550/DevConsoleTools %}

I have bundled a bunch of tools that I think would be useful together here is a little list of what it can do right now:

- Generate random guids
- Generate random email address
- Generate random number
- Generate lorem ipsum
- Base64 encode/decode strings
- Upper/lower case strings

I also want to add

- MD5 hashing
- SHA1 hashing
- SHA256 hashing
- To do list?

We'll see how far we can push this
Merge multiple Media Stream and save into a single file in React js
Tags: react, javascript, webrtc, stream
Published: 2022-05-30 15:17:53

if you are creating webrtc application or any media stream based application and you want to record multiple media streams into one file and then export the merged stream file in the respected format then read this article carefully.

in this article, I have explained the media stream recording in two parts,

#### 1. mix and record multiple audio streams into one file.

#### 2. mix and record multiple video streams into one file.



## mix and record multiple audio streams into one file

first, install this libraries

`npm install multistreamsmixer
npm install recordrtc
npm install file-saver`

then,import all the libraries

```
import MultiStreamsMixer from 'multistreamsmixer';
import RecordRTC, { getSeekableBlob, MultiStreamRecorder } from "recordrtc";
import { saveAs } from 'file-saver';
```

then write this code to mix and record the audio streams.




```
const streammixer = new MultiStreamsMixer([stream1, stream2]);
let recorder = RecordRTC(streammixer.getMixedStream(), {type:'audio',mimeType: 'audio/wav'});      
recorder.startRecording();
```


now write this code to stop and save the mix recorded stream.

 

```
recorder.stopRecording(function () {
  let blob = recorder.getBlob();          
     getSeekableBlob(blob, function (seekableBlob) {
         saveAs(seekableBlob, "filename"+ ".mp4");            
     });          
 });
 recorder.destroy();
```

this is how you can mix and record the multiple audio streams and then save it in any format you want.
this seekable function is help to make the audio file seekable otherwise it will not be seekable if you not use this function.


## mix and record multiple video streams into one file

first, install this libraries

`npm install multistreamsmixer
npm install recordrtc
npm install file-saver`

then,import all the libraries

```
import MultiStreamsMixer from 'multistreamsmixer';
import RecordRTC, { getSeekableBlob, MultiStreamRecorder } from "recordrtc";
import { saveAs } from 'file-saver';
```

then write this code to mix and record the audio streams.

```
let mixAV = new MultiStreamRecorder([stream1, stream2],{
            mimeType: 'video/mp4'
          });
mixAV  = mixTeacherStudentAV;
mixAV.record();
```


 now write this code to stop and save the mix recorded stream.

 

```
mixAV.stop(function(blob) {
      getSeekableBlob(blob, function(seekableBlob) {
        saveAs(seekableBlob, "filename"+ ".mp4");        
      });
 });
```

this is how you can mix and record the multiple video streams and then save it in any format you want.
this seekable function is help to make the video file seekable otherwise it will not be seekable if you not use this function.
Git: Amending Commits
Tags: git, beginners
Published: 2022-05-30 15:12:42

There are times after making a commit then reality hits:

- Forgot one or more files to be included in the commit
- Commit message looks silly, unclear, unprofessional,etc. Whatever the reason is, it needs to be edited.

Instead of making a brand new separate commit, the previous commit can be "redo" using
`git commit --amend`
My 1st Project
Published: 2022-05-30 15:12:11

Your Music Player website Link: https://0ksymn.csb.app/
(Check it out for good luck 😃)
Here's the project that I made applying all concepts of HTML and CSS only, that I learned in the past 20 days. (A Music Player 🎸)

Project Video 👇
https://www.linkedin.com/posts/ankit-kiran-3819b0219_projects-frontend-frontenddevelopment-activity-6937021971159207936-EPpa?utm_source=linkedin_share&utm_medium=member_desktop_web

☢️Don't watch the video if you can't bear bad editing and bad background music.🎥
"It has a surprise at the end."

To go onto the next page click any popular artist.

Be sure to leave a comment.
I'd be happy to hear genuine reviews or any further improvements that I can make.


#projects #frontend #frontenddevelopment #webdeveloper #webdevelopment #webdev #webdesign #building #100daysofcode #codingisfun
Our New Release Laravel eCommerce Script
Tags: laravel, ecommerce, xgenious, javascript
Published: 2022-05-30 15:09:04


![Grenmart – Organic & Grocery Laravel eCommerce](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/llejx2vfnkvoyon66mux.png)

[**Grenmart – Organic & Grocery Laravel eCommerce**](https://xgenious.com/our-products/grenmart-organic-grocery-laravel-ecommerce/)

Grenmart is a Organic & Grocery Laravel eCommerce Platform PHP Scripts. it has 3 home page variant which fit anyone needs for showcase your small/medium/larage ecommerce business website. It’s highly customisable, it comes with many awesome features, like Drag & Drop Page Builder, drag & drop menu builder, drag & drop form builder, drag & drop widget builder and many more. it’s compatible with Desktop, laptop, mobile and also compatible with major browsers. it has Comes With Advance Tax/Campaign/Shpping/Coupon/Inventory module. you can use this ecommerce script not only for grocery you can use it for any kind of shop you want, we have added advance, campaign / coupon / shipping along with advance inventory management system,

We have make is fully compatible with seo, meta data, canonical url and sitemap. also make it userfriendly so that your customer an easily thing things from search get related product suggestions and more.

we have added all the thing required for doing seo, seecially add og meta support for all the blog with facebook/twitter support. it support 15+ payment Gateway Paypal, Stripe, Paytm, Flutterwave Rave, Razorpay, Mollie, Paystack, Midtrans, Mercado Pago,Cashfree, Payfast,instamojo, Bank Payment, Check Payment, Manual Payment Etc
Day-97 Training At Ryaz
Tags: javascript, webdev, beginners, programming
Published: 2022-05-30 15:08:08

- Date:30/05/2022
- Day-Monday

Today, I started at about 10:30 am as I was in progress to complete the java script cource and the bidding project so, today I started with the left over task so,firtly today I started with the java script cource as basic css module was left behind so, firstly I started with it in this the instructor started with basic html structure and elements and after this I started with attributes, id's and classes and after this instructor started with css styling and after this I started with css box model n CSS, the term box model is used when talking about design and layout.The CSS box model is essentially a box that wraps around every HTML element. It consists of: margins, borders, padding, and the actual content. with this I completed the left over 6 th module and after this I started with left over 9th module so, in this I did maps fundamentals A Map holds key-value pairs where the keys can be any datatype and A Map remembers the original insertion order of the keys and A Map has a property that represents the size of the map.so, this way my day ended up and I got to learn many new things.