teleren/devto huggingface dataset:
Valid Anagram
Tags: dsa, python, beginners
Published: 2022-02-15 12:13:26

##Instructions
Given two strings s and t, return true if t is an anagram of s, and false otherwise.

An Anagram is a word or phrase formed by rearranging the letters of a different word or phrase, typically using all the original letters exactly once.

####Example

```python
Input: s = "anagram", t = "nagaram"
Output: true
Input: s = "rat", t = "car"
Output: false
```
##Approach
We can sort the given strings and compare if they are equal.

###Implementation

```python
def isAnagram(self, s: str, t: str) -> bool:
        return sorted(s) == sorted(t)
```
This approach has a time complexity of O(nlog(n)) because of sorting. 
The space complexity if O(1)

##Approach 2
We can use a hashmap and checking if the count of each letter is the same in both strings.
First we check if the strings have the same length because if they are not of same length we immediately return false.
We initialize a hashmap and iterate through the strings to determine the occurrence of each letter.

```python
def isAnagram(self, s: str, t: str) -> bool:
        lookup = {}
        for i in s:
            if i not in lookup:
                lookup[i] = 1
            else:
                lookup[i] += 1
        for i in t:
            if i in lookup:
                lookup[i] -= 1
            elif i not in lookup or lookup[i] == 0:
                return False
        
        return True if max(max(lookup.values()), 0) == 0 else False
```
This has a time complexity of O(n) and space complexity of O(n).

We can also use a set to achieve the same results

```python
def isAnagram(self, s: str, t: str) -> bool:
    if len(s)!=len(t):
       return False
       for i in set(t):
           if s.count(i)<t.count(i):
              return False
       return True
```
Agile Testing Principles and Challenges
Tags: agile, testing, webdev
Published: 2022-02-15 11:52:29

Agile Testing requires testers and developers to work together. Only during the development cycle can testers provide comments to developers.

## The primary Agile Testing Principles are as follows:

1. **Continuous testing** is a key component of agile testing. Testing is conducted on a constant basis to ensure that it keeps pace with progress.


