teleren/devto huggingface dataset:
The breadcrumbs left on the yellow brick road
Tags: devjournal, beginners
Published: 2022-08-04 16:09:06

This week I was working on a project, like any other day, and went to watch a video on YT regarding some topics I had to get some info on. And on a video made by [Fireship](https://www.youtube.com/c/Fireship) <-(_I **HIGHLY **recommend his channel_), I stumbled upon a little tiny word that I had NEVER heard or seen before. - I won't tell you because it's embarrassing. - JK, it's _MODULO_.
I won't go into why I don't know it, or what it is, but the thing is, we WILL leave behind information that we will need and have to study at some point. This means it's OKAY to not know everything at everytime. Keep it simple, don't overheat. trust the process.
Which TDD school is better? 🤔
Tags: tdd, programming, discuss, testing
Published: 2022-08-04 16:07:16

There're at least two major schools of TDD: 🇬🇧London(outside-in) and Chicago 🇺🇸 (inside-out) and several other schools which considered less influential. Which one is better?

I believe it's none. Let me explain!


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/h041u25ya33z2ropu4i5.jpg)


London School of TDD suggests you start with an Acceptance-level test and then go to a lower level testing/implementation. Since inevitably you would be writing code which calls non-existing code you will rely more on mocking and you will need some kind of rough overall general design of a code you're going to write.


Chicago School in contrast suggests starting with the smallest possible requirement and then gradually and incrementally increasing the scope.


Other schools (like twitter-style TDD) could suggest ignoring smaller ("unit") tests entirely.


So which one is better? In fact, it is the wrong way to frame question. The better way would be to ask: Which would make sense to use now?


You see, different schools of TDD has something different to offer in every other case!


Want to know more? Feel free to follow me here and on my YouTube channel: https://www.youtube.com/channel/UCkJRvCK2-l2gCuPT9-HUG7A
How to make a morse encoder
Tags: opensource, microservices, embedded, luos
Published: 2022-08-04 16:03:40

In this tutorial, we will explain the Morse encoder algorithm and its encapsulation in a Luos service.
⏩ https://www.luos.io/tutorials/morse

We will see with examples, how we can exploit the output of the encoding algorithm, and how we can generate and share an input to be encoded by the application.
242. Valid Anagram - Leetcode Easy
Tags: programming, tutorial, python, career
Published: 2022-08-04 16:02:00

## Problem statement
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 1:

Input: s = "anagram", t = "nagaram"
Output: true
```
```
Example 2:

Input: s = "rat", t = "car"
Output: false
```

## Approach 1
Since, the letters and their frequency will be same in both strings, we check if they are identical in sorted order. We can return true if they are identical in sorted order.

```python
class Solution:
    def isAnagram(self, s: str, t: str) -> bool:
        return sorted(s) == sorted(t)
```
**Time complexity** - `O(s log s) or O(t log t)` - due to sorting
**Space complexity** - `O(1)` - if not accounted for the space used for sorting.

## Approach 2
We first need to check if their lengths are equal. If not, we can immediately return false as anagrams should be of equal length. Next, we need to count the frequency/occurances of each letter in both strings. We can do that using a hashmap for each string. We can return true if both hashmaps are identical.
```python
class Solution:
    def isAnagram(self, s: str, t: str) -> bool:
        if len(s) != len(t):
            return False
        sMap = {}
        tMap = {}
        
        for i in range(len(s)):
            sMap[s[i]] = sMap.get(s[i], 0) + 1 #get function on hashMap return it's value 
            tMap[t[i]] = tMap.get(t[i], 0) + 1 #or default value we specified which is 0 in this case
            
        if len(sMap) != len(tMap): # If lengths of hashMaps are not equal,
            return False  #it means that there is a mismatch
      
        for c in (sMap):
            if(sMap[c] != tMap.get(c, 0)): # In case of t not having a letter present in s,
                return False # tMap needs to give 0 there, that's why using get function there.
            
        return True
