teleren/devto huggingface dataset:
Doomsday Algorithm
Tags: javascript, math, react
Published: 2022-10-02 09:06:30

The Doomsday rule, Doomsday algorithm or Doomsday method is an algorithm of determination of the day of the week for a given date.

The algorithm is simple enough that it can be computed mentally, some people could usually give the correct answer in under two seconds

## How The Doomsday Algorithm work ?
Doomsday Algorithm takes advantage of each year having a certain day of the week upon which certain easy-to-remember dates, called the doomsdays

for example, the last day of February, 4/4, 6/6, 8/8, 10/10, and 12/12 all occur on the same day of the week in any year, we can use that to determine what day of the week for any date in the year if we know what day is the doomsdays for our year

After you have determined which day will be the doomsdays for the year you want to know, you can simply find out any day of the week for any date in the year by counting forward/backward from the nearest doomsday to the date you want to know

The question here is how can we determine what day the doomsdays will be for the year we want to know?

## The Rules of Doomsday Algorithm
I created an application based on this algorithm to determine the day of the week with an explanation of the algorithm directly on the date you entered. You can view it from here : [https://doomsday-algorithm.vercel.app/](https://doomsday-algorithm.vercel.app/)

Let’s take a random date and explain the algorithm to it for example 7/9/1812

1. Start by taking the last two digits of the year, this is your startingNumber in our case it will be (12)
2. Divide the startingNumber (12) by four and ignore the remainder : 12 / 4 = 3
3. Add the last result (3) to the startingNumber : 3 + 12 = 15
4. Find the remainder of last result (15) divided by 7 : 15 % 7= 1 ,(Or find the nearest number less than 15 and divisible by 7 and substravted from 15)

Now we want to find what is the century’s anchor day , we can simply know that from that table here

The table in repeat you can easily know the doomsday for any century

![Doomsday Century](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/39j81dkfjb5ddfk33fa2.png)

- After we determined the century’s anchor day Friday we will add the last result to that day _**Friday+ (1) = Saturday**_

Now we know the doomsday for a date year 1812 is Saturday we need to Find the closest doomsday and we can do that according to this table

![Doomsday Month](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/us5v5q5w6xpjrqhglcbs.png)

> (Note if the year is a leap year the doomsday for January will be 4 and February will be 29 and if is not a leap year January will be 3 and February will be 28)

we know now 5 September is Saturday now we can simply count from 5/9 to 7/9 the result will be **Monday**

> ( Note: If the difference between the two dates is large, you can subtract or add 7 until you reach the nearest number to the specified date, and then you can count )

**Resources**
[Doomsday rule](https://en.wikipedia.org/wiki/Doomsday_rule)
In One Minute : Swagger
Tags: api, beginners, programming, oneminute
Published: 2022-10-02 11:18:27


Swagger is a suite of tools for API developers from SmartBear Software and a former specification upon which the OpenAPI Specification is based.
The Swagger API project was created in 2011 by Tony Tam, technical co-founder of the dictionary site Wordnik.

{% embed https://youtu.be/9dovf71KShY %}

Swagger's open-source tooling usage can be broken up into different use cases: development, interaction with APIs, and documentation.

When creating APIs, Swagger tooling may be used to automatically generate an Open API document based on the code itself. 
This embeds the API description in the source code of a project and is informally called code-first or bottom-up API development.

Using the Swagger Codegen project, end users generate client SDKs directly from the OpenAPI document, reducing the need for human-generated client code.
As of August 2017, the Swagger Codegen project supported over 50 different languages and formats for client SDK generation.

When described by an OpenAPI document, Swagger open-source tooling may be used to interact directly with the API through the Swagger UI.


Official Website :- https://swagger.io/
Open API :- https://openapis.org/
AWS CLI vs Azure CLI
Tags: aws, azure, cli, opensource
Published: 2022-10-02 13:41:47

Hello, everyone!

I want to compare AWS CLI and Azure CLI. I want to make this comparison simple. So here we are,

| Feature | AWS CLI | Azure CLI |
|:---:|:---:|:---:|
| Platform | Have all common OS (Linux, MacOS, and Windows) + Docker. [Details](https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html) | Have all common OS + Docker. [Details](https://learn.microsoft.com/en-us/cli/azure/install-azure-cli) |
| Update CLI | Use the same way as installing | Have specific command to update `az upgrade` and support automatic update. [Details](https://learn.microsoft.com/en-us/cli/azure/update-azure-cli) |
| Source Code/Repository (Anyway, the star count maybe will be updated in the future) | Open Source. Have 12.9k stars ![stars aws](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/uzelr97rwlvzommcktiv.png) [Details](https://github.com/aws/aws-cli) | Open Source. Have 3.3k stars. ![stars az](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/f70t63i9538ve93gnj7a.png) [Details](https://github.com/Azure/azure-cli) |
| Programing Language | Python ![aws cli lang](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hgzkrcy8dtkgk3u81ul5.png) | Python ![az cli lang](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/k4g5to9v7oemximer9yu.png) |
| Contributors (The number maybe will be updated in the future) | 309 ![aws contributors](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/n1xeflegzemucdd3ug08.png) | 864 ![az contributors](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0idjgyr3p1xdn7gvqqai.png) |
| Configure CLI (Credentials) | - Manual `aws configure` <br> - Environment variables <br> - Shared credentials file <br> - Config file <br> - IAM Role <br> **Note**: Basically, you only need to provide profile + the credentials (ACCESS_KEY_ID & SECRET_ACCESS_KEY) <br> [Details](https://github.com/aws/aws-cli#configuration) | - Interactive sign in `az login` <br> - provide username & password `az login -u <username> -p <password>` <br> - Using service principal `az login --service-principal -u <app-id> -p <password-or-cert> --tenant <tenant>` <br> - Using managed identity `az login --identity` <br> [Details](https://learn.microsoft.com/en-us/cli/azure/authenticate-azure-cli) |
| License | [Apache 2.0](https://github.com/aws/aws-cli/blob/develop/LICENSE.txt) | [MIT](https://github.com/Azure/azure-cli/blob/dev/LICENSE) |

## Thank you

![Thanks](https://media.giphy.com/media/BYoRqTmcgzHcL9TCy1/giphy.gif)
SFDX Commands in Action
Tags: salesforce, sfdx, commands, salesforcecli
Published: 2022-10-02 14:33:47

The Salesforce CLI is a powerful command line interface that simplifies development and build automation when working with your Salesforce org.
Over the past few years I am using multiple sfdx commands from deploying metadata to running code snippet using sfdx command.

_**> Here is the consolidated list of all commands which are needed by developer during complete development life cycle**_

---

## 1. Retrieve code/metadata from org

_How to retrieve source from an org?_

sfdx commands are very flexible different types of metadata can be retrieved together.


```
//Example 1: Retrieve single file
sfdx force:source:retrieve -p force-app\main\default\triggers\AccountTrigger.trigger

//Example 2: Retrieve multiple file
sfdx force:source:retrieve -p force-app\main\default\triggers\AccountTrigger.trigger,force-app\main\default\classes\TriggerHandler.cls

```

---

## 2. Deploy code/metadata to org

_How to deploy source to an org?_

sfdx commands are very flexible different types of metadata can be deployed together.

```
//Example 1: Deploy single file
sfdx force:source:deploy -p force-app\main\default\triggers\AccountTrigger.trigger

//Example 2: Deploy multiple file
sfdx force:source:deploy -p force-app\main\default\triggers\AccountTrigger.trigger,force-app\main\default\classes\TriggerHandler.cls

```
---

## 3. Run Test class
_Can we run test class or test method using sfdx commands?_

Yes, here are few useful options using sfdx commands

```
//Running complete test class
sfdx force:apex:test:run -n "TestClass1,TestClass2"

//Another Way
sfdx force:apex:test:run -t "TestClass1,TestClass2"

//Run only specified test methods
sfdx force:apex:test:run -t "TestClass1.method1,TestClass2.method2"
```

---

## 4. Execute code snippet
_Definitely I do need to open developer console for executing code snippets?_

No, sfdx command is here for executing code snippets directly from terminal. 😀

```
sfdx force:apex:execute
```

---

## 5. Check logs using sfdx command
_How can I see logs stream in VSCode terminal?_

Here is the sfdx command…

```
sfdx force:apex:log:tail
```

---

## 6. Login to org directly from cli
_Did you forgot the password of sandbox? But you don’t want to reset it, since this sandbox is already setup and authorised by couple of other 3rd party applications like vscode,xl connector, data loader, metazoa, etc._

You are lazy like me to update password in all of these applications. Here is the sfdx command to rescue us.

```
sfdx force:org:open -u orgAlias
```

---
Happy Learning !!!
Playwright with Cucumber/JUnit 5 - Dependency Injection with PicoContainer
Tags: cucumber, java, testing, playwright
Published: 2022-10-03 00:25:35

### Dependency Injection

This project uses dependency injection to put the instance of TestContext into the step definition class. In a larger test project you would have multiple step definitions and you want an easy way to create common instances of things like the Playwright instance and BrowserContext. This also allows you to share data between steps in the same scenario like when we get and set the alert text.

This is implemented by including the maven dependency for pico-container earlier in the series and injecting this class through the Constructor of the step classes needing this class.

Constructor code in DemoSteps.java:

```java
public DemoSteps(TestContext testContext) {
        this.testContext = testContext;
        this.browser = testContext.getBrowser();
    }
```

Code using dependency injection to store alert text between steps in the same scenario:

```java
    @When("User clicks submit")
    public void userClicksSubmit() {
        DemoPage demoPage = new DemoPage(page);
        String alertText = demoPage.clickSubmit();
        testContext.setAlertText(alertText);
    }

    @Then("Verify alert {string}")
    public void verifyAlertToFillInResultIsShown(String alertText) {
        Assertions.assertEquals(alertText, testContext.getAlertText());
    }
```

Full **TestContext.java** class
```java
package io.tpan.steps;

import com.microsoft.playwright.*;
import io.cucumber.java.AfterAll;
import io.cucumber.java.BeforeAll;

public class TestContext {

    protected static Playwright playwright;

    protected static Browser browser;

    protected BrowserContext browserContext;

    protected Page page;

    @BeforeAll
    public static void beforeAll(){
        playwright = Playwright.create();
        browser = playwright.chromium().launch(new BrowserType.LaunchOptions() // or firefox, webkit
                .setHeadless(false)
                .setSlowMo(100));
    }

    @AfterAll
    public static void afterAll(){
        browser.close();
        playwright.close();
    }

    public Browser getBrowser() {
        return browser;
    }

    String alertText;

    public String getAlertText() {
        return alertText;
    }

    public void setAlertText(String alertText) {
        this.alertText = alertText;
    }
}

```
As always code is on available on [Github](https://github.com/terencenmnpan/TestAutomation/tree/main/PlaywrightCucumberExample)
Switching between multiple Terraform versions
Tags: terraform, devops, opensource, webdev
Published: 2022-10-03 09:45:28

Hey All,

In case you are using Terraform to provision and manage your infrastructure, you normally install a specific version on your machine (or on your CI servers).

But what if you wanted to install another terraform version to test it out? 

In case you have multiple environment in the same codebase, let's say dev and prod, and you deployed both of them using a fixed terraform version (1.2.7).

After a while a new terraform version is available (1.3.1). You can update the version on your machine and test if it works fine, if not re-install the older version ... Which can be a bit cumbersome ...

Or, you can use [tfenv](https://github.com/tfutils/tfenv) which is a Terraform version manager.


After installing tfenv, you can use the **tfenv list** command to list the available terraform versions you have installed:

```
~ tfenv list
  1.2.7
No default set. Set with 'tfenv use <version>'
```

There is a new terraform version available that I would like to test out.

To install it, you just simply run : 

```
tfenv install 1.3.1
Installing Terraform v1.3.1
Downloading release tarball from https://releases.hashicorp.com/terraform/1.3.1/terraform_1.3.1_darwin_amd64.zip
######################################################################### 100.0%
Downloading SHA hash file from https://releases.hashicorp.com/terraform/1.3.1/terraform_1.3.1_SHA256SUMS
Not instructed to use Local PGP (/usr/local/Cellar/tfenv/3.0.0/use-{gpgv,gnupg}) & No keybase install found, skipping OpenPGP signature verification
Archive:  /var/folders/jl/tfyd0yns2xxgb_58fj3ljslc0000gn/T/tfenv_download.XXXXXX.ouHdm2P4/terraform_1.3.1_darwin_amd64.zip
  inflating: /usr/local/Cellar/tfenv/3.0.0/versions/1.3.1/terraform  
Installation of terraform v1.3.1 successful. **To make this your default version, run 'tfenv use 1.3.1'**
```

List down all the installed terraform again:

```
tfenv list         
* 1.3.1 (set by /usr/local/Cellar/tfenv/3.0.0/version)
  1.2.7
```

You can see that the latest version is selected now.

If you'd like to switch to the old version, you simply run:
`tfenv use VERSION`

So:

`tfenv use 1.2.7`

Now you can see the default selected version:

```
tfenv use 1.2.7
Switching default version to v1.2.7
Default version (when not overridden by .terraform-version or TFENV_TERRAFORM_VERSION) is now: 1.2.7
➜  ~ tfenv list     
  1.3.1
* 1.2.7 (set by /usr/local/Cellar/tfenv/3.0.0/version)
```

This way you can test the newer version in your dev codebase in an easy way with just switching versions.

I hope you enjoyed this short blog.

Thank you for reading!
Batch script that scrolling each folder and copying the content of this folders
Published: 2022-10-03 16:31:56

i have list of folders, each one has a list of files with the same extension 
i want to write a batch script to scroll every folder and copy all the files on each folders

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/un2aqfsudrijbucntwau.png)
Best Ecommerce Tools to Your Business Growth
Published: 2022-10-19 05:20:36

There is no doubt that eCommerce has taken the business world by storm. In today's digital age, more and more businesses are turning to online platforms to sell their products and services.

If you're thinking of starting an eCommerce business, or if you're looking to take your existing business online, you'll need to choose the right tools to help you grow and succeed. In this article, we'll share with you the best [eCommerce tools ](https://www.cloudways.com/blog/ecommerce-tools/)to help you boost your business growth.


1. Shopify 

Shopify is one of the most popular eCommerce platforms in the world. It's user-friendly, scalable, and comes with everything you need to launch and grow your online store. Plus, it has a wide range of features and integrations that can help you run your business effectively.

2. WooCommerce 

WooCommerce is a WordPress plugin that turns your WordPress website into a fully-functional online store. It's user-friendly, flexible, and comes with a wide range of features to help you grow your business.

3. BigCommerce 

BigCommerce is another popular eCommerce platform that helps you build a professional online store. It's feature-rich, scalable, and comes with everything you need to launch and grow your business.

These are just some of the best eCommerce tools that can help you boost your business growth. Choose the right platform and tools for your business, and you'll be well on your way to success.
IBM zDay 2022 Recap: Speaking at zDay for The First Time | Optimizing Sustainability with LinuxOne
Tags: ibm, linux, linuxone, sustainability
Published: 2022-10-19 20:06:31

IBM zDay is a free one-day virtual conference event hosted by IBM about all things IBM zSystems. Global thought leaders come together to highlight industry trends, Innovations in AI, Quantum Computing, Mainframes, and a lot more! I had the pleasure of being invited to speak at zDay 2022 and open for Dr. Fan Jing Meng from IBM China, conducting a demonstration on the new IBM LinuxOne Emperor 4 and it’s impact on energy consumption.


![Speaker Lineup](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tbj41kzif9a8hqe8pj7x.PNG)

**Speaker Lineup**

zDay 2022 boasted a speaker lineup of some of the biggest names in Tech and Enterprise Computing such as Linus Sebastian from Linus Tech Tips, Ross Mauri—General Manager at IBM Systems, John Mertic—Program Director at The Linux Foundation, Meredith Stowell—VP at IBM Ecosystems, and many other industry
leaders.


![Team Intro](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/j8ssk5rgo3fpsx2ahdi6.PNG)

**Optimizing Sustainability**

My session focused on the effects of big data on the environment and what can be done for the “greening” of the IT sector. According to a report by IBM—titled “IT sustainability beyond the data center, Decarbonizing with hybrid cloud”—Collectively, data centers around the world consume 200 to 250 terawatt-hours (TWh) of electricity, according to the International Energy Agency (IEA). That’s roughly 1% of global electricity demand and approximately 0.3% of all global carbon emissions.9 Demand for data centers and network services will only continue to grow in the future, consuming even more electricity and producing even more carbon. Some estimates suggest that there has been a 43% absolute increase in the power capacity demand by data center operators between 2018 and 2021, and that the global data center market will grow by more than 30% between 2021 and 2027.10 Therefore, action to support further efficiency improvements, lower energy consumption, and reduced carbon impact from data centers is critical.

**IBM Z Linux One**


![LinuxONE Emperor 4](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/j9s9a97o59u49aj7sa0c.png)

This is where IBM’s new LinuxOne Emperor 4 system comes in. It helps organizations that care about achieving sustainability goals reduce energy costs and carbon footprint with a secure high-performance server platform for data-intensive workloads. To learn more about the IBM LinuxONE Emperor 4, head over to the [website](https://www.ibm.com/products/linuxone-emperor-4) and read more about how it can benefit your organization.


![LinuxOne Stats](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5vt81cuii2l6bcxr2f3l.PNG)

If you want to watch the entire demo and all of the other sessions from zDay 2022. Head over to the event website to get free access to the replays [here.](https://ibmzday.bemyapp.com/2022)
What is the proper length for a podcast?
Tags: podcast
Published: 2022-10-22 11:48:32


Podcasts come in a variety of sizes and forms.

Podcasts range in length from a minute to several hours. So, the major question is, what kind of stuff are you going to record?


If your episodes are suitable for bite-sized content, strive for 5 to 10 minutes.


If you wish to speak with a co-host, decide how long each chat will be (and make sure you have something to say, not just meandering gibberish) and keep to that time limit.


Are you putting together a story episode? Many story-based podcasts are around an hour long.


Long-form interviews and in-depth analyses? There are several that last more than an hour - up to 3-4 hours.

What is important is that you have something to say.


Turning on the microphone and making it up as you go is a recipe for disaster.


"Be On, Be Good, Be Gone," my employer pounded into my head early in my radio career.


Be On

Meaning: Be ready to speak up and be intriguing. Have a clear goal in mind and be prepared to deal with anything unexpected that may arise.


Take Care

Meaning: When you open the microphone, your audience expects you to present them with something enjoyable, thrilling, amusing, motivating, or informative that will keep them listening. You must deliver.


Go Away

Meaning: Do not overstay your welcome. When you've completed your mission, get out of dodge.
"Take as much time you need, but be as brief as you can," radio coach Tommy Kramer adds.


Understand Your Audience


As you develop your episodes, you will discover what your audience appreciates and expects from you based on how they react to your content.


Make sure you're surveying your audience, allowing them to contact you via email, and creating a community with your new listeners. It also allows you to ask them questions.


This is the most effective method for determining how to improve and change the length of your episodes.


Know Your Audience


As you develop your episodes, you will discover what your audience appreciates and expects from you based on how they react to your content.


Make sure you're surveying your audience, allowing them to contact you via email, and creating community with your new listeners. It also allows you to interrogate them


This is the most effective technique to modify and adjust the length of your episodes.


Listen to #1 [Malayalam Podcast](https://www.themalayali.in/) from kerala
Next.js E-commerce StarterKit (2022)
Tags: ecommerce, nextjs, starterkit, tutorial
Published: 2022-10-22 15:59:58

## Intro

Creating an e-commerce website might look like a simple task, but in fact, it is a pretty complicated one: you need to find a Backend, an API, organize product listings on the Frontend, a catalog with hierarchy, filters, and search, a cart and a checkout. And don't forget about image resize. And all these parts should be done in a modern way, e.g. with Next.js and SSG.

## The solution

Ready to use Next.JS E-Commerce Starter kit!

https://github.com/kirill-zhirnov/boundless-nextjs-sample
Demo: https://blank.demos.my-boundless.app/

There are 2 ready to use themes:

https://github.com/kirill-zhirnov/boundless-marsfull-theme/
Demo: https://mars.demos.my-boundless.app/

https://github.com/kirill-zhirnov/boundless-moon-theme
Demo: https://moon.demos.my-boundless.app 

The checkout is a standalone component, which can me easily customized: https://github.com/kirill-zhirnov/boundless-checkout-react

Themes use BoundlessCommerce (https://boundless-commerce.com) as a backend. There is an absolutely free tariff plan which covers small business needs.

These Next.JS sites can be easily deployed to Vercel or Netlify. If you want a longread about creating NextJS Ecommerce website - please visit our blog (I don't want to do a copy/paste :)): https://boundless-commerce.com/blog/how-to-create-a-nextjs-e-commerce-website

And if any question - please contact us - we are happy to help!
Simple Password Generator
Tags: generator, python
Published: 2022-10-22 16:30:16

Here is a simple python generator that use the "Random" module with a random.sample() method. The generated password is a combination of upper and lowercase letters, numbers and symbols. To make the password more complex and not easy to hack, the length of the password has been set to 20.

Give it a try, feel free to improve it and let me know!

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