teleren/devto huggingface dataset:
Class: Static Members
Tags: javascript, beginners, codenewbie, webdev
Published: 2020-09-12 21:20:56


Classes in JavaScript can have static methods and properties. These members are members of the class, not members of the objects created from the class. Most likely, you would create them as utility methods (to compare class instance, clone or create objects).

### Static methods

```javascript
class Person {
    name;
    age;

    constructor(name, age) {
        this.name = name;
        this.age = age;
    }

    static orderByAge(a, b) {
        return a.age - b.age;
    }
}

const employees = [
    new Person("Parwinder", 22),
    new Person("Robert", 33),
    new Person("George", 18),
    new Person("Eliu", 101),
    new Person("Gaurav", 39)
]

employees.sort(Person.orderByAge);

console.log(employees);
```

In the example above, the `Person` class creates a person with a name and their age. We have a static method in the class called `orderByAge`. This method compares the age of all `Person`. The ordering of age does not belong to one specific person but to a group of them (or the parent class they were all created from).

The output of the above code will be:

```javascript
[ Person { name: 'George', age: 18 },
  Person { name: 'Parwinder', age: 22 },
  Person { name: 'Robert', age: 33 },
  Person { name: 'Gaurav', age: 39 },
  Person { name: 'Eliu', age: 101 } ]
```

Keep in mind that static methods are methods on the class alone! You cannot do the last two console logs below:

```javascript
class Person {
    name;
    age;

    constructor(name, age) {
        this.name = name;
        this.age = age;
    }

    static orderByAge(a, b) {
        return a.age - b.age;
    }

    static sayMyName(person) {
        return person.name;
    }
}

const me = new Person("Parwinder", 101);

console.log(me.name); // Parwinder => this is valid
console.log(me.age); // 101 => this is valid
console.log(me.orderByAge); // undefined or Property 'orderByAge' is a static member of type 'Person' 🚨
console.log(me.sayMyName); // undefined or Property 'sayMyName' is a static member of type 'Person' 🚨
```

### Static Properties (or public static fields)