Source: read Full Article: [https://www.testscenario.com/agile-testing-principles-and-challenges/](https://www.testscenario.com/agile-testing-principles-and-challenges/)

## Agile Testing's Difficulties

While agile testing provides several advantages, it also presents numerous challenges:

1. **Changing Requirements:** If requirements change or stories are dropped during the sprint, the testing that has already begun must be deleted. It abruptly alters the scope of testing, necessitating the restart of testing for the new tales.



**Solution**: When a requirement changes, the tester should ensure that they provide as much information as possible with their team. Information such as which test cases have been performed, which portions of the programme have not yet been tested, and so on. It may provide developers with guidance on how to modify the code without impairing its quality.



Is This Something You're Interested in? Contact Testscenario [Mobile app Testing](https://www.testscenario.com/mobile-app-testing-services/)
CSSBattle Target#4
Tags: css, webdev, beginners, programming
Published: 2022-02-15 11:32:56

_Hey everyone👋,
  I am back with the **CSSBattle** Series✨!_
This article is for [Target#4 "Ups n Downs"](https://cssbattle.dev/play/4) on [CSSBattle](https://cssbattle.dev/)

![Target 4 Ups n Downs](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cn85updsi6rsyhnawbk8.png)
 
 

####The best approach I could come up till now is stated below.

```css
<p><p id="b"><p><style>
body{
display:flex;
margin:134 50;
background:#62306D}
p{
width:100;height:100;
background:#F7EC7D;
border-radius:0 0 50% 50%}
#b{
transform:rotate(180deg);
position:relative;top:-100
```
This was my shortest solution condensing to **196 characters.**


#### Another approach using the CSS grids is as follows
```css
<p><p id="b"><p><style>
body{
margin:-16 50;
background:#62306D;
display:grid;
grid-template-rows:150px 150px;
}
p{
width:100;height:100;
background:#F7EC7D;
border-radius:0 0 50% 50%;
grid-row:2;
}
#b{
transform:rotate(180deg) translateY(100px);
```

Comment down your way of doing the same.
Stay Tuned for daily updates regarding all the challenges on CSSBattle.


###Want to connect?
[You can connect with me here](https://linktr.ee/prakhartandon)
Make your website carbon neutral
Published: 2022-02-15 11:32:16

Hey y'all,

If the internet were a country, it’d be the 6th most polluting.

We were gobsmacked to learn this. Somehow, after more than 20 years of using the internet and 15 years building it, it just had never occurred to us. Out of sight, out of mind.

So we made a little service to help people figure out their carbon footprint, get insights on how to reduce said footprint, and remove what they can't reduce through carbon removal technology.

We're looking for beta testers and general feedback!

Check it out at [https://beta.backspace.eco/](https://beta.backspace.eco/)
Common errors found when generating Android certificates (and how to fix them!)
Tags: android, appgallery, huawei
Published: 2022-02-15 11:31:21

AppGallery supports two kinds of signing certificates: one that is totally generated by AppGallery Connect and the other one that is generated by developers. Here I will share some solutions with you for the common errors reported during the signing certificate generation.
The command in the [official document](https://developer.huawei.com/consumer/en/doc/development/AppGallery-connect-Guides/agc-appsigning-introduction-0000001051379577) is as follows:

{% gist https://gist.github.com/devwithzachary/4770e84fc6e46bf89faa1dbee2fd2844 %}

## Error 1 - "No value provided for flag: include-cer"
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/z1eheb0iclw6zhjjrkoz.png)
Cause: It is not the correct **pepk.jar** file. Normally, its file size is around 2 MB. Check whether it is the file that was provided by Android Studio.
Solution: Use the correct **pepk.jar** file that you can get from [Google](https://www.gstatic.com/play-apps-publisher-rapid/signing-tool/prod/pepk.jar).

## Error 2: "java.io.IOException: Keystore was tampered with, or password was incorrect"
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6zcmwajzi4klv2ax9c33.png)
Cause: The keystore password is most likely not correct.
Solution: Enter the correct password.

## Error 3: "Unable to export or encrypt the private key"
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4yv8j8nvqhdrojdsv6fo.png)
Cause: Incorrect password. The keystore password is entered correctly, but the key file password is entered incorrectly when entered for the second time.
Solution: Enter the correct **key** file password. 

## Error 4: "Unable to parse the input:"
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hkgfyhkc6pdk3cja3ce3.png)
Cause: The length of the encryption key is incorrect. Check whether you have copied the complete encryption key.
Solution: Use the complete encryption key.

## Error 5: "java.lang.IllegalArgumentException: publicKey should be 68 bytes"

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cdt1yt2zg6drnfgodvau.png)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/iecxcvh231mrdnag4ra9.png)
Cause: The length of the encryption key is incorrect. Check whether you have copied the complete encryption key.
Solution: Use the complete encryption key.

## Error 6: "java.lang.IllegalArgumentException: Hex encoded byte array must have even length but instead has length: 143."
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/h2ppgnc0jp7kt54cffy5.png)
Cause: The encryption key is too long.
Solution: Use the correct encryption key

## Error 7: "java.security.GeneralSecurityException: point is not on the curve"
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/whesbyndq5enqenuqts4.png)
Cause: The encryption key is incorrect.
Solution: Use the correct encryption key.
Backing up Prometheus using TSDB Snapshots : Kubernetes/OpenShift
Tags: prometheus, backup, kubernetes
Published: 2022-02-15 11:30:00


> These are my quick-and-dirty brain-dump notes to myself on how to backup prometheus database running on k8s or OpenShift

* Get Token for API Authentication and Prometheus API Route URL
```
    oc whoami -t
    oc get route -n openshift-monitoring | grep -i prometheus
```
* Run sample curl request

```    
    curl -ks -H ‘Authorization: Bearer 0za4LjX9xPcqDjhWaufkgcQGo4grqA7ws4zvHrqgfY4’ ‘[https://prometheus-k8s-openshift-monitoring.apps.ocp4.cp4d.com/api/v1/query?query=ALERTS'](https://prometheus-k8s-openshift-monitoring.apps.ocp4.cp4d.com/api/v1/query?query=ALERTS') | python -m json.tool
```    

