teleren/devto huggingface dataset:
Few awesome tricks in Python
Published: 2021-01-17 11:56:08

Few awesome tricks with Python that will save both your time and extra Lines:

A. Assigning Values according to the condition:

Normal Code:👉
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/v4o8i5guh91f4l0o8zdy.png)
Better way:
In spite of writing these lines of code what we can do is use in this way.👇
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/xvzke22ein1d8smrd3kc.png)




B. Using indexes and values of a list at the same time

Normal Code:  👇
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/vkbmqlz9iokifttqc8d2.png)

Better way:
Using the enumerate function. Enumerate is a function that will return both the values and index that we are looping over the list.👇
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/ljoqzzbizxgolunhe9xq.png)




C. Unpacking
Suppose there are a few variables in code and we have to use some of them then we can use the unpacking technique.
Normal code: 👇
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/cmtg4d1yw8bohhadw9f5.png)

Better way: 
If we are using only one variable then we can get rid of that by using _ 

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/usf0chnc3ro7nktgm55p.png)




D. Reverse a list or string:
In python, we can reverse a list or a string by just using one line of code.
Better way : 👉
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/1x6e04pu19rb2tc1fzdx.png)




E. Swap numbers without using temp variable:
Normal code:👉
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/mhi355qyi1kqacaf9wii.png)

Better way: 👉
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/f7aaix834g8raecvi19v.png)




F. Looping over multiple lists at the same time

Suppose there are multiple lists and we have to loop over all of them and use them in one statement or function, then in that case we can use the zip function like this: 👇
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/i7k5c51idiht6xaedicl.png)


That's it for this one. Thanks for reading :)
Asynchronous JavaScript
Tags: javascript
Published: 2021-01-17 11:50:38

Until recently, I thought asynchronous JavaScript was so complicated. It's not helped by the multitude (or so it seems) or ways to handle it. The simplest way I've found is to use async await and fetch. Because they all do what they say the do.

You can think of fetch like playing fetch with a dog. First you throw the ball:

```
const playBall = fetch(ball);
```

And then you need to wait for the dog to return with the ball:

```
const playBall = await fetch(ball);
```

Then the dog returns with the ball:
```
const playBall = await fetch(ball);
return ball;
```

All of that can only happen within an asynchronous function. An asynchronous function is easy to make: you just put async at the start of the function.

```
async function playWithDog() {
  const playBall = await fetch(ball);
  return ball;
}
```

That's it: it really is that simple.