```
**Time complexity** - `O(s)` - only single loop.
**Space complexity** - `O(s + t)` - for hashMaps.

## Conclusion
Do let me know if I missed any other approach.

Do follow me for more such explanations.
Let's connect on: [Twitter](https://twitter.com/VChiranjeeviAK) [LinkedIn](https://www.linkedin.com/in/chiranjeevi-tirunagari/) [Showwcase](https://www.showwcase.com/vchiranjeeviak)
Custom tab in WooCommerce
Tags: wordpress, woocommerce, webdev
Published: 2022-08-04 15:57:57

Hello WordPress guys and gals! Sometimes when we work with WooCommerce we need to add some special tab. Recently I had to do it when I was creating a e-commerce shop for one of my client. It was a shop with clothes and every item in the shop had a size (L, M, XL etc.). So I decided to create a custom tab with "Size charts" name. In this tab I put the table with sizes.

Here you can see example but it's not from the shop I talked about above:

![WooCommerce - Custom tab](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gh6thyv8w53frc3xsr7v.png)

## So how to create a custom tab in WooCommerce?

Just open `functions.php` file of your theme and paste these lines of code:

{% gist https://gist.github.com/texe/8a4e144c3f74dd10b514f465e5f4f7de %}

------

*It would be great if you will comment or follow me on social media*:

[![Chris Texe Twitter](https://madlon.eu/wp-content/uploads/sites/21/TwitterTexeButton.webp)](https://twitter.com/TexeChris)

[![Chris Texe LinkedIn](https://madlon.eu/wp-content/uploads/sites/21/LinkedInTexeButton.webp)](https://www.linkedin.com/in/texe/)

Also you can visit my websites:

- [Linux blog](https://varlock.net)
- [Web Agency website](https://madlon.eu)
Viewing HTML Source Code On iPhone and iPad
Published: 2022-08-04 15:55:00

As a new software engineering student I noticed a limitation when trying to test out my webpages on either my iPhone or iPad, there is no built in functionality to "view source page source".  Sure, there are third party apps that do this plus much more but I just wanted a built in option right in my Safari mobile browser.

With a little googling I found there is a way and it starts with an app that every Apple device has called Shortcuts.  You can use this app to build custom shortcuts that can be added to your browser actions. You can do a lot more with the Shortcuts app. (The gifs in this post were created using a shortcut!)

![Apple Shortcuts App](https://setlock10.github.io/setlock-website/apple-shortcuts.jpg)

Once there hit the + in the top right corner to add a new shortcut. You can set the name, icon and icon color.

![Naming App Gif](https://setlock10.github.io/setlock-website/Apple-Shortcuts-1.gif)

Then it is time to "Add Action" and search for and choose "Make HTML from Rich Text".  Click the settings icon in the upper right and turn on "Show in Share Sheet". Add another action, search and choose "Quick Look".

![Customizing the Shortcut](https://setlock10.github.io/setlock-website/Apple-Shortcuts-2.gif)

All that is left to do now is test it out.  Go to any webpage in Safari and hit the action button, then choose "View Source" and Voilà, source code!

![Using the Shortcut](https://setlock10.github.io/setlock-website/Apple-Shortcuts-3.gif)
Laravel tap helper function
Tags: laravel, laravelhelpers, functions
Published: 2022-08-04 15:49:00

Laravel's **_tap()_** is one of the simplest methods in the framework. pass in a value and a a closure , and you'll get back the modified original value. Cleans up code by eliminating temporary variables!

## Here are some usage code snippets

- 
```
$user = tap(User::create(['id' => 1, 'name'=> 'raj'])
->sendWelcomeNotification();

//The nice thing about above code is it create the user and sends notification and returns the result of first argument.
```

- 
```
$user = User::find(1);

$user->update(['name' => 'benitto']);

return $user;

// we can do this in one line

return tap($user)->update(['name'=> 'benitto']);
```

- 
if we pass closure as second arguement the result of first arguement is passed to clousure

```
$user = tap($user,function($user) {
       $user->sendWelcomeNotification();
       $user->onBoardSetup();
  });
```


**_Keep Learning!!_**
217. Contains Duplicate - Leetcode Easy
Tags: programming, tutorial, python, career
Published: 2022-08-04 15:35:00

## Problem statement
Given an integer array nums, return true if any value appears at least twice in the array, and return false if every element is distinct.

```
Example 1:

Input: nums = [1,2,3,1]
Output: true
```
```
Example 2:

Input: nums = [1,2,3,4]
Output: false
```

## Approach 1 (Brute force)
Let's select an item in the array every time. Now, let's look at the remaining array to see if any other item with same value exists or not. If it exists, we return true. Else, false.

```python
class Solution:
    def containsDuplicate(self, nums: List[int]) -> bool:
        for i in range(len(nums)-1):
            for j in range(i+1, len(nums)):
                if nums[i] == nums[j]:
                    return True
        return False
```
**Time complexity**: `O(n^2)` -  due to nested for loops.
**Space complexity**: `O(1)`

## Approach 2
If we sort the input array, all the duplicate elements are rearranged side by side. We can traverse through the array and keep checking the adjacent elements if they are same or not. If we find one such pair, we can return true.

```python
class Solution:
    def containsDuplicate(self, nums: List[int]) -> bool:
        nums.sort()
        for i in range(len(nums)-1):
            if nums[i] == nums[i+1]:
                return True
            
        return False
```
**Time complexity**: `O(n log n)` - due to sorting.
**Space complexity**: `O(1)`

## Approach 3
Let's iterate through the array and keep adding each item into a hashset. And before adding, check if that item is already present in that hashset. This checking operation takes O(1) time because it is a hashset. If we find one such element, we can return true.
```python
class Solution:
    def containsDuplicate(self, nums: List[int]) -> bool:
        hashSet = set()
        for n in nums:
            if n in hashSet:
                return True
            else:
                hashSet.add(n)
        
        return False
```
**Time complexity**: `O(n)` - only one for loop.
**Space complexity**: `O(n)` - for extra hashset.

## Conclusion
Do let me know if I missed any other approach.

Do follow me for more such explanations.
Let's connect on: [Twitter](https://twitter.com/VChiranjeeviAK) [LinkedIn](https://www.linkedin.com/in/chiranjeevi-tirunagari/) [Showwcase](https://www.showwcase.com/vchiranjeeviak)
Elegant VS Code Extensions [part 2]
Tags: vscode, javascript, webdev, productivity
Published: 2022-08-04 15:24:14

It's been over a year since I published [Elegant VS Code Extensions](https://dev.to/ayoub3bidi/elegant-vs-code-extensions-2fo6) article.
So I decided to make a second part.
Without further ado, let's jump into our new list.
###Auto Rename Tag
Instead of changing open and close tags by yourself, you can use Auto-Rename Tag and do this simultaneously. Start changing an open tag and its close tag will change automatically. This is very useful, especially when you have a lot of nested code.
###Better Comments
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/a753yiyz7mmg5scrnm2d.png) 
What this extension do is spice up your code commenting game by allowing different colored comments which would make them stand out rather than the boring grey default.
###Code Snap 
So far, the CodeSnap extension is my favorite tool to create a screenshot with its simplicity. After installation, you can just drag to select your code where you want a screenshot, right-click to open the CodeSnap menu, and click a button to generate a screenshot and save it as PNG locally.
###Git History
Git History gives us a wide range of features, Using Git History we can access the git log with the graph and details, As the name also suggests we can view and search the history and we can also compare branches, commits, and files across commits along with many miscellaneous features. With the new update of VS Code, you will see many miscellaneous features of Git History already available on the Source control section on VS Code.
###Live Server
This extension launch a local development server with live reload feature for static & dynamic pages. It will help you while developing a basic project without any framework but with feature of real-time reload that exist in every framework.
###Vim
{% youtube -txKSRn0qeA %}
In case you don't know what vim is, it's a free and open-source, screen-based text editor program. it was know for it's capability to make you productive while coding But we all are using vs code now. This is when vim extension comes and give you the best of both worlds.
##Conclusion
This was it. I'm hoping these extensions help you become more productive!
Cybersecurity Programming: SQL Injection Scanner with Python
Tags: cybersecurity, sql, security, python
Published: 2022-08-04 15:20:47

Hey 👋 !
Whether you're running on Windows, Kali Linux [ or any other Debian based Linux distro ] or even a Mac user, this short script [ under 80 lines of Python code ]  will work just fine.
Now, SQL injection is a real world threat especially for big companies, getting access to your database and gaining full control is horrible and especially if you have your own business - No surprise here that it ranks amongst the top 10 cybersecurity threats in the world.
Let us build a simple yet powerful scanner for any SQL injection attacks, and see how it works.
{%youtube HJBxn8KZRuM%}
URL: https://bekbrace.netlify.app 
GitHub : https://github.com/BekBrace/sqli-scanner
Facebook / Twitter : @bekbrace
Instagram : @bek_brace
Dev.to: @bekbrace
Some deep diving in JS concepts
Tags: javascript, webdev, programming, discuss
Published: 2022-08-04 15:17:41

There is no need to tell you that JavaScript has some unexpected behaviors sometimes and it's so frustrating when we don't understand them and get what's going.In this post we will explore one of them and hopefully fully understand it ! 

`for (var val = 0; val < 10; val++) {
    console.log(val);
    setTimeout(function() {
        console.log(`The number is ${val}`);
    }, 1000);
}`
this above for loop will print 

> 0
> 1
> 2
> 3
> 4
> 5
> 6
> 7
> 8
> 9
> "The number is 10"
> "The number is 10"
> "The number is 10"
> "The number is 10"
> "The number is 10"
> "The number is 10"
> "The number is 10"
> "The number is 10"
> "The number is 10"
> "The number is 10"

and the same for loop but with let instead of var will print

> 0
> 1
> 2
> 3
> 4
> 5
> 6
> 7
> 8
> 9
> "The number is 0"
> "The number is 1"
> "The number is 2"
> "The number is 3"
> "The number is 4"
> "The number is 5"
> "The number is 6"
> "The number is 7"
> "The number is 8"
> "The number is 9"

The question is : **why there are different behaviors ?**

First thing to know :

**important**:The setTimeout API will only start executing the callback function once all the global synchronous code has executed,so setTimeout API will register the function as callback 10 times.

Second thing:
Declaring a variable with var (outside of a block) will define it in the global scope and declaring it with let will declare it into the local scope 

You started to get it right ?(if you still didn't,don't worry i'll break it to you)

In the loop with var declaration,the callback function of setTimeout will have to wait for the global scope operations to finish (i value changing and the console.log(i)) before being able to execute.

And in the let declaration version , "i" variable is locally declared (local scope) so it's changes won't block the setTimeout callbacks execution.

That's it hope you enjoyed reading this post,Happy coding.

SOURCE:https://discuss.codecademy.com/t/var-and-let-in-a-loop-working-differently/550468/8
A Roadmap for Data Center Migration
Tags: data, datascience
Published: 2022-08-04 15:14:00


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/62es22v8puk7aawxry7a.png)
Data center migration is the process of relocating an organization’s current data center to another operating environment. The first and most important task when preparing for migration is to avoid (or at least minimize) data loss. Data center migration isn’t about relocating physical equipment but rather about moving the data from one data center to another. This process doesn’t involve moving hardware from the old site to the new site.



According to Wikipedia, Data migration is the process of selecting, preparing, extracting, and transforming data and permanently transferring it from one computer storage system to another. Additionally, the validation of migrated data for completeness and the decommissioning of legacy data storage are considered part of the entire data migration process. Data migration is a key consideration for any system implementation, upgrade, or consolidation, and it is typically performed in such a way as to be as automated as possible, freeing up human resources from tedious tasks. Data migration occurs for a variety of reasons, including server or storage equipment replacements, maintenance or upgrades, application migration, website consolidation, disaster recovery, and data center relocation.


**Data Center Migration Best Practices**

Whether you are planning a data center migration to cloud or physical locations, following certain recommendations can help you organize and perform your migration more efficiently. The following practices are the basic elements of a migration methodology and can be used to increase the chances of successfully completing any migration project.



Data center migration is moving data and workloads to a different location. To complete the project successfully and avoid budget overlaps, IT infrastructure downtime, and data loss, you need to create a data center migration strategy. 



Source: [https://www.dataversity.net/a-roadmap-for-data-center-migration-challenges-and-solutions-part-1/](https://www.dataversity.net/a-roadmap-for-data-center-migration-challenges-and-solutions-part-1/)
Hide Posts From Particular Categories From WordPress Homepage Without Using a Plugin
Published: 2022-08-04 15:12:00

By default, the homepage of your WordPress site shows posts from all the categories.

However, it is possible to exclude certain categories from being displayed on your homepage, but there's no option to do that in WordPress out of the box.

I wanted to hide posts from the [deals category](https://www.digitalkube.com/category/deals/) on my site because a lot of affiliate programs misunderstand internet marketing blogs that post coupons as **"deals sites"**, which they do not allow.

To avoid confusion, I decided to hide all the posts from the deals category from my site's home.

In this tutorial, I will show you how to create a category filter without using a plugin.

You need to edit your site's **functions.php** file and add the following code:

```
function hide_category_home( $query ) {
if ( $query->is_home ) {
    $query->set( 'cat', '-9' );
}
    return $query;
}
add_filter( 'pre_get_posts', 'hide_category_home' );
```

Replace **9** with your category's ID. Don't remove '-'

Use the below code to hide posts from multiple categories:

```
function hide_category_home( $query ) {
if ( $query->is_home ) {
    $query->set( 'cat', '-9, -69, -23' );
}
    return $query;
}
add_filter( 'pre_get_posts', 'hide_category_home' );
```

Click save and you're done!
Como desabilitar o Receptor de AirPlay e disponibilizar a porta 5000 no macOS Monterey
Tags: setup, macos
Published: 2022-08-04 15:07:00

O macOS Monterey por padrão utiliza a porta 5000 para o Receptor de AirPlay; _recurso que possibilita receber conteúdo de vídeo e áudio de qualquer outro Mac_, como eu não utilizo optei por desabilitar e liberar a porta.

Para desabilitar é necessário acessar o recurso em "Preferências do Sistema" > "Compartilhamento" e desabilitar.


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

Uma tentativa que fiz antes de descobrir esse detalhe do receptor, foi tentar liberar a porta, mas curiosamente o mac a preenche imediatamente.

```
#Como descobrir o processo que está utilizando a porta 5000
lsof -i :5000

#Exemplo do retorno
COMMAND   PID          
com.docke 881

#Para liberar a porta 5000 basta passar o valor de PID
kill -9 {PID}
```
Thoughts on the software supply chain (GitLab)
Tags: software, development, javascript, gitlab
Published: 2022-08-04 14:42:11

---
title: Thoughts on the software supply chain (GitLab)
published: true
description: a few thoughts on what is going wrong here
tags: software,development,javascript,gitlab
cover_image: https://dev-to-uploads.s3.amazonaws.com/uploads/articles/x3185l3z3yodpzlom0yr.png
# Use a ratio of 100:42 for best results.
---

I know this is a dry subject, but we have to get through it now.

## The Register reported

As The Register reported, GitLab wants to delete repos. 

When I read that, I thought to myself:

> At first, that doesn't sound so tragic. 
> It should only hit repos that are no longer maintained.
> And so many projects don't use GitLab.com yet.

But if you have software that relies on that code, you won't be able to build your product. And what if Microsoft (Github) does the same?

And of course, GitLab has the right to do this to reduce costs. But it is still hard.

**But what does it mean for your software.**

The software supply chain includes everything we use in the development of software. Be it images for icons or the library for calculating statistics.

Many ecosystems use repositories to distribute and manage code. 

Node has npm or yarn, php has composer and go can load software directly or via Google.

For example, many node projects only store the package.json and not the actual packages. 

Software components often depend on platforms and systems that we cannot control. 

Yes, there are some mirrors, but the resilience is not very high.

When using `npm install` or `go get` we should consider what happens when this code is no longer available.

Let's see if GitLab follows through or backs out.

In our company, we have all external software available in source code.

Are you taking care of the software supply chain? What measures are you taking.


## References

* [www.theregister.com/2022/08/04/gitlab_data_retention_policy/](https://www.theregister.com/2022/08/04/gitlab_data_retention_policy/
)
* [www.gao.gov/blog/solarwinds-cyberattack-demands-significant-federal-and-private-sector-response-infographic](https://www.gao.gov/blog/solarwinds-cyberattack-demands-significant-federal-and-private-sector-response-infographic)
* [dev.to/katepapineni/how-to-check-for-missing-unused-or-out-of-date-javascript-dependencies-34i5](https://dev.to/katepapineni/how-to-check-for-missing-unused-or-out-of-date-javascript-dependencies-34i5)