teleren/devto huggingface dataset:
Vanilla JavaScript get following Monday
Tags: javascript
Published: 2020-12-23 05:13:51

In today's article, I wanted to check something very specific.
Imagine we need to know the first upcoming Monday?

This can become very tricky because you will need to know if it's a new month or even a new year.

Luckily there is a quite easy way to do this.

So first we'll build the code based on whatever day it is you are reading this.

Then we will demo an end of month/year date.

## JavaScript get following Monday from today

Let's start by defining what today is:

```js
let today = new Date();
```

Now we can make the wireframe of our function using an [ES6 Arrow function](https://daily-dev-tips.com/posts/javascript-arrow-function/).

```js
getNextMonday = input => {
  // Do something
  return input;
};
```

The function is called getNextMonday, and it accepts one input.
It then needs to do something with the input and return something.

So how do we go about finding the next Monday?

Let's modify the input we receive.

```js
input.setDate(input.getDate() + ((8 - input.getDay()) % 7));
```

What we do here is set a new Date based on whatever the input was.

The `input.getDate()` will return 23 if you are reading this on the 23rd of December. Which is a Wednesday (3rd day of the week)

Then add the number of days till a Monday so in the case of the 23 it would be (23 + (8 - 3) % 7); = 28

Which happens to be a Monday! Yeey 🎉

Then we can return a [template literal](https://daily-dev-tips.com/posts/javascript-template-literals/) where we merge the dates.

```js
return `The next monday is ${String(input.getDate()).padStart(2, '0')}-${String(
  input.getMonth() + 1
).padStart(2, '0')}-${input.getFullYear()}`;
```

Quite a chunky one, but it fixes the dates by [adding leading zeroes to our date](https://daily-dev-tips.com/posts/vanilla-javascript-add-leading-zeroes-to-date/) using the padStart method.

The full function will then be:

```js
getNextMonday = input => {
  input.setDate(input.getDate() + ((8 - input.getDay()) % 7));
  return `The next monday is ${String(input.getDate()).padStart(2, '0')}-${String(
    input.getMonth() + 1
  ).padStart(2, '0')}-${input.getFullYear()}`;
};
```

## Making sure it's the valid end of month

Now, this worked since 23 + 5 = 28, but what if we go further than the number of days in a month?

Let's take New Years' eve 2020 which is on a Thursday again.
The date is now 12-31-2020 (31st of December).

```js
let today = new Date('12-31-2020');
```

Then if we run our function calculation the day will be?

(31 + (8 - 4) % 7); = 35

Which is weird right, there are only 31 days in December.
But still, because we are doing these modifications on a Date object JavaScript understands it needs to count further.

That said the first Monday from New Years eve is:

{% codepen https://codepen.io/rebelchris/pen/qBajZwR %}

P.s. it's `The next Monday is 04-01-2021`.

### Thank you for reading, and let's connect!

Thank you for reading my blog. Feel free to subscribe to my email newsletter and connect on [Facebook](https://www.facebook.com/DailyDevTipsBlog) or [Twitter](https://twitter.com/DailyDevTips1)
Hello, World! I Started My Blog In Plain HTML
Tags: html, blog, beginners, webdev
Published: 2020-12-23 05:04:02

Today is a special day for me: I finally created my blog, what I has been thinking of for years 🎉. If you are reading this on another platform, it is an automatic crosspost, feel free to [check out my website].

## Plain HTML is fun 🤓

Because I didn't want to give myself another reason to keep procrastinating, I decided to start this blog dead simple: plain HTML, no inline style, no CSS, no JS, whatsoever.

Surprisingly, after making the decision, I realized that HTML and the web were originally created for people to write, share, and communicate information. That why we have HTML tags `title`, `article`, `header`, headings ( `h1` `h2` `h3` `h4` `h5` `h6`), paragraph (`p`), etc, they're all for writing articles and sharing stories. Over time, thanks to more and more powerful computers and browsers, HTML/CSS/JS became more and more like a framework to create interactive applications on the web.

This is such an interesting _Aha!_ movement for me because I started with game and desktop programming, which are all about visualization and interactivity. All of my previous experience with web development were also about creating beautiful and interactive web applications. I've never happened to think of HTML as a means for writing and sharing stories.

This also answered one of my biggest unsolved questions in programming - why on earth there're many different HTML tags that have the same visualization and all the weird workaround-like positioning techniques ( `float`, `clear: fix`, etc). Coming from game and desktop development, absolute position, flex, and grid were always obvious options when it comes to layout and positioning for me. Now, it all makes sense 🤯 and it's very interesting to see how HTML - the core of The Internet has evolved over time.

Alright, that is it. I thought that I were gonna write more about why I started this blog and what value you can get from it, but I ran out of time, gotta write it tomorrow then.

<!-- Links -->

[check out my website]: https://phuctm97.com
Being Ambitious Is A Myth
Tags: career, blog, startup, motivation
Published: 2020-12-23 05:03:57

For the whole past of my life, I had always thought that being successful and being cool is what "being ambitious" means to be. I always wanted to be respected by friends, college friends, highschool friends, relatives, and everyone, as many people as possible - I thought that is ambition. Now, I see that is **bullshit**. I'm saying this to myself and I hope you aren't in the same situation, but if you are, you know you aren't alone.

So, why is that **bullshit**?

There is nothing bad about aspiring to be successful, the bad thing is **the definition of it**. For me and most people starting up, I believe, it is to have a lot of money and to be respectable. It sounded perfectly normal until recently I watched [Gary Vee's video] and went through a couple of other ideas including [Naval's famous tweet]. I wanted to be like the people I admired, I wanted to have the money and the status they have - what I had always defined as "being successful". The problem is I skipped **the process in between**, the even more serious problem is I **wanted to skip that process**, I only wanted the result. Whereas, for Gary Vee and Naval, they enjoyed the process, their definition of ambition is the romantics of the process, they wanted to create as many assets and value as possible, money and status are by-products. They were successful when they said nothing about their success, whereas I wanted to be successful to be able to talk about myself, I wrote blog posts to get people's attention, I tried to start a company to say "I'm a CEO of this successful company". I wanted to be an asshole. Now you see how it's all bullshit?

I'm still not 100% sure that I understand being ambitious correctly now, but from now on, being ambitious for me is to believe in something good for people and the world, go do it, make it happen, and enjoy the process of doing it. The more value I want to create, the more people I want to help, the bigger my ambition is, there is nothing about me having more money and higher status, me is just another by-product of what I enjoy doing everyday.

<!-- Links -->

[gary vee's video]: https://youtu.be/qRj144Gd7EA

[naval's famous tweet]: https://twitter.com/naval/status/1002103360646823936
Python3 Programming - Exercise 7 - String operations and function
Tags: python, programming, beginners, tutorial
Published: 2020-12-23 04:59:09

## String operations and function

A string is a sequence of at least zero characters enclosed within (delimiter by) an opened and closed single ( `''` ) or double ( `""` ) quotation marks. These include any character, even space or numbers. `Eg: 'swift Python', "Alan Turing", "Michael Jordan - 23"`

## String operations

These are operations done on strings objects. These operations are `string concatenation` and `string repetition`. We use the addition, `+`, and multiplication, `*`, operators, respectively, to concatenate (_join_) and repeat strings.

### Example

Concatenation, in this context, is adding one string to another string.

```Python
# String concatenation
first_name = 'Daniel'
last_name  = "Doe"
full_name = first_name + " " + last_name

# we added the first name, space and then the last name to
# produce a full name. The " " is an empty string but
# with space between the delimiters
# output => Daniel Doe
# Without space, we'd have, DanielDoe as the output

# String repetition
# Lets say we want to repeat a particular string for n
# number of times, we do, string * n.
# Lets try to repeat "Hello" three time
h = "Hello"
print(h * 3)
# output=> HelloHelloHello
```

## String function

These function will help us format the string. There is a lot of these functions on the Python [docs][doc-site].

### Calling the function

A function as we would discuss later is a piece of code that **does** something - performs certain computation. Do `my_string.function()` to call a string function on a string object.

```Python

########### String functions ###########

name = "John"

# change of a name to lower case
print(name.lower())

# change of a name to upper case
print(name.upper())

# capitalize of a name - the first character becomes upper
# and the rest lower
print(name.capitalize())

# return string as a title format
print(name.title())

# remove (strip) 'h' from the name
print(name.strip('h'))

# find the length or size (number of characters) in name
print(len(name))

# split a string by some char
str_split = "hello world"
str_list = str_split.split(' ')  # ['hello', 'world']
print(str_list)

# join
list_str = ['hello', 'world']
new_str = " ".join(list_str)
print(new_str)  # "hello world"

# join with some character, say $
list_str = ['hello', 'world']
new_str = "$".join(list_str)
print(new_str)  # "hello$world"

# There is a whole lot on the Python home page
```

## Practical

- Write a program to take input from the user, print the input, separated by a short-dash, `-`, and the length of the string. `Eg: input='Doe', output=Doe - 3`
- Write a program that reads data from the user and converts the data to lower case, upper case, title and capitalize.

## Summary

- String concatenation - add ( join) one string onto another. `Eg: name = 'Future' + ' ' + 'Dann'.`
- String repetition - repeat a string for _n-times_. `Eg: print("Green tea" * 2).`
- Do `my_string.function_name()` to call a string function.

#

[doc-site]: https://Python.org
Magento Development Company In UK
Tags: magento
Published: 2020-12-23 04:56:03

Magento is a popular open-source platform used to build customized eCommerce websites for all types of businesses. Whether you’re a startup and need a new website from scratch or you want to migrate your current e-commerce store to the platform, we’re here to help. Here’s how Magento can benefit you by taking your business to the next level.

If you’re searching for a Magento Development Company In UK, look no further than Tecocraft. As established enterprise Magento developers, we pride ourselves on producing versatile Magento eCommerce solutions that help businesses grow year-on-year. Our certified Magento development team ensures that your eCommerce site is built for optimum performance, conversion rates, and reliability.
Web - https://www.tecocraft.co.uk/magento-development/
Demonstrating Geo Distributed Active-Active Redis Enterprise using Docker Desktop for Windows
Published: 2020-12-23 04:34:57

## Pre-requisite

- Docker for Windows

## Steps

## Clone the Repository

```
git clone https://github.com/collabnix/redisplanet
cd redisplanet/ee/active-active/
```

## Setting up Network

```
./network-setup.sh
```

## Setting up Redis Enterprise

```
./rs-setup.sh
```
Setting up Geo Distributed Active-Active Redis Enterprise Cluster on Google Cloud Platform
Published: 2020-12-23 04:33:47

## Pre-requisite

- Create 3 Ubuntu 18.04 LTS instances, each of 6GB on GCP
- Chose Asia for 1st, US for 2nd & Europe for 3rd Instances
- Install Docker on each of these nodes

## Cloning the Repository

```
git clone https://github.com/collabnix/redisplanet
cd redisplanet/ee/active-active
```

```
$ sudo docker run -d --cap-add sys_resource --name redis-node-01 -p 8443:8443 -p 9443:9443 -p 12000:12000 redislabs/redis
```

```
 sudo docker ps
CONTAINER ID        IMAGE               COMMAND             CREATED        
     STATUS              PORTS                                             
                                                                           
                                NAMES
36f10d5e16ec        redislabs/redis     "/opt/start.sh"     19 seconds ago 
     Up 11 seconds       53/tcp, 5353/tcp, 8001/tcp, 8070/tcp, 0.0.0.0:8443
->8443/tcp, 8080/tcp, 0.0.0.0:9443->9443/tcp, 10000-11999/tcp, 12001-19999/
tcp, 0.0.0.0:12000->12000/tcp   redis-node-01
```

Wait till 1 minute to let Redis Enterprise come up.
Building 3-Node Active-Active Redis Enterprise Cluster for Developers using Docker Desktop for Mac
Published: 2020-12-23 04:32:59

## Prerequisite

### Clone the Repository

```
git clone https://github.com/collabnix/redis
cd redis/ee/active-active/
```


## Sequence

```
sh network-setup.sh
```


```
sh rs-setup.sh
```

```
sh connect-networks.sh
```


```
sh cluster-setup.sh
```

```
sh crdb.sh
```
Test your Internet Speed through the Command Line
Tags: linux, windows, mac, productivity
Published: 2020-12-23 04:25:15

In this quick post, I will be sharing a simple trick to test your internet speed through the command line. I know you can test your internet speed through a web browser, but there might be a few reasons for which you would prefer the command line tool instead. Maybe you’re remotely connected to a server via ssh, and want to test speeds on that machine. Maybe you’re already used to using commands to troubleshoot your network, and want to add a speedtest to your toolkit. Or, maybe you just think the command line is cool.

Whatever be the reason, testing your internet speed through the command line is much faster and easier. All you need to do is to install a package called **speedtest-cli**.

### Installing speedtest-cli on Linux

On Ubuntu(or any other Debian based distro), run:

```
sudo apt install speedtest-cli
```

For other Linux distros, you must change the apt with the respective package managers:

- `dnf` for Fedora
- `pacman` for Arch
- `yum` for CentOS
- `zypper` for openSUSE

### Installing speedtest-cli on Windows

Installing speedtest-cli on Windows is slightly more complicated. This is because first, you need to [download and install Python](https://docs.python.org/3/using/windows.html#the-full-installer). Then you need to ensure that both python and pip are added to the system PATH. But if you already have them installed, no worries! Just open the command prompt and run:

```
pip install speedtest-cli
```

### Installing speedtest-cli on macOS

The simplest way to install speedtest-cli on a Mac is using **Homebrew** , the open-source package manager for Mac. Check out this [guide to installing Homebrew](https://brew.sh/) if you don’t have it set up (if you use the command line a lot, you should absolutely install Homebrew).

Once Homebrew is set up, you can install speedtest-cli with a simple command:

```
brew install speedtest_cli
```

Note the _underscore_ in the package name. For some reason, the name is different in Homebrew than the Linux package manager.

### Running speedtest-cli

Testing your internet speed using the command line is the same on all platforms. All you need to do is to type speedtest and hit the Enter key.

![](https://cdn-images-1.medium.com/max/736/1*1ku7Av-fgK8hxYiIpRzfTw.png)

I hope you found this post helpful.
Thanks for reading.🙏
How to add more simulator in Xcode 12 ?
Tags: ios, xcode, macos, programming
Published: 2020-12-23 04:22:35

Today's I came across an issue while upgrading Xcode 11 to 12. Not able to find an option to add devices which support iOS older versions like 12,13 etc. Because Xcode 12 came with iOS 14 default version. When we selected to add a new Simulator then the iOS option was coming only iOS 14 no other option to add. While doing google found one  [StackOverflow question](https://stackoverflow.com/questions/64075441/xcode-12-download-more-simulators-runtime-is-empty/65413382#65413382) which was having same issue. But all of the answers do not look straight forward. 

So, I tried the simplest thing which generally all apps have an option to search inside the app. Below are steps to do the same. 


1.  Open Xcode 12 app
2.  Go to menu -> Xcode -> Preferences 
![Preferences](https://cdn.hashnode.com/res/hashnode/image/upload/v1608660828088/C8iJReiBN.png)
3.  Go to component tab shown like below picture 👇🏻
![Component](https://cdn.hashnode.com/res/hashnode/image/upload/v1608661664791/xHkHTkFUA.png)
4. Then start installing whichever iOS version would like to install. Once its install iOS version
5. To add a simulator. Go to -> Xcode menu -> Open Developer tool -> Simulator 
6.  Simulator menu -> File -> New Simulator. It will show a list of iOS available for the device. 
![Screenshot 2020-12-22 at 11.47.02 PM.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1608661033370/erBZc6hv0.png)
7. Select Device name -> Select Device model -> iOS version -> Create Simulator.


References : 
https://stackoverflow.com/questions/64075441/xcode-12-download-more-simulators-runtime-is-empty/65413382#65413382

Hope this helps you. Thanks for reading this blog. If any feedback feel free to reach out to me.
Data Structures in Kotlin | Linked-List
Tags: kotlin, android, datastructures, programming
Published: 2020-12-23 04:02:04

Hola Amigos! 🙌, I do tech blogging at [AndroidBites](https://chetangupta.net/), do check it out.

This page is dedicated to my learning of DataStructure. I never took time to learn them up and always been scared of them, but actual growth comes from fighting your fears, so I have decided to create my own version of them and entirely in Kotlin.
So my aim is to :
* Create my own data structure implementations
* provide them with the behavior as close the standard library
* Battle-tested and Entirely in Kotlin

I believe in sharing so if you like to share too your always invited to contribute! 🤩
Let's grow together 💪🏻 ! happy hacking 💻. 
P.S : Don't forget to show love and support 🥰 by sharing! & providing feedback! 📝 and PRs are always welcome

Chao!

# 📖 Repository
## [DataStructure-in-Kotlin](https://github.com/ch8n/DataStructure-in-Kotlin)

# ⏰ MileStones 
## [Linked-List 1 : Create| Read | Update | Delete]((https://github.com/ch8n/DataStructure-in-Kotlin))

# 👥 Social
Stalk Me 👀 : <br>
[LinkedIn](https://bit.ly/ch8n-linkdIn) | [Medium](https://bit.ly/ch8n-medium-blog) | [Twitter](https://bit.ly/ch8n-twitter) | [StackOverflow](https://bit.ly/ch8n-stackOflow) | [CodeWars](https://bit.ly/ch8n-codewar) | [WorkX](https://bit.ly/ch8n-home) |[Github](https://bit.ly/ch8n-git) | [Instagram](https://bit.ly/ch8n-insta) | [Youtube](https://bit.ly/ch8n-youtube) 

© License
```markdown
Copyright [2020] [Chetan gupta] [chetangupta.net]
   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

     http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.
```
AZ-303 Azure Active Directory [Module 1]
Tags: azure, az303, architect, certification
Published: 2020-12-23 03:23:36

AZ-303 Azure Architect Technologies - Module 1 is about Azure Active Directory. 

## Azure Active Directory 
{% youtube O3zj-UoJKTc %}

## Resource Group, Management Group, Subscription Limits
{% youtube LVbFgEY0xhc %}

##  Multi-factor Authentication and Conditional Access
{% youtube KfsaznlsBRU %}

## Resources
Official Exam Page 
https://docs.microsoft.com/en-us/learn/certifications/exams/az-303
(refer to the “Skilled Verified” and “Two-ways to prepare (online)” section)

Video demo on Azure AD focusing on AZ-303 Exam
For more such please subscribe https://www.youtube.com/channel/UCUzFKvlZOm3ukAiF59B_HgQ
AZ-303 Azure Architect Technologies - Introduction
Tags: azure, az303, architect, certification
Published: 2020-12-23 03:15:39

## Introduction 
{% youtube FRYEVosAl1U %}

## Resources
Official Exam Page 
https://docs.microsoft.com/en-us/learn/certifications/exams/az-303
(refer to the “Skilled Verified” and “Two-ways to prepare (online)” section)

Youtube Series https://www.youtube.com/playlist?list=PLPIVZsyfpXt8kQj1WCuEwzwyXYgiUqXEQ
Intermediate or Advanced books on Java
Tags: help, java
Published: 2020-12-23 03:08:13

Java is one of the skills that my application architect was looking for and I have a year worth of experience on it using Spring Boot, I also have knowledge of Design Patterns and data structures.

However, I'm a Junior so I still can't confidently say that **I know Java**, I feel stuck.

I'd appreciate any book suggestions that could help me feel more comfortable with Java, intermediate or advanced books.

Please and thank you! :)
Grid vs Flexbox
Tags: css
Published: 2020-12-23 03:05:38

# Introduction

In a previous blog, I mentioned the difference between Grid and Flexbox being a two dimensional VS a one dimensional difference. But I didn't elaborate, and today I would like to take the chance to.


### Grid
The Grid in CSS works in two dimensions at the same time. This means that it works on both the X and Y axis. If you remember the grids from way back in grade school, it actually turned out to be a great representation of this concept while simultaneously being EXACTLY that.

### Flexbox
Flexbox in CSS works in one dimension at a time. Distinct from Grid, it only works on either the X axis OR the Y axis. 

## How are they similar?
Grid and Flexbox both are able to operate based on columns and rows. Where the Grid represents itself as two-dimensional and Flexbox as one dimensional, these properties operate independently regardless of whether we set the items within them as a column or row.

I found a personal use that sets them apart on my personal portfolio where I display my skills. I used Grid since it did what Flexbox can't... to my knowledge. Please correct me if I'm wrong on this. 

There is a property with grid that I used `grid-template-rows: 1fr 1fr 1fr` which each stand for a fraction of the row space. There's some math involved in the background, but let's just leave at this: There are three items in one row, and they each take up 33.33333% of the total width of the grid container. 

Flexbox offers another property called `flex-wrap: wrap` which would allow for items to wrap to the bottom row when the screen is resized. Although we would provide a similar setup, Flexbox is operating on one dimension. Ultimately, I could not get the behavior I was seeking just using Flexbox.


# Conclusion
Grid and Flexbox have their unique purpose in CSS. There could be an entire book we could write on using them individually or together, but I'll save your eyes. :wink: I'd like to give a disclaimer that I am not an expert in CSS, but I'm eager to keep learning about the technical concepts. Please share your thoughts in the comments. 

Happy holidays, everyone!