* Create TSDB Snapshot
``` 
    curl -X ‘POST’ -ks -H ‘Authorization: Bearer 0za4LjX9xPcqDjhWaufkgcQGo4grqA7ws4zvHrqgfY4’ ‘[https://prometheus-k8s-openshift-monitoring.apps.ocp4.cp4d.com/api/v2/admin/tsdb/snapshot'](https://prometheus-k8s-openshift-monitoring.apps.ocp4.cp4d.com/api/v2/admin/tsdb/snapshot') | python -m json.tool
``` 
* You might get an error, so you first need to enable Admin APIs
``` 
    {
     “error”: “Admin APIs are disabled”,
     “message”: “Admin APIs are disabled”,
     “code”: 14
    }
``` 
* Enable AdminAPI
``` 
    oc -n openshift-monitoring patch prometheus k8s \
     — type merge — patch ‘{“spec”:{“enableAdminAPI”:true}}’
``` 
* Verify Admin API is enabled
``` 
    oc describe po prometheus-k8s-1 | grep -i admin
     — web.enable-admin-api
``` 
* Hit TSDB snapshot API to take snapshot
``` 
    curl -X ‘POST’ -ks -H ‘Authorization: Bearer 0za4LjX9xPcqDjhWaufkgcQGo4grqA7ws4zvHrqgfY4’ ‘[https://prometheus-k8s-openshift-monitoring.apps.ocp4.cp4d.com/api/v2/admin/tsdb/snapshot'](https://prometheus-k8s-openshift-monitoring.apps.ocp4.cp4d.com/api/v2/admin/tsdb/snapshot')
     | python -m json.tool
``` 
``` 
    {
     “name”: “20210512T162601Z-33415dbd315ae6af”
    }
``` 
* Find the snapshot and copy it locally

* The default folder is /prometheus/snapshots/ but you can find the data folder by finding the `--storage.tsdb.path` config in your deployment.
``` 
    curl -X ‘POST’ -ks -H ‘Authorization: Bearer 0za4LjX9xPcqDjhWaufkgcQGo4grqA7ws4zvHrqgfY4’ ‘[https://prometheus-k8s-openshift-monitoring.apps.ocp4.cp4d.com/api/v1/admin/tsdb/snapshot'](https://prometheus-k8s-openshift-monitoring.apps.ocp4.cp4d.com/api/v1/admin/tsdb/snapshot') | python -m json.tool
``` 
* List the the snapshot directory
``` 
    oc -n openshift-monitoring exec -it prometheus-k8s-0 -c prometheus — /bin/sh -c “ls /prometheus/snapshots/20210512T162601Z-33415dbd315ae6af”
``` 
* Copy the Snapshot from prometheus container to local machine
``` 
    oc project openshift-monitoring
    oc rsync prometheus-k8s-0:/prometheus/snapshots/ /home/prometheus
``` 

> And this is how to back Prometheus Snapshot to a local machine
Laravel 8 Export to Excel
Tags: webdev, beginners, programming, laravel
Published: 2022-02-15 11:29:26


![Export Laravel Excel](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/whzmfut4kqf1rg88v0e3.png)

## Export Data to Excel Files in Laravel 8

Today I am Going To Explain you about how you can Export Excel  Files in Laravel 8.

I am going to use [Tech-Admin Panel](https://dev.to/shanisingh03/free-laravel-8-admin-starter-kit-1b5i) for this.

For Exporting excel file i am using [Laravel Excel](https://laravel-excel.com/).

You can read about (Laravel Import From CSV/ Excel Files Here!)[https://dev.to/techtoolindia/import-excel-file-into-laravel-8-3kif]

## Step 1 - Installation
To Install the [Laravel Excel](https://laravel-excel.com/) Package via composer run command below.
```php
composer require maatwebsite/excel
```

Next to export config file you need run command below.
```php
php artisan vendor:publish --provider="Maatwebsite\Excel\ExcelServiceProvider" --tag=config
```

## Step 2 - Create an Exports Class inside `app/Exports`

Create Exports Class by using artisan command

```php
php artisan make:export UsersExport --model=User
```

## Step 3 - Handle Export To Excel Function
```php
public function export() 
{
   return Excel::download(new UsersExport, 'users.xlsx');
}
```

You can watch the explanation video for more clarity.

{% youtube _tRwyCCQ9dQ %}

Thank You for Reading

In case of any query related to LARAVEL.

Reach Out To me.
[Twitter](https://twitter.com/techtoolindia)
[Instagram](https://www.instagram.com/techtoolindia/)
[YouTube](https://www.youtube.com/channel/UCOy6o08Yn9DtXMKqxhD9ivA)
Do you really need  Hostinger paid SSL & Cloudflare CDN services? 
Tags: cdnsetup, sslcertificate, freecdn, howtosetupcloudflarecdnforfree
Published: 2022-02-15 11:28:32

The quickest answer is no.....

You don't need to buy the paid CDN and SSL service of [Hostinger](https://www.hostg.xyz/SH9Lx). And the simplest answer is because the money you will pay is not actually for the service. It's just for how to do the service.



![Cloudflare buying offer](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9hii9svla9b7zncayt1n.png)

after buying a shared hosting on [Hostinger ](https://www.hostg.xyz/SH9Lx)for my website I went to see the performance of the website on services like gt-metrix and page speed and things like that and actually I wanted to see how my website is performing on the internet and how fast it is I was shocked that my website is so much slower than the normal and mostly the reason was actually not using a cdn...

![gt-metrix performance](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5k8fto9tn9dlk4s5icjz.png)
 now you might be asking if you are not a developer or a developer who hasn't reached the hosting steps and launch his first website, what is the meaning of a CDN? actually the CDN is a content delivery network. That means to provide fast delivery to the content of your website on the internet.


![cdn meaning](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/revut77yd3tyo4dedonh.png)



 so it means that some servers on the internet around the whole world actually serving your website and making it move fast and delivering the content by actually saving some cash of the images and all the files and scripts that you have. When the user tries to request it by https requests or something like that it actually appears so fast and without the need to download all over again. 

![CDN performance](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qye0i87rps0ir2rfrvhz.png)

By the way to make proof that it was a problem in the server not in the website script I tested the same files on gh-pages which is GitHub pages it's something for developers if you are a developer you already know GitHub pages and if you aren't then just check that on the internet and it will have an easy clarification. I found out that it was very very fast and it's faster than my paid premium plan on [Hostinger](https://www.hostg.xyz/SH9Lx). However, here's the magic happens...


Let me tell you now how to add the services of Cloudflare to your website on any host for free and that you don't need to pay for a CDN services. In this video, I'm going to show you that you can do that and without actually buying this so Please start the video in the 3:30 minute. As this is the start of the following steps from here. 


{% youtube ijvUCfPpUIw %}
How to Export Data To Excel file in Laravel 8
Tags: laravel, php, tutorial, programming
Published: 2022-02-15 11:26:14


![Export Laravel Excel](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/whzmfut4kqf1rg88v0e3.png)

## Export Data to Excel Files in Laravel 8

Today I am Going To Explain you about how you can Export Excel  Files in Laravel 8.

I am going to use [Tech-Admin Panel](https://dev.to/shanisingh03/free-laravel-8-admin-starter-kit-1b5i) for this.

For Exporting excel file i am using [Laravel Excel](https://laravel-excel.com/).

You can read about [Laravel Import From CSV/ Excel Files Here!](https://dev.to/shanisingh03/how-to-import-excel-csv-file-into-laravel-4he3)

## Step 1 - Installation
To Install the [Laravel Excel](https://laravel-excel.com/) Package via composer run command below.
```php
composer require maatwebsite/excel
```

Next to export config file you need run command below.
```php
php artisan vendor:publish --provider="Maatwebsite\Excel\ExcelServiceProvider" --tag=config
```

## Step 2 - Create an Exports Class inside `app/Exports`

Create Exports Class by using artisan command

```php
php artisan make:export UsersExport --model=User
```

## Step 3 - Handle Export To Excel Function
```php
public function export() 
{
   return Excel::download(new UsersExport, 'users.xlsx');
}
```

You can watch the explanation video for more clarity.

{% youtube _tRwyCCQ9dQ %}

Thank You for Reading

In case of any query related to LARAVEL.
Reach Out To me.
[Twitter](https://twitter.com/shanisingh03)
[Instagram](https://www.instagram.com/shanisingh03/)
Coding Interviews are not broken!
Tags: interview, technicalinterview
Published: 2022-02-15 11:24:32

Coding interviews are broken. They judge your memory rather than skills. I am a fresher and I don't think I am going to use these algorithms and data structures anywhere. After all being the most junior developer in the team I will be mentored by the senior developers. It's my employer's responsibility to train and groom me into better developer. I have graduated from a well reputed university with higher grades. Isn't it enough to prove my worth?

Sounds familiar? Don't be surprised, these were common even back in early 2000's. Computer Science graduates after completing 40 courses of 320 credit hours scoring higher GPAs filled with confidence applying for the jobs and get punched in the face when interviewed for algorithms and data structures. Graduates performing well in these interviews doesn't necessarily belong to elite universities but they all have one thing in common and that is problem solving skills. A skill to analyze the problem and develop the logical steps to solve that problem using algorithms and data structures which they have been taught throughout their bachelors degree program.

Why the companies test for algorithms and data structures? It is difficult to understand when you are starting your professional career and this is the case with me also. But after few years when I got promoted and started taking technical interviews I have observed that developers who score better in algorithms and data structures proved better programmers and quick learners. You can shift them easily to any technology and they quickly grasp it and start producing results. This is because they have developed a logical way of thinking which every programming languages demands.

So next time preparing algorithms and data structures try to learn how everything works, it will not only help you to score better but also make you better developer no matter which programming language you work in.
What is GitHub License And How To Add Them?
Tags: opensource, github, productivity, beginners
Published: 2022-02-15 11:03:47

Many individuals find it inspiring to know that they can develop software with people from around the world who are passionate about it. Sadly, they repeatedly make the same mistakes. The mistake is not licensing their code, and then they expect others to contribute. This post explains how and why software should be licensed. Now let's get started.

## What is licensing a repository?

In order to allow others to modify or distribute open-source software, the repository where the software resides should contain the license file (which provides rights to modify or distribute). 

Thus, others (who forked the repository) can edit, distribute the software contained in the repository. By using open-source software, we avoid reinventing the wheel

## Why You Should Add a License to Your Repository

Each source code repository must include a license. It should be protected since it is your creation. Despite being protected by copyright, the original creations must be used according to their license. 

In the future, you may need to include some special terms in your software. A software license describes how to use, modify, and distribute the software.

## What if I do not include a license in my repository?

There will be legal uncertainty if a license is not added to your repository. Potential customers may not understand if they have permission to use your software, resulting in them refusing to purchase it. Additionally, some users may be under the impression that you do not have a legal agreement for the product, so they can do whatever they want with it.

It is unclear if "All Rights Reserved" will have any legal effect in any jurisdiction if you do not add a license to your new project on GitHub. To avoid future issues, pick a license that meets your needs and add it to your repository.

## How to Add A License for Your Open Source Projects

It's easy to license your projects. In the root directory of your repository, you must place a `LICENSE`, `LICENSE.txt`, or `LICENSE.md` file.

To make it easier, GitHub offers these features:

- Open the GitHub repository in a browser.

- Click on the `Create new file` in the root directory.

- Type "LICENSE" as the filename.

- Press the `Choose a license template` button.

- Choose an appropriate license 

- After selecting a license, click `Review and Submit`

- Click `Commit`

I recommend you take a look at this [website](https://choosealicense.com/) if you have any doubts regarding which license is best for your project. 

Hopefully, you now know how to license your repository. Do comment your favorite open source license in the comments below

> You can now extend your support by buying me a Coffee.😊👇

<a href="https://www.buymeacoffee.com/muthuannamalai" target="_blank"><img src="https://cdn.buymeacoffee.com/buttons/v2/default-yellow.png" alt="Buy Me A Coffee" style="height: 60px !important;width: 217px !important;" ></a>

Thanks for Reading 😊