🚨 This feature is in stage 3 of the ES proposal. Only Chrome 72 or above supports it at the moment. Check the [proposal here](https://github.com/tc39/proposal-static-class-features) and the [compatibility here](https://kangax.github.io/compat-table/esnext/#test-static_class_fields)

We use static fields when a field needs to exist only once per class and not on every instance we create. It could be used for storing config, endpoints, cache and so on.

```javascript
class Base {
    static field = "Base Class";
}

class Child extends Base {

}

class GrandChild extends Child {
    static field = "Grand Child Class";
}

console.log(Base.field); // Base Class
console.log(Child.field); // Base Class
console.log(GrandChild.field); // Grand Child Class
```
Happy International Programmers' Day
Tags: programmersday, watercooler, programming
Published: 2020-09-12 20:57:24

_This article has been originally posted on my [blog](https://www.sandordargo.com/blog/2020/09/12/programmers-day). If you would like to receive my latest articles, please [sign up to my newsletter](http://eepurl.com/gvcv1j)._

Dear Fellow Programmers,

If there is one day in the year when we can stop a bit and reflect on the importance of our jobs, this is it.

I strongly believe that all jobs, all work is valuable. I never looked down with a stiff nose on anyone because they did something lesser paid or something that - according to people more clever than me - delivers less added value.

Work itself has a tremendous value compared to sitting on the couch and doing nothing. 

But I digressed. Or did I?

The point is the representatives of whatever profession can take pride in theirs and they should. We should. Of course, without belittling any other.

Face it, crafting software is everywhere. Probably it's not the most glamourous job or not the most exciting one. Yet, we change the world for the better or worse. Today, let's focus on the better part.

We write software that connects families scattered in a country, on a continent, or around the whole globe. Sometimes just connect them virtually, but sometimes physically.

We write software that helps people travel during their well-earned vacations. They can book their airplane tickets, their rental cars easier than ever. This latter is what I help with.

We write software that brings knowledge closer to everyone and makes it possible for more people than ever to learn languages, history, math, physics, or God forbid computer science!

We write software saving lives, [either through helping doctors to perform surgeries](https://www.healthcare.digital/single-post/2017/08/23/7-ways-Google-Glass-is-revolutionising-healthcare) or by writing algorithms helping to identify lethal illnesses before they turn way too serious. Or by analyzing viruses so that doctors can provide treatment.

We write software helping [trucks slow down in insanely small time](https://youtu.be/oAHlthX3-NM) when a small folk runs on the road chasing his ball. We write software making airplanes safer. Yes, even after the year behind us.

We write software that help us in almost all areas of life. We should continue to do so and concentrate even more on doing the the thing that we feel right.

This is the 256th day of the year, 12th September. I wish you a happy programmers' day!

How your software makes the world a better place?
3 Bugs This Week
Tags: bugs, programming, aws
Published: 2020-09-12 20:54:21

---
title: 3 Bugs This Week
published: true
description: 
tags: bugs,programming,aws
//cover_image: https://direct_url_to_image.jpg
---

Ensuring tech blogs don't become the Instagram for Coders where we portray everything in our coding lives as perfect...

I had 3 bugs this week.

1. [eventual consistency latency](https://docs.aws.amazon.com/AmazonS3/latest/dev/Introduction.html): Used a hash to wait for S3 to update a file, but didn't wait long enough. Normally s3.getObject is a 60 ms operation even if megs in size, BUT eventual consistency can make it up to 20 seconds or more. My code didn't work, I have to "wait & retry longer". The worst kind of bug, it only happened "some times".

2. No published interface: One microservice was ok with creating default values, another required them and when missing blew up. This is what you get without clearly defined public interfaces and using dynamic languages at scale. Martin Fowler has [a post on how to fix](https://martinfowler.com/ieeeSoftware/published.pdf).

3. Empty Array === blow up: We have a common case where we load some data, but it could be empty. That's ok, finish early. The code didn't; it had no clue what to do with an empty Array and blew up. Except I already fixed it. Then didn't check the code in 2 weeks ago. 20 years on and I still can attend amateur hour 😛. Too many video games where it autosaves for you <-- my excuse.
Python List
Tags: python
Published: 2020-09-12 20:14:21

```
# Author - MI SHAJIB

# Python List / or any other language called by array

bazar = ["alu", "potol", "morich"]

print(bazar)

# List item update / replace

print(bazar[0])

bazar[0] = "fish"

print(bazar)
# we can change any item using negative index example

print(bazar[-1])

bazar[-1] = "cucumber"

print(bazar)

# bazar[3] = "cream"  # It will give list assignment error (list assignment index out of range) That's why we use append() method of python

# print(bazar)


# Add / Append new item with append() method. append() method add item end of the list
bazar.append("cream")
print(bazar)

# If we want to add new item using index number then we can use insert() method
bazar.insert(0, "oil")
print(bazar)

# we can also add two list
bazar2 = ['mango', "salt", "spray"]

print(bazar2)

final_bazar_list = bazar2 + bazar

print(final_bazar_list)

print('\n \n \n \n')


# Remove list item using del keyword
del final_bazar_list[2]  # Here we want to delete 2 index item / spray
print(final_bazar_list)  # Successfully delete the given item

print('\n \n \n')

# Remove list item using remove() method
final_bazar_list.remove('potol')  # Here we want to remove potol
print(final_bazar_list)  # Successfully removed item

print('\n \n \n')


# If we want to remove end item of the list then we can use pop() method. Also we can store removed item by using this pop() method
# Here we can remove last item and store the removed item into variable
removed_item = final_bazar_list.pop()
print(final_bazar_list)
print(removed_item)

print('\n \n \n')

# We can also define empty list
empty_list = []
print(empty_list)

print('\n \n \n')


# we can also convert string into list
string = "shajib, zihan, akter"
string_list = string.split(',')
print(string_list)
print(type(string_list))

# we can also split string by space
string2 = "polash, fahad, akter"
string_list2 = string2.split(' ')
print(string_list2)
print(type(string_list2))

print('\n \n \n')

# We can find length of list by len() method
print(final_bazar_list)
print(len(final_bazar_list))
print('\n \n \n')


# We can append multiple item at a time by extend() method
final_bazar_list.extend(['ada', 'lebu'])
print(final_bazar_list)
print('\n \n \n')

# List Reversing
final_bazar_list.reverse()
print(final_bazar_list)
print('\n \n \n')

# List Soring
final_bazar_list.sort()
print(final_bazar_list)
print('\n \n \n')

# We can also define list into list or multidimensional list
multi_list = [['a', 'b', 'c'], [1, 2, 3, 4], 'x', 'y', 'z']
print(multi_list)
print(len(multi_list))

# Access multidimensional list
print(multi_list[0])
print(multi_list[0][2])

print(multi_list[1])
print(multi_list[1][3])

print(multi_list[4])
```
How to test NPM package locally
Tags: angular, npm
Published: 2020-09-12 20:43:38

I started contributing to Angular and NPM packages. One of main issue i faced is how to debug this NPM package locally before committing. 

I tried search around StackOverflow and Medium. Found NPM has one best think is `npm link` and `npm unlink`. Using this command you can create symbolic link to local package to global `node_modules` or inside Angular project `node_modules`

Here is documentation available for `npm link` and `npm unlink` https://docs.npmjs.com/cli/link

First tried running command `npm link` inside NPM package and `npm link foldername` this foldername is same NPM package folder name. But this didn't work. 

Why ? 

- Because package name was using author name in package. It called as scope in node modules. In my case its something like this `@username/foldername`. 

How do link this ? 

- Same as normal command only mention `npm link @username/foldername` and for Angular project `npm link @username/foldername`. This name generally from `package.json`

And what ? 

Its works like rocket...🚀🚀🚀🚀
Local NuGet repository
Tags: dotnet
Published: 2020-09-12 20:11:20

Just add another reference under `<packageSources>` on `~/.nuget/NuGet/NuGet.config` (or `%appdata%\NuGet\NuGet.Config` on Windows):

```xml
<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <packageSources>Alt Text
    <add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
    <add key="Home directory" value="/home/john/NuGet" />
  </packageSources>
</configuration>
```

Or edit through the "Package Sources" option on Visual Studio:

![](https://dev-to-uploads.s3.amazonaws.com/i/9x1g7769cb3mhcwvxwfw.png)
Finding Nth Fibonacci number in constant time.
Tags: codequality, algorithms, optimized
Published: 2020-09-12 20:02:16

The below code uses Binet's Algorithm to find the nth Fibonacci number. 

```
int nthFibonacci(int n){
    double phi= double(1+sqrt(5))/2; 
    return round(pow(phi,n)/sqrt(5));
}
```
Day 58: Consuming Open Weather API
Tags: 100daysofcode, javascript, html, css
Published: 2020-09-12 19:58:11

I worked on updating weather data on my webpage. I'm consuming the data from open weather API. I was hoping I'd set up an autocomplete with Spott API but since It is not working yet, I'll use OpenWeather API to search cities.

The code:
```javascript
const input = document.getElementById("input");
input.addEventListener('keyup', async (event) => {
	event.preventDefault();
	if (event.keyCode === 13) {
		const typedString = document.getElementById("input").value;

		await axios(`https://api.openweathermap.org/data/2.5/weather?q=${typedString}&APPID=72a730baaa2ebd7a0edabe3d09b870c2`, {
			"method": "GET"
		}).then(response => {
			let data = response.data
			console.log(data);

			const city = document.querySelector('.city');
			city.textContent = `${data.name},`

			const country = document.querySelector('.country');
			country.textContent = data.sys.country

			const weather = document.querySelector('.weather');
			weather.textContent = data.weather[0].description

			const temp = document.querySelector('.degrees')
			temp.textContent = `${Math.round(data.main.temp - 273.15)}°`;

			const humidity = document.querySelector('#humidityRate')
			humidity.textContent = `${data.main.humidity}%`

			const cloudRate = document.querySelector('#cloudRate');
			cloudRate.textContent = `${data.clouds.all}%`

		}).catch(err => {
			console.log(err);
		});
	}
})
```
The code explained:
I am attaching an event listener to the input element: `keyup` which will fire when a key is released. Since I do not want the event to keep firing every other time. I have specified that I only want the event to fire when the user hits enter, keyCode 13. Next, I am making a get request to Open weather API then updating the data received to my page. I switched to Axios because I had a hard time working with JSON while using fetch. Axios on the other hand automatically transforms JSON which makes it easier for me to work with.

Here is the repo: [Weather App Repository](https://github.com/M-Tee/Weather-App).

I am also updating the date and time with javascript:
```javascript
let today = new Date()

const day = document.querySelector('#day');
day.textContent = `${today.getDate()}th`

const month = document.querySelector('#month');
month.textContent = today.toLocaleString('default', { month: 'long' })

const year = document.querySelector('#year');
year.textContent = today.getFullYear()
```

That was all for the day.
_Day 58_
internship on API concepts - asking for suggestions
Tags: help
Published: 2020-09-12 19:54:18

Hello Guys

I am a backend developer working on Node mostly and have a business client (not a software house) that wants me to remotely mentor one of their interns in an internship that covers concepts like building APIs, data extraction techniques, building integrations between different services ... etc.

I am not really sure what to teach him, or how to approach this? any concepts you think are more important than others? what exactly to cover and any suggested path to follow? are there any courses or resources you think can help?

It's also worth mentioning that the guy specialization is actually in data science and he is comfortable with Python so there is that too :P

I know it seems like a mess however they have no one else to cover these topics for him, so I'll have to give it a try in the hope that I might offer him something that helps him.

Your input will be really appreciated

Thank you
Monitor available IPs with Lambda and Cloudwatch
Tags: aws, devops, eks
Published: 2020-09-12 19:56:42

---
title: Monitor available IPs with Lambda and Cloudwatch
published: true
date: 2020-09-12 19:48:02 UTC
tags: aws, devops, eks
cover_image: https://dev-to-uploads.s3.amazonaws.com/i/nhvk4yb1am0m9kx05vf4.jpg
canonical_url: https://chrisdodds.net/monitoring-vpc-subnet-available-ips-with-lambda-and-cloudwatch/
---
I ran into a situation where I needed to keep track of available IPs related to an AWS EKS cluster and couldn’t find any off the shelf tooling in AWS or otherwise to do so.

Tangential gripe: The reason I needed the monitor is because [EKS doesn’t support adding subnets](https://github.com/aws/containers-roadmap/issues/170) to a cluster without re-creating it and the initial subnets that were used were a little too small due to reasons. I wanted to have a sense of how much runway I had pending AWS fixing the gap or me implementing a work around.

So, I cobbled together a Lambda function to pull the info and pipe it into Cloudwatch.

[Gist here](https://gist.github.com/chrisdodds/123abc5cffee2b72b2d3f0356c58c8f6)

I’m using tags to scope the subnets I want to track, rather than piping in everything – since Cloudwatch custom metrics cost money. But you could use whatever filters you wanted.

After getting the data into Cloudwatch, I was quickly reminded that you can’t alarm off of multiple metrics, so I used a math expression (MIN) to group them instead. This works for up to 10 metrics (this post should really be titled “The numerous, random limitations of AWS”), which luckily worked for me in this instance.

![](https://chrisdodds.net/wp-content/uploads/2020/09/Screen-Shot-2020-09-12-at-2.36.58-PM-1024x108.png)

Then I setup an alarm for the threshold I wanted and tested it – it worked. Fun times.

Photo by [Taylor Kopel](https://unsplash.com/@taylorkopel?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText) on [Unsplash](https://unsplash.com/s/photos/aws?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText)

The post [Monitor available IPs with Lambda and Cloudwatch](https://chrisdodds.net/monitoring-vpc-subnet-available-ips-with-lambda-and-cloudwatch/) first appeared on [Chris Dodds](https://chrisdodds.net/).
Microsoft September 2020 Patch Tuesday
Tags: security
Published: 2020-09-12 19:30:21

I just wanna told you: "This article is inspired by 'Catalin Cimpanu', 'cause somethings we need know this information and is a little hard to search about it, so... Thanks, Cimpanu!

If u use to Windows, is very important update every months (Patch Tuesday), 'cause has this updates:
 
*form:*

> CVE -> Common Vulnerabilities and Exposures
> the asteric* -> further steps to take after installing the updates
> MITRE -> The MITRE Corporation

our mate 'Catalin Cimpanu' say:
*"Of note is that this month, of the 129 vulnerabilities, 32 were classified as remote code execution issues, which are bugs that permit attackers to exploit vulnerable applications remotely, over a network."*

It's true, if u check in the Microsoft official page, the release of this month is severity 10/10

Check this CVE:

MITRE CVE-2020-1256
    *"An information disclosure vulnerability exists when the Windows GDI component improperly discloses the contents of its memory. An attacker who successfully exploited the vulnerability could obtain information to further compromise the user’s system.
    There are multiple ways an attacker could exploit the vulnerability, such as by convincing a user to open a specially crafted document, or by convincing a user to visit an untrusted webpage.
    The security update addresses the vulnerability by correcting how the Windows GDI component handles objects in memory."*

I mean, is usually see this type of pages (pishing, scam) and in this points it's patched 

Finally, this is the list of CVE patched:
* CVE-2020-0664
* CVE-2020-0856
* CVE-2020-0875
* CVE-2020-0914
* CVE-2020-0921
* CVE-2020-0928
* CVE-2020-0941
* CVE-2020-0989
* CVE-2020-1031
* CVE-2020-1033
* CVE-2020-1083
* CVE-2020-1091
* CVE-2020-1097
* CVE-2020-1119
* CVE-2020-1193
* CVE-2020-1210
* CVE-2020-1218
* CVE-2020-1224
* CVE-2020-1250
* CVE-2020-1256
* CVE-2020-1332
* CVE-2020-1335
* CVE-2020-1338
* CVE-2020-1589
* CVE-2020-1592
* CVE-2020-1594
* CVE-2020-1596 *
* CVE-2020-16851 *
* CVE-2020-16852 *
* CVE-2020-16853 *
* CVE-2020-16854
* CVE-2020-16855
* CVE-2020-16879
* CVE-2020-16884 *

*this is not a complete list of CVEs for this release* 
clarifies Microsoft

So... What's your thinking about?
Sorry for my syntax's, but isn't my mother tongue. 

PD: Windows 10 Security told: *'So good, it can block zero-days without being patched'*

Bibliography

* *Microsoft September 2020 Patch Tuesday fixes 129 vulnerabilities*, ZDnet, recovered from: https://www.zdnet.com/article/microsoft-september-2020-patch-tuesday-fixes-129-vulnerabilities/

* *September 2020 Security Updates*, Microsoft, recovered from:
https://portal.msrc.microsoft.com/en-us/security-guidance/releasenotedetail/2020-Sep
Debris: Fetch Random Fact to Your Readme
Tags: actionshackathon, bash
Published: 2020-09-12 19:25:28

[Instructions]: # (To submit to the GitHub Actions x DEV Hackathon, please fill out all sections.)
I like to know some fun fact. And usually I know it from wikipedia. But sometime I'm just to lazy to open wikipedia. So I thought why don't I just see the fact from site that I often visit, that's github. And so I decided to make this simple github action to fetch random fact to my Readme profile.

### My Workflow

I use this action on my github profile readme. You can see it here
{% github github.com/ekickx/ekickx %}
[Note]: # (Make sure to include the name of your GitHub Action and share where it's being used!)


### Submission Category: 

Wacky Wildcards


### Yaml File or Link to Code

```yaml
on:
  push:
    branches: master
  schedule:
    - cron: '30 17 * * *'
      
jobs:
  build:
    name: Update Readme.md
    runs-on: ubuntu-latest
    env:
      GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
    steps:
      - uses: actions/checkout@v2
      - name: Debris action
        uses: ekickx/debris@master 
        with:
          fact_args: 'today'
```

{% github github.com/ekickx/debris %}

[Note]: # (Our markdown editor supports pretty embeds. Try this syntax: `{% github link_to_your_repo %}` to share a GitHub repository)