teleren/devto huggingface dataset:
How to remove class names from a DOM element using JavaScript?
Tags: javascript
Published: 2020-09-07 00:00:00

---
  title: How to remove class names from a DOM element using JavaScript?
  published: true
  tags: JavaScript
  date: Mon Sep 07 2020 05:30:00 GMT+0530 (India Standard Time)
  canonical_url: https://melvingeorge.me/blog/remove-classnames-element-dom-javascript
  cover_image: https://melvingeorge.me/_next/static/images/main-267210db762669fe9d1f4f359a60b9a9.jpg
  ---
  [Originally posted here!](https://melvingeorge.me/blog/remove-classnames-element-dom-javascript)
  
## Remove class names from a DOM element

To remove a class name from a DOM element, you can use the `remove()` method in the [`classList`](https://melvingeorge.me/blog/get-all-classnames-of-element-dom-javascript) property in an element using JavaScript.

Let's say you want to remove a class name called `red` from an `h1` element.

```javascript
// first get the reference to the h1 element
const h1 = document.querySelector("h1");

// remove red class name from h1 element
h1.classList.remove("red");
```

- The method accepts valid class names as arguments.

If you want to remove multiple classes at the same time, you can pass those class names to the `remove()` method by passing them as arguments like this,

```javascript
// first get the reference to the h1 element
const h1 = document.querySelector("h1");

// remove red, border-red, bg-yellow classnames
// from the h1 element at the same time
h1.classList.remove("red", "border-red", "bg-yellow");
```

See this live example in [JSBin](https://jsbin.com/luziburayi/edit?html,css,js,output).

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

---
Golang Web - Form Value
Tags: go, web, backend, programming
Published: 2020-09-06 23:37:56

In this chapter we will learn how to submit the data, from layer FrontEnd to BackEnd, so lets do it..

# FRONT END
Prepare a new folder and a template view.html on this file needs to be defined 2 template, which are form and result. The first template (form) became as the landing page program and the contents of the invitation to submit the data.

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

# BACK END
Open file main.go, in this file 2 route handler registration.
- Route / is a landing page, show the form input.
- Route /process as a action from input, show the text.

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

Handler route / wrapped in a function called routeIndexGet. Within it template form in the template view.html will be rendered to view. The request in this handler is restricted to method get only, the request by method will result in a response of 400 Bad Request.

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

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

# TEST
So now run the program that we have created.

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

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/0js7r9vmnqm0qb0m1jqi.JPG)

Finally! Try at home.
Send Multiple Messages through the Terminal with the iMessage App!
Tags: ios, python, productivity, learning
Published: 2020-09-06 23:31:18

If you would like to learn a quick and fun trick, you will need to do the following:

* Get an AppleScript to be able to open the iMessage app:

```
on run {targetBuddyPhone, targetMessage}
    tell application "Messages"
        set targetService to 1st service whose service type = iMessage
        set targetBuddy to buddy targetBuddyPhone of targetService
        send targetMessage to targetBuddy
        send targetMessage to targetBuddy
        say targetMessage
    end tell
end run

```

* Create a TXT file that will have some lines of text

* Create a new Python file: In this python file, you will have to use two different libraries OS, & Config

```

import os
import config

def get_words(file_path):
    with open(file_path, 'r') as f:
        text = f.readlines()[0]
        words = text.split()
    return words

def get_lines(file_path):
    with open(file_path, 'r') as f:
        text = f.readlines()
    return text

def send_message(phone_number, message):
    os.system('osascript send.scpt {} "{}"'.format(phone_number, message))

if __name__ == '__main__':
    #words = get_words('ly.txt')
    #for word in words:
        #send_message('6197516857', word)


    text = get_lines('ly.txt')
    for line in text:
        send_message('18012321787', line)

```

After that, you will have to run the script inside the terminal.

```

python3 main.py

```

Look at my GitHub repository: 

[Send Message - Repository](https://github.com/hvaandres/send_messages)
Measure the time taken by a function to execute - console.time & console.timeEnd ⏳⏲
Tags: javascript, webdev, 100daysofcode, codenewbie
Published: 2020-09-06 23:18:12

A quick and easy way to measure the time it takes code to run is by using `console.time` in conjunction with `console.timeEnd`.

All you need to do is surround the code or function call you desire to evaluate with `console.time` and `console.timeEnd` respectively...


{% twitter 1279092026643013633 %}

`console.time(<label>)` starts a timer with a given (unique) label and `console.timeEnd(<label>)` stops the timer with the corresponding label (the labels must match for this to work).

Once stopped, the elapsed time is automatically displayed in the console 🤯

Drop a comment if you've ever used this technique to measure the performance of your code.
Have a good one.
Leetcode - Climbing Stairs (with JavaScript)
Published: 2020-09-06 22:31:21

Today I am going to show how to solve the Climbing Stairs algorithm problem.

Here is the problem:
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/q35216nyw4y7vl5mxnde.png)

I am going to build a tree to help better understand  the solution to this problem. 

Let’s determine in how many distinct ways we can climb to the top of a 4-step staircase. 

I am going to add branches to the tree based on the number of steps we can take. In this problem, we can either take 1 step or 2 steps. If we take 1 step, we will have to climb 3 more steps. If we take 2 steps, we will have 2 steps left. I will continue to add branches until I reach the base cases:
- When we have 0 steps, how many ways are there to climb? There's 1 way - we just don’t climb. 
- When we have 1 step, how many ways are there to climb? There's 1 way - just climbing on that one step.

To calculate the total number of ways to climb the staircase, we have to first figure out how many ways there are to get to each step, starting from the bottom. We then add the number of ways for each step together and find that there are a total of 5 ways to climb a 4-step staircase.

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

Now we can see that the solution to this problem is the sum of its subproblems. In our case, the total number of ways to climb a 4-step staircase is the sum of the total ways to climb a 3-step staircase  and a 2-step staircase.  Based on that we can write:
num_ways(4) = num_ways(3) + num_ways(2)
For n  number of steps, the equation is: 
num_ways(n) = num_ways(n-1) + num_ways(n-2)
 
This is actually a fibonacci sequence. Each number in a fibonacci sequence is the sum of the two preceding ones, starting from 0 and 1. 
0, 1, 1, 2, 3, 5, 8, 13, 21, 34, ...
Fib(n)=Fib(n−1)+Fib(n−2)

So the solution will be:
```javascript
var climbStairs = function(n) {
    if (n == 1 || n == 0) return 1 // our base cases
    
    let first = 1;
    let second = 2;
    
    for (let i = 3; i <= n; i++) {
        let third = first + second;
        first = second;
        second = third;
    }
    return second;
    
};

```
Simple lists in Flutter
Tags: firstyearincode, dart, flutter, beginners
Published: 2020-09-06 22:20:42


Flutter includes an awesome way to display simple lists. The ListView widget. Everything in Flutter is a widget. Writing text, you need the Text widget, rows and columns you will need a Row or Column widget. 

Once you get the concept of widgets in Flutter life becomes easy. www.flutter.dev also boast of great documentation. 

The ListView widgets is a standard way to display a list containing few items. The ListView also includes the ListTitle widget that contains properties like leading, title and other properties serving as visual structure to a list of data. 

Here is a code sample of a simple list:
```dart
import 'package:flutter/material.dart';

void main() => runApp(MaterialApp(
      home: MyList(),
    ));

class MyList extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    final myTitle = "My Contact List";
    return Scaffold(
      backgroundColor: Colors.blueGrey,
      appBar: AppBar(
          backgroundColor: Colors.black,
          title: Text(
            myTitle,
            style: TextStyle(
              fontSize: 20.0,
              color: Colors.white,
            ),
          )),
      body: ListView(
        children: <Widget>[
          ListTile(
            leading: Icon(
              Icons.email,
              size: 30.0,
              color: Colors.white,
            ),
            title: Text(
              'edison@outlook.com',
              style: TextStyle(color: Colors.white, fontSize: 20.0),
            ),
          ),
          ListTile(
            leading: Icon(
              Icons.phone,
              size: 30.0,
              color: Colors.white,
            ),
            title: Text(
              "01114567832",
              style: TextStyle(fontSize: 20.0, color: Colors.white),
            ),
          ),
          ListTile(
            leading: Icon(
              Icons.map,
              size: 30.0,
              color: Colors.white,
            ),
            title: Text(
              " 1004 estates",
              style: TextStyle(fontSize: 20.0, color: Colors.white),
            ),
          ),
          ListTile(
            leading: Icon(
              Icons.apps,
              size: 30.0,
              color: Colors.white,
            ),
            title: Text("My apps",
                style: TextStyle(fontSize: 20.0, color: Colors.white)),
          )
        ],
      ),
    );
  }
}

```
Final Result:
![Alt text](https://dev-to-uploads.s3.amazonaws.com/i/78x6zv522pkjbqnk7lnp.png)
Use bind to assert a function throws error
Tags: javascript, testing, tips
Published: 2020-09-06 22:20:23

---
title: Use bind to assert a function throws error
published: true
description: How to use the bind method to prepare a function to be tested for error throwing in Chai
tags: javascript, testing, tips
//cover_image: https://direct_url_to_image.jpg
---

If you are using Chai (but that should be valid for other testing frameworks) for your unit tests and you need to assert that a function throws an error, you can use the [assert.throws](https://www.chaijs.com/api/assert/#method_throws) function.

However, the doc is not really clear on how to use it so, if you are testing a function `foo` to throw an error with input `bar` you could be tempted to write the test like this (as I initially did):

```javascript
assert.throws(foo('bar'), "Expected error message");
```

Turns out this way the test does not work.

Reading more carefully the documentation, we can see that the assert.throws function expects, as its first argument, a function

```
.throws(fn, [errorLike/string/regexp], [string/regexp], [message])
```

but in my first attempt I was passing the **application** of a function.

One possible way to make the test function as it is supposed, is to use the [bind](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind) method:

```javascript
assert.throws(foo.bind(foo, 'bar'), "Expected error message");
```

It will create a new function with the `this` keyword set to the first argument, in this case the function itself but it could be whatever makes sense. Next arguments will be passed to the new function when it will be actually called, so we can provide the input under test.

Chai can now use the result of the bind function, a new function, to execute the test in the way it is supposed to, passing the input that should verify our assert.
Data Structures- Pt 1: Stacks and Queues
Tags: beginners, stacks, queues, datastructures
Published: 2020-09-06 21:51:47

I had tried learning about data structures on my own by reading through many articles and watching tutorials but the concepts never quite stuck. I decided to ask for recommendations from fellow bootcamp grads and most of them suggested a few courses on Udemy. I am in the middle of one of those courses and I can happily say that I am finally understanding the concepts! In my next few post I will be sharing what I have learned.

Data structures are ways of organizing information with optimal runtime for adding, editing, and removing data.

###Queues
A queue is ordered list, using first-in/first-out list management. You can compare it to standing in line at the meat counter at the grocery. You take a number(index), and the butcher will call the numbers in order starting from smallest to largest, so the first person to get a ticket will be the first person called, and so on. 
* Adding a record to a queue(a new person getting in like), is called enqueuing.
* Dequeuing is removing the first record of the queue(the first person in line has completed their transaction and leaves).

###Stacks
Stacks are also ordered lists but use first-in/last-out order list management. The concept is the same as stacking plates on a shelf. The first plate you place on the shelf becomes plate on the bottom and last plate you place on the shelf is at the top. So, when you grab to plate on top for your next meal, you are taking the last plate you put the shelf.

In Javascript, arrays are used for both Queues and Stacks but with limitations.
* For Queues we use can use .unshift() to add to the the array, and .pop() to remove from the other end.
* For Stacks we use .push to add to the end and .pop() to remove the last item.


Adding and removing are the main operations for these data structures but we can also create a peek function to preview the record at the front of a queue, or last/"top" of a stack. 
We can also combine multiple queues into one queue and create a queue from stacks.
My purpose: web development for statistical communication
Tags: webdev
Published: 2020-09-06 21:34:23

In honour of [this introduction post](https://dev.to/idman95/console-log-my-first-post-5g52), I decided to use this site as a way to document my web development skill acquisition.

In high school (many years age), I took a web development course and really enjoyed it! I did the website for that years student car show event, and had a lot of fun being a part of that. Though I must say my favourite part of coding that was refactoring 20-30 lines into about 3!

Since that time I haven't touched web development, but have continued to learn coding in one form or another since then. Most recently I've been working with R over the last 5 or so years, and Python a bit more recently as part of my graduate program. I've enjoyed it immensely.

I would like to learn to communicate statistical ideas in an interactive fashion that can easily be accessed by anyone. So I'm using this time to learn the skills to build sites to share intuition behind the ideas I have learned. I know some of this can be done using R, Python, and Julia. But to get to the level of control I would like over the delivery of the message, I'd like to know the nitty gritty so I can make adjustments that people who don't know the lower level stuff cannot make.

I look forward to learning lots, and hopefully helping others do the same :)
I just want to write code!
Tags: career, productivity, todayilearned
Published: 2020-09-06 21:13:00

I used to be under the impression that the job of a software developers was just to write code. I know I’m not alone in having been guilty of thinking that way.

The fact is that a majority of our time in the software development field is spent dealing with people, not with computers.

__If you want to be a good software developer, you have to learn to deal effectively with people__(even if writing code is the part of your job you enjoy the most).

Source: [click Here](https://twitter.com/almokht01385206/status/1302709890562035712?ref_src=twsrc%5Etfw)
Contrasting NATS with Apache Kafka
Tags: apachekafka, nats, microservices, eventstreaming
Published: 2020-09-06 20:44:03

**TL;DR** Kafka is an *Event Streaming Platform*, while NATS is a closer to a conventional *Message Queue*. Kafka is optimised around the unique needs of emerging *Event-Driven Architectures*, which enrich the traditional pub-sub model with strong ordering and persistence semantics. Conversely, NATS is highly optimised around pub-sub topologies, and is an excellent platform for decoupling systems where message order and reliable delivery is a non-issue.

I’ll preface this post by pointing out that there is another product — **NATS Streaming** — which is a different beast and is closer to Kafka. You may want to take a detour to NATS Streaming if you after an alternative event streaming platform; otherwise, read on.

# Subscriptions
At its core, **NATS is about publishing and listening for messages**. These depend heavily on subjects which scope messages into streams or topics. Consumers subscribe to topics either verbatim (matching the topic name precisely), or using wildcards. Below is an illustration of publisher-subject-consumer relationship in NATS.

[Read the rest of the article on Medium.](https://itnext.io/contrasting-nats-with-apache-kafka-1d3bdb9aa767)
پنل اس ام اس چیست؟
Published: 2020-09-06 20:42:32

نرم افزاری اینترنتی است که می توان از طریق آن به یک یا چندین نفر به طور همزمان پیامک های مشابه ارسال کرد.
این کار از طریق اینترنت و در کوتاه ترین زمان ممکن صورت می گیرد و دیگر نیازی به موبایل برای ارسال پیام ها در تعداد زیاد نمی باشد که ما در این مقاله به آن می پردازیم.

بسیاری از افراد، شرکت های تبلیغاتی و یا کسب و کارهای مختلف از سامانه پیامک و یا پنل اس ام اس برای بازاریابی و تبلیغ محصولات و یا معرفی کسب و کار خود به افراد و گروه های مختلف استفاده می کنند.
امروزه و با همه گیری استفاده از فضای مجازی استفاده از انواع سامانه پیامکی از اصلی ترین و موفق ترین شیوه های بازاریابی برای شغل های مختلف می باشد.

مزایای استفاده از پنل اس ام اس
نرم افزارهای ارسال پیامک خدمات متنوعی را می توانند انجام دهند، این سامانه ها علاوه بر دریافت و ارسال پیامک در مقیاس های انبوه می توانند برای گروه های سنی و یا مناطق خاصی از کشور به ارسال پیامک بپردازند.

همچنین یک پنل اس ام اس می تواند گروه های شغلی و یا صنف های خاصی را هدف قرار دهد و به آنها پیامک ارسال کند.
یکی از مزایای استفاده از سامانه های پیامکی نگه داشتن همیشه مشتری برای خود است، این سامانه ها می توانند به صورت اتوماتیک روز تولد افراد موجود در بانک شماره را به آنها تبریک بگوید و این کار اصولا برای مشتریان خوشایند می باشد.

کاربردها
هر فرد و یا کسب و کاری با خریداری یک پنل اس ام اس می تواند شماره های مورد نظر خود را وارد آن کند و یا می تواند از بانک شماره ای که در سامانه پیامکی وجود دارد استفاده کند.
این نرم افزار می تواند ارتباط دو طرفه ای ایجاد کند و مشتریان نیز به شما پیامک ارسال کنند و در صورت بازاریابی سوالات مورد نظر خود را از شما بپرسند.

این نرم افزار همچنین این قابلیت را دارد که شما می توانید متوجه شوید که پیامک تان به چه کسانی رسیده است و یا در حال ارسال می باشد و در صورتی که به برخی از افراد موجود در بانک شماره نرسیده باشد هزینه آن از حساب شما کسر نخواهد شد و عودت داده می شود.
قابل ذکر است برای خریداری یک پنل اس ام اس خوب و مناسب نیز مانند خرید هر نرم افزار و یا کالایی باید تحقیق کرد و مناسب ترین آن را خریداری کرد.

انواع پنل اس ام اس موجود در بازار دارای شرایط ویژه و امکانات متفاوتی می باشند، پس بهترین راه برای خرید موفق ابتدا تحقیق درباره نحوه کارکرد آن و اطلاع از امکانات نرم افزار الزامی می باشد.
برخی از نرم افزار ها علاوه بر داشتن امکاناتی مانند ارسال پیامک انبوه، تکی و تدریجی، دارای امکانات ارسال پیامک منطقه ای، صنفی و سنی نیز می باشند.

این نرم افزارها همچنین نیز می توانند دارای امکاناتی مانند ارسال پیامک به صورت اتوماتیک، نظرسنجی، مسابقه، منشی و … نیز باشند که باید در مورد همه اینها اطلاعات کافی را کسب کنیم.
قابل ذکر است که استفاده از سامانه پیامکی می تواند توسط یک نام کاربری و رمز عبور انجام شود.

https://smsfa.ir/blog/what-is-an-sms-panel/
Visualizing COVID Risk Through an ER Diagram
Tags: entityrelationship, er, datamodels, diagram
Published: 2020-09-06 20:31:00

Like most things in the world, there are different levels of risk for the current pandemic, depending on what is going on in your life, who you are, and who surrounds you.

Today I am showing off a couple of data models I created to show what risks you may or may not have to keep in mind during these *weird* times.

#**COVID Risk ER Diagram:**
![Untitled Diagram](https://dev-to-uploads.s3.amazonaws.com/i/re23cuxgmv51h15j0sbe.png)

###**ER Explanation:**

Patient, Hospitals, Geographic Location, Risk, Occupation, Behavior/Hobbies. These are all the things I have decided would be important to look out for when it comes to the risk of COVID. Each of these entities connects in a way that makes it easy to see that if you are relating to many of the attributes (Green ovals) in one of the entities you show a risk even without relating to any of the others.

##**Example Tuples:**
![COvid Tuples](https://dev-to-uploads.s3.amazonaws.com/i/fc7b43o7nabngslycczd.png)
 

###**Connecting the Diagram with the Tuple:**

The ER Diagram directly correlates with the Tuples which will hold the data and information about each subject when data is collected. In theory, there could be an algorithm that takes all the data for each entity and spits out the risk for each subject depending on their personal information.

{% youtube sIRhboaKHr8 %}

When designing this diagram I had almost the thought of a flowchart in mind, so if you follow the arrows you should be able to self judge your own risks. I tried to make my diagram in a way that I would be able to understand without too much background of the subject, so hopefully, it makes it simple to understand for you in this format.
World of WoqlCraft - Ep.23 Quick up data for TerminusDB 3.0
Tags: python, database, update, video
Published: 2020-09-06 20:16:08

---
title: World of WoqlCraft - Ep.23 Quick up data for TerminusDB 3.0
published: true
description: Just a quick update about what is new for our new TerminusDB 3.0 release and our Python client. Now with Terminus Hub you can get the graphs that we show in previous episodes from Terminus Hub.
tags: Python, database, update, video
---
Just a quick update about what is new for our new TerminusDB 3.0 release and our Python client. Now with Terminus Hub you can get the graphs that we show in previous episodes from Terminus Hub.

Find the source code from our [tutorial repo](https://github.com/terminusdb/terminus-tutorials).

Join the TerminusDB community at [Discord](https://discord.gg/Gvdqw97)
I just launched a free step-by-step course where I build a real production Rails application.
Tags: rails, ruby, webdev
Published: 2020-09-06 19:31:15

I've gained so much from the Rails community, and I want to give back. That's why I've created a free course where I build a real production Rails application from start to finish. You see the whole process as if we are pairing.

[https://www.railscodealong.com/](https://www.railscodealong.com/)

My goal is for this course to be a resource for Junior Developers who are looking to level-up, and learn the skills necessary to become a better programmer.

This course is perfect for anyone with imposter syndrome. I don't always know how to do something. I make A LOT of mistakes. But I show you how I read the documentation and error logs to find a solution. If I can do it, so can you.

---

Did you like this post? [Follow me on Twitter](https://twitter.com/stevepolitodsgn) to get even more tips.