A good API to try this with is  [TheDogAPI](https://thedogapi.com/) or [TheCatAPI](https://thecatapi.com/) if that's your preference. Neither of them need an API key and they will give you dog/cat photos. Here's a real world example using the code from above.

```
async function getDog() {
  const request = await fetch(https://api.thedogapi.com/v1/images/search)
  const data = request.json();
  return data;
}
```

If you paste https://api.thedogapi.com/v1/images/search into your browser you'll see the JSON data it gives you. And you can click on the url to see a random dog picture.
Revisiting the O in SOLID
Tags: computerscience, cleancode, solid, java
Published: 2021-01-17 11:33:35

![good Code](https://dev-to-uploads.s3.amazonaws.com/i/06lz22m0tbedulsvvsfs.jpg)

This is a continuation of the SOLID. In the last post, I covered the S and now we will be continuing with the O. So if you didn't check the last post, feel free to click on the link: https://dev.to/sightlessdog/revisiting-the-s-in-solid-150e 

#Open/Closed Principle: 

>“An entity should be open for extension, but closed  for 	modification”

**Bertrand Meyer, 
OO Software Construction** 

##Open for Extension: A module will be said to be open if it is still available for extension.

##Closed for modification: This assumes that the module has been given a well-defined, stable description (the interface in the sense of information hiding).

##we can achieve that by using a pattern, where high-level modules don't know anything about low-level details. The code is not rigid because nothing would recompile if we add new things, and the code is not fragile because you cannot break the code or let’s say the architecture doesn't let you break things. 

Let's use an example for this, everything would be easier to understand.
let's suppose we have a cone class that looks like this 
![Cone Class](https://dev-to-uploads.s3.amazonaws.com/i/whf6zr8fpj6bdn1124wx.PNG)

And to make things more complicated, let's say we want to calculate it's volume, then the volume calculator class would look like this 
![Volume](https://dev-to-uploads.s3.amazonaws.com/i/d44jy0lgd8svezti19f3.PNG)

##Easy, right? 

But wait for a second, there's another client who doesn't have a cone but has Cube and wants to calculate the volume.

An approach would be to do the logic in the calculator class 
![Added Cube](https://dev-to-uploads.s3.amazonaws.com/i/f2j8lnjow4xfsb5wet4j.PNG)

And as you can notice, this class (VolumeCalculator) isn't closed for modification. In order to extend it, we had to change it.

##Now using the open/closed principle
We would at first define a high-level module like Shape
![Shape](https://dev-to-uploads.s3.amazonaws.com/i/8s754bx0ajegd8obx62f.PNG)

And then we would define our concrete shapes separately and by extending the abstract class.
![NeWcONE](https://dev-to-uploads.s3.amazonaws.com/i/c95ho393vmm08ruqsuh5.PNG)

![NewCube](https://dev-to-uploads.s3.amazonaws.com/i/snmkmbmt5tujppf21e8y.PNG)

And finally, our Volume Calculator would look like this
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/rj868412qev64vepjuw3.PNG)

##And that's how we opened our class for extension by closing it for modification. 

#Sources :
Meyer, B. (1997): Object-Oriented Software Construction, 2nd edition
http://www.cvc.uab.es/shared/teach/a21291/temes/object_oriented_design/materials_adicionals/principles_and_patterns.pdf
Robert C. Martin “Principles of OOD”
https://www.youtube.com/watch?v=zHiWqnTWsn4&t=2707s
https://www.youtube.com/watch?v=rtmFCcjEgEw
https://www.baeldung.com/solid-principles
Day14 : 100DaysOfCode
Tags: 100daysofcode, flutter, productivity, programming
Published: 2021-01-17 10:26:44

Quiet a hectic day...
Was selected in the second round of hackathon as mentioned in my previous post..
we were given set of problem statements to solve
(Out of 100 teams in 1 round we were one of the top 10 teams to be selected in round 2)

nd we choosed Proximity Chat or Geo-Fencing based Chatting
System.
It was a 24-hour hackathon and we tried to make an application which consisted of basic auth thereafter chat functinality using firebase along with map location using polylines and geofencing.
We named our application neighborly.

Early morning we had our presentation nd we had to pitch to judges .


Soon after presentation ended , immediate result was announced and we didnt came in top3.
We  gave it our all best made a small but complex app in 24 hours but :(

Though,
Learned a lot!

You can get out github repo link from here-
https://github.com/singhtaran1005/Neighborly

Here are some of the screenshots of our app-
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/wj1vypzirtj45p3elw0r.jpeg)

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/agv0ecbb24g7h4bn5e7b.jpeg)

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/rwfcvs9w95bwinwzk55n.png)


You can Follow me->
https://github.com/singhtaran1005
https://www.linkedin.com/in/taranpreet-singh-chabbra-27517918a/
Qlik Sense Certification Training Course Online
Tags: datascience
Published: 2021-01-17 10:49:15

Do you desire to be a successful data analyst & earn to take your career to the next level? Then look no further. At IgmGuru we aspire to provide you with the best [Qlik Sense training](https://www.igmguru.com/data-science-bi/qlik-sense-training/) across the globe. Our Qlik Sense course takes you through a journey that enables you to integrate the power of artificial intelligence with your creativity to create and visualize models and to give a whole new dimension to your perspective. Start our Qlik Sense certification course and fulfill your career dreams. Register for the online course and learn Qlik Sense now!
Major League Hacks | Local Hack Day: Build
Tags: mlh, majorleaguehacking, localhackday
Published: 2021-01-17 10:38:58

#Introduction
Hey! The start of the MLH LHD Build week was astonishing for me. I got to know about this week-long hackathon by a fellow-mate which turned out to be the finest series of events that I have attended so far!

![MLH LHD Built](https://uploads-ssl.webflow.com/5f2c6dba183e4e456dfef9ac/5fc94808dc1bd30672ace64f_2020-LHD-build-for-web-01.png)
#MLH
MLH Local Hack Day: Build is one of the three major events hosted by amazing folks at #MLH. Participated in the week-long celebration of coding and various new intimidating technologies.

The event started on 10th January for the next 7 days. Every day was certainly filled with new challenges, but where there are challenges, there are amazing folks to guide you.

**EquiCode**, my guild for the MLH LHD Build was very supportive of every challenge. There were daily and week-long challenges that could spark creativity inside a developer.

![EquiCode](https://pbs.twimg.com/profile_images/1338912238464200704/-IGL7J7Z_400x400.jpg)


We also had some networking tasks, where we all shared a meal with our guildmates and be a part of such community and support each other and grow together: EquiCode.

#Collaboration
###EquiCode and EddieHub had this amazing session together to share a meal that helped me explore the diversity of such enormous communities.


All of this was possible only because of our bewildering guild-mates and our Team Leader i.e. *Khushi Sharma*.

She supported us every day, made us realize that a rank is just a number. It's great that everyone is participating so much and helping each other out.


> After all, the community is a place to learn and explore together!


Bringing in the competition of MLH LHD Build, EquiCode was swiftly able to retain the **'3rd position' in the top guilds leaderboard amongst 100+ guilds**.

> Proud to be part of such a community!!! 

> This week was the most memorable week so far.
Interacting with new people, learning, sharing, and supporting each other to fulfill every challenge.


**I hope to attend such hackathons in near future!**
My Experience at Local Hack Day by MLH
Tags: mlh, localhackday, majorleaguehacking
Published: 2021-01-17 10:36:12

Hi, I'm Utkarsh Agarwal. I'm pursuing my B.Tech in the field of CSE.
Recently  I have participated in the Local Hack Day(LHD) Hackathon conducted by MLH. This was the first hackathon in which I have participated. I was curious to know about the projects, community, guild and many more. And LHD will give me the right platform to increase my confidence, connections and skills. I have done many projects whether it be daily challenges or weekly challenges. I have accomplished most of the tasks. I have learnt many new technologies like AI, blockchain and many others. It is not a hackathon where I have to code only, It also has fun activities like MSPaint Bob Ross, cup stackling, and Chrome Dino game which will give the refreshment to me. I like the task where I have to create the TicTacToe, Twilio API concept, Ellie design etc. It was a wonderful experience for me. 
My GitHub profile: https://github.com/Utkarsh-Agarwal-585
LinkedIn Profile: https://www.linkedin.com/in/utkarshagarwal585/
Devpost: https://devpost.com/taurusu222?ref_content=user-portfolio&ref_feature=portfolio&ref_medium=global-nav
Destructuring Tweets - Episode 3 - Length of a Multiline-String
Tags: snippet, javascript, destructuring, length
Published: 2021-01-17 10:27:34

---
title: Destructuring Tweets - Episode 3 - Length of a Multiline-String
published: true
description: I pick a more or less random snippet from Twitter and analyze it in depth in this series. It shall help me, and you understand the trickery behind it. This episode features the concept of length when called on a string.
tags: snippet, javascript, destructuring, length
cover_image: https://dev-to-uploads.s3.amazonaws.com/i/8cfmlxyhpilvw285sjzy.png
---
Howdy, welcome to OddDev's series about destructuring one of those JavaScript quizzes on Twitter. Welcome to this week's episode!

# Snippet of the Week

This week's [snippet](https://twitter.com/chriskalmar/status/1274597923456679938) is from [Chris Kalmar](https://twitter.com/chriskalmar):
```javascript
const stars = `
  ⭐
  ⭐⭐
  ⭐⭐⭐
  ⭐⭐⭐⭐
  ⭐⭐⭐⭐⭐
`;

console.log(stars.length * 2);
```
They create a multiline string via Template Literal syntax. That is just a fancy way of saying they initialized it by using backticks (`` `foobar` ``). It offers some excellent features, one of them even being crucial for this blog post.
Well, then we output the length and multiply it by two.

# The Output

Commonly the length of a string is described as providing the count of the characters. Technically, this is incorrect. Practically, most times, it's okay to think about it like that, tho. Even now, for our snippet, this is not the trickery! We, indeed, only count characters.
Following that logic, the first thought is to count the stars (⭐) and multiply them by two, being 30. Surprisingly enough, this is far from reality. The output is 62.

# Analysis

The analysis is relatively easy here when you know two things. First, two whitespaces indent every line of stars! They also need to be taken into consideration. For five lines, we have an extra ten characters. Adding up on 15 stars, we have a length of 25. 
Second, Template Literals support multiline strings! We need to count every line break (`\n`) as well. Let us refactor the string declaration with regular apostrophes:
```javascript
const stars = '\n  ⭐\n  ⭐⭐\n  ⭐⭐⭐\n  ⭐⭐⭐⭐\n  ⭐⭐⭐⭐⭐\n';
```
As you can see, we have six line breaks. These plus 25 characters add up to 31. Doubled in the output gives us 62.

# Snippet Summary
- **Trickery**: The string contains whitespaces and line breaks
- **Key Learning**: Template Literals support multi-line strings (for better or worse)
- **Further Reading**:
    - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/length
    - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals#multi-line_strings
Weekly Update #2 - 17th Jan 2021
Tags: devjournal, rust, typescript, git
Published: 2021-01-17 10:19:51

This is my second weekly update of 2021. Two weeks ago, I made a post about my goals for 2021 and as promised, I will give you an update on how I'm doing. Let's get right into it!

{% link https://dev.to/hb/my-2021-learning-plan-76f %}

## Weekly Update

I would say that this week was the week of Rust. I dived into Rust much further, building some bigger projects and going into more advanced syntax. I started off the week by following an <a href="https://www.philippflenker.com/hecto/">awesome tutorial</a> which teaches you how to build a text editor in Rust. I extended this project by adding Python support for the text editor (which I named Lynx).

{% github https://github.com/henryboisdequin/lynx %}

I also learnt more about lifetimes, borrowing, and unsafe code in Rust. A couple of days ago, I found a <a href="https://www.youtube.com/channel/UC_iD0xppBwwsrM9DegC5cQQ">YouTube channel</a> which is very helpful for people looking to learn intermediate Rust. I mostly followed the "Crust of Rust" streams, looking at Lifetimes, macros, unsafe code, and more. I also experimented with using async/await and Tokio in Rust by building multiple CLI applications which fetch 3rd party APIs. Towards the end of the week, I created my own Git CLI tool in Rust which can initialize a repository, add files, and commit files.

{% github https://github.com/henryboisdequin/git-cli %}

To finish off the week, I did some open source contributions for various different types of stuff. Overall, I think it was a successful week! For the upcoming week, I will focus on more Rust by building some more applications. Hopefully, I can also create a portfolio with Tailwind, and do some more open source contributions. 

I also started my own newsletter, if you would like to get some more content from time to time, be sure to sign up!

Thanks for reading!

**Henry**

<a href="https://buttondown.email/hb">📰 Newsletter</a>
<a href="https://github.com/henryboisdequin">🐱 GitHub</a>
<a href="https://twitter.com/henryboisdequin">🐦 Twitter</a>
Displaying snackbar in flutter while navigating
Tags: flutter, dart, android, ios
Published: 2021-01-17 10:04:11

The technologies/tools that we will be using in this tutorial are
Pc (windows,Mac,Linux) any one  you like to code in😃
[Flutter](flutter.dev)
[Vscode](https://code.visualstudio.com)
And also I will be assuming you have Flutter  and Vscode already set up,so lets start

Sometimes we wish to display a snackbar to our users while they navigate to a new route/screen,a very good usecase of this is when auth token gets expired while users are using the application and we route them to login screen, we ought to show them a notification to signify that the application didn't malfunction,though snackbars are not the only form of notification/popup we could give users in flutter  but its usually preferred because it doesn't take the focus of the user away from the app since it displays at the bottom of the screen.
That seems easy right? the naive way is to call navigator then call the snackbar method just like this

![flutter](https://github.com/Baksman/KBook_IBRAHIMSHEHU/blob/master/carbon%20(2).png?raw=true)

If you run the code snippet above you will discover that it doesn't work, this is simply because we are calling Snackbar from a screen different from the context(previous screen) we gave to it.
The next thing that might come into your mind is to call snackbar in the  login screen either in build or initstate method that wont work because at that point in time flutter is already rendering the widget tree and and internally flutter sees snackbar like a new screen trying to build a screen while building a screen ?? huhh?? It throws an error
![image](https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcS69n7gAXFkY-GoLD_iqVcxZUgg8lBdv3tkcA&usqp=CAU)
#WidgetsBinding to the rescue
What this widget simply does is that it waits for  flutter to finish rendering before calling the function wrapped iniside of it, So we can add the code below to either initState or  build method to the screen we are navigating to
![Flutter](https://github.com/Baksman/KBook_IBRAHIMSHEHU/blob/master/carbon%20(3).png?raw=true)
Done !!
Best Gems for beginners.
Tags: beginners, html, css, javascript
Published: 2021-01-17 09:53:54

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/16wtmnjpqlgmpup8aduf.png)
 When we want to learn any new language, the first thing that came to our mind is that " I should find the tutorial on YouTube", and no doubt **YouTube** is the best free resource to learn. 
It's very helpful if you find a good instructor on Youtube because it helps you to understand the basic concept of the technology much better than reading all of them.
I collected Five  YouTube channels here that offer both in-depth tutorials and quick tip videos that make it easy to expand your **Web Development** skills.

## 1-The Net Ninja ##
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/lourr3x8s8g7qjpcxtpx.png)

The person behind this wonderful channel is Shaun and he is one of the best full-stack developers on youtube. 
His tutorial also helps those who never did any coding in their entire life.
 I will definitely recommend everyone to visit and try to learn from him.

 




**Some of his playlist** :
* HTML & CSS
* JavaScript
* React.js,Vue.js,Node,js and etc.

## 2- Traversy Media ##
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/8ld49wb1bv7mpxw7rszw.jpg)
The man who has a solution for every problem, he has a large variety of playlists in which he covers mostly the language of Web technology. He also Shares his work experience and being a software developer.

**Best Youtube Playlist on Traversary Media** :
* FullStack React and Django
* Python
* React.js Project and etc.

## 3- WebDevSimplified ##
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/2c6umiexmu5ete0ddwbg.jpg)
Open up your notebook when you visit this channel it is a pure tutorial experience.
 If you are the kind of person, who likes to take 15-30 minutes a day for professional development, check this channel out.

**Best Youtube videos on WebDevSimplified**
* Real-Time Chat App
* AI Face Detection using Js      
* Design Photoshop Clone etc.

## 4-Dev Ed ##
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/97fox80bagmmcr09zm9w.jpg)
This youtube channel covers those problems that we face in the development of any website like making a logo, small animation, freelancing, photoshop, etc. He has a very interesting playlist that you should check out.

**Best YouTube videos on DevEd**
* Figma Tutorial
* Animation using Vanilla Javascript
* Python Tutorial

## 5-FreeCodeCamp ##
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/3dmfk77w2ejoai1mu6vg.png)
It is the most popular youtube channel which has a tutorial on most of the programming languages, here you can find the complete website making, App development as well as machine learning tutorials.
 This channel provides tutorials on the topic like  HTML, CSS, jQuery, JavaScripts, React.js, SQL, and Ruby, etc. 
 
**Best Youtube Playlist of FreeCodeCamp**
* DevOps
* Machine Learning
* Game Development and etc.
Major League Hacking
Published: 2021-01-17 09:44:35

Hello everyone,
I'm Shweta.I am really glad to share with you  all my experiences I had with Major League Hacking.It is such a wonderful community with amazing people guiding ,supporting and encouraging each other to learn and create a change.I was a part of MLH thrice.It has really done wonders to me .I learned alot through participating and exploring new concepts, techniques.Apart from knowledge and Technical stuff I really enjoyed being a part of the guild and deep diving through all the sessions.Doing everything hands-on gave made me feel confident.I would really suggest you guys to be a part of MLH and stay tuned for amazing things coming your way by MLH.It has got so many supportive and encouraging people to guide you through yoyr path.Looking forward for the upcoming events.Thank you MLH.
Local Hack Day
Published: 2021-01-17 09:28:08

Local Hack Day: Build is a week-long celebration of building hacks. It is organized by Major League Hacking (MLH) , which is a official global hacker community. Each day, we receive challenges to complete. The more challenges we conquer, the more points we will earn. We can pick up which challenges to accept, so whether it's your first time coding or you’re a seasoned expert, Build has something for everyone.

My experience with Local Hack Day was Awesome. I learned many new things from "API" to "Game Simulator", and enjoyed a lot while interacting with communities. 
It was amazing to see my journey from rank-84 to rank-45 moving up to rank-37 then rank-11 and then finially reaching to rank-9.
This is the first time I am participating in Local Hack Day and it has given me such a wonderful experience.

#MLH #MajorLeagueHacking #LocalHackDay