teleren/devto huggingface dataset:
Scrape all images from websites
Tags: php, webdev, javascript, beginners
Published: 2022-06-06 16:52:02

First of all you need to download html dom parser file from sourceforge. Then this code will work for you best.
Here is the code you can find all images the [Spotiflyer](https://spotiflyer.online).

PHP Code
`<?php
 
// Initialize curl
$ch = curl_init();
 
// URL for Scraping
curl_setopt($ch, CURLOPT_URL,
    'https://spotiflyer.online/matlab-data-types/');
 
// Return Transfer True
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
 
$output = curl_exec($ch);
 
// Closing cURL
curl_close($ch);
 
// For web page display
echo '<head>';
echo '<meta http-equiv="content-type"
    content="text/html; charset=utf-8" />';
echo '</head>';
echo '<body>';
 
echo '<h1>Web Scraping using cURL</h1>';
 
// Checking for images
preg_match_all(
'!https://spotiflyer.online/wp-content/uploads/(.*)/(.*).png!',
    $output, $data
);
 
foreach ($data[0] as $list) {
    echo "<img src='$list'/>";
}
 
echo '</body>';
 
?>`
Javascript Objects
Tags: javascript, beginners, webdev, node
Published: 2022-06-06 16:43:51

## Object
- Non-primitive data type.
- Stores multiple collections of data.
- Simply, js Object is a collection of key-value pairs.

```
key: value
```


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


## Syntax

```
const object_name = { 
    key_1: value_1,
    key_2: value_2,
    key_n: value_n
}
```

## Object Creation

```
const person = {
  firstName: 'Manikandan',
  lastName: 'MK',
  age: 24,
};

console.log(typeof person); // object
console.log(person); // { firstName: 'Manikandan', lastName: 'MK', age: 24 }
```
Explanation:
  An object is a collection of key-value pairs.
   
       person                    - object name,
       firstName, lastName, age  - key/name. (left side)
       Manikandan, mk, 24        - value. (right side)

  Key-value pairs are called properties.
   

**ACCESSING OBJECT**

**1. Dot Notation**

Syntax: 
    
```
Object_name.key
```
    
Example: 

```
const person = {
  firstName: 'Manikandan',
  lastName: 'MK',
  age: 24,
}; 

console.log(person.firstName); // Manikandan
```

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


**2. Bracket Notation**

Syntax: 
  
```
  ObjectName["propertyName"]  (property name is nothing key name)
```
    
```
Example: 
const person = {
    firstName: 'Manikandan',
    lastName: 'MK',
    age: 24
    }

    console.log(person['firstName']);   // Manikandan
```

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


##  Nested Object 
A nested Object is nothing but an Object containing another object.

```
Example:
    
const person = {
  firstName: 'Manikandan',
  lastName: 'MK',
  age: 24,
  physicalDetails: {
    height: 170,
    weight: 70,
  },
};

console.log(person.physicalDetails); // { height: 170, weight: 70 }
console.log(person.physicalDetails.height); // 170
```
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tivhriapiqx9m9dhvjck.png)


**Add Property from an Object**
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qlipj7smfi2qc320fxo6.png)

**Remove Property from an Object**

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/duzu81bp245klyyrrbw6.png)
Find the factorial of given number in Python
Tags: python, beginners, interview, tutorial
Published: 2022-06-06 16:43:17

Method 1: Finding the factorial of a given number using for loop

```
def factorial(number):
    output = 1
    if number < 2:
        return output
    else:
        for i in range(2, number+1):
            output *= i
    return output

print(factorial(5))

# output: 120

``` 
Method 2: Finding the factorial of a given number using recursion 


```
def factorial_recursion(number):
    if number < 2:
        return 1
    return number * factorial_recursion(number -1)def factorial_recursion(number):
    if number < 2:
        return 1
    return number * factorial_recursion(number -1)

print(factorial_recursion(5))

# output: 120
``` 

Method 3: Finding the factorial of a given number using the lambda function 


```
factorial_lambda = lambda number: 1 if number  < 2 else  number * factorial_lambda(number -1)

print(factorial_recursion(5))

# output: 120
``` 

Thanks for reading this post. Let me know which one is your favorite method.
3Sum
Tags: leetcode, dsa, theabbie
Published: 2022-06-06 16:30:42

Given an integer array nums, return all the triplets `[nums[i], nums[j], nums[k]]` such that `i != j`, `i != k`, and `j != k`, and `nums[i] + nums[j] + nums[k] == 0`.

Notice that the solution set must not contain duplicate triplets.

**Example 1:**

**Input:** nums = \[-1,0,1,2,-1,-4\]
**Output:** \[\[-1,-1,2\],\[-1,0,1\]\]

**Example 2:**

**Input:** nums = \[\]
**Output:** \[\]

**Example 3:**

**Input:** nums = \[0\]
**Output:** \[\]

**Constraints:**

*   `0 <= nums.length <= 3000`
*   `-105 <= nums[i] <= 105`

**SOLUTION:**

    class Solution:
        def threeSum(self, nums: List[int]) -> List[List[int]]:
            n = len(nums)
            if n < 3:
                return []
            triplets = set()
            nums.sort()
            for i in range(n - 2):
                a = nums[i]
                start = i + 1
                end = n - 1
                while start < end:
                    b = nums[start]
                    c = nums[end]
                    total = a + b + c
                    if total == 0:
                        triplets.add(tuple(sorted([a, b, c])))
                        start += 1
                        end -= 1
                    elif total > 0:
                        end -= 1
                    else:
                        start += 1
            return [list(triplet) for triplet in triplets]
Fullscreen API
Tags: fullscreen, webapi, javascript
Published: 2022-06-06 16:25:23

---
title: Fullscreen API
published: true
description: Usage of Fullscreen API
tags: fullscreen,WebAPI,javascript
cover_image: https://programacion.net/files/article/article_02177_.jpg
# Use a ratio of 100:42 for best results.
---

Using Fullscreen API is really easy, but sometimes things do not work as you need, maybe you discover not work the same in all browsers. Keep reading to learn how to use it in different scenarios:

> I exclude IE because nobody should use it in 2022

**I only provide example code compatible with Chromium-based, Firefox, and Safari**

## Request fullscreen

```js
document.documentElement.requestFullscreen();
```

> The above function is async!

## Exit fullscreen

```js
document.exitFullscreen();
```

Ok! Nice works perfect, but this is the beginning! Fullscreen API it's not standardized in all browsers so you will need to use a prefix to maximize compatibility.

____

## Compatibility

Today the majority of modern updated browsers can handle Fullscreen API without a prefix but let's do 100% compatible code.

```js
const context = document.documentElement;
const requestFullscreen = context.requestFullscreen || context.webkitRequestFullscreen || context.mozRequestFullScreen;
const exitFullscreen = document.exitFullscreen || document.webkitExitFullscreen || document.mozCancelFullScreen;
```

**(Change `context` value to `this` in case you work with a web component)**

Great! Now I only need to execute `requestFullscreen` and `exitFullscreen` to toggle!

Nope! You will get the following error:

```js
TypeError: Failed to execute 'requestFullscreen' on 'Element': Illegal invocation

TypeError: Failed to execute 'exitFullscreen' on 'Element': Illegal invocation
```

This is because the reference of context (DOM element) will not works, so we will need to bind the context:

```js
requestFullscreen.bind(document.documentElement)();
exitFullscreen.bind(document)();
```

In case you want to use it inside of web component:

```js
requestFullscreen.bind(this)();
exitFullscreen.bind(document)();
```

____

## Full working toggle Fullscreen

```js
function toggleFullscreen() {
    const requestFullScreen = this.requestFullscreen || this.webkitRequestFullscreen || this.mozRequestFullScreen;
    const exitFullscreen = document.exitFullscreen || document.webkitExitFullscreen || document.mozCancelFullScreen;
    const isFullscreen = document.fullscreenElement || document.webkitFullscreenElement || document.mozFullScreenElement;
    if (isFullscreen) return exitFullscreen.bind(document)();
    else if (!isFullscreen) return requestFullScreen.bind(this)();
}
toggleFullscreen.bind(document.documentElement)(); // Typical way
toggleFullscreen.bind(this)(); // Inside web component
```
Random Flip Matrix
Tags: leetcode, dsa, theabbie
Published: 2022-06-06 16:00:48

There is an `m x n` binary grid `matrix` with all the values set `0` initially. Design an algorithm to randomly pick an index `(i, j)` where `matrix[i][j] == 0` and flips it to `1`. All the indices `(i, j)` where `matrix[i][j] == 0` should be equally likely to be returned.

Optimize your algorithm to minimize the number of calls made to the **built-in** random function of your language and optimize the time and space complexity.

Implement the `Solution` class:

*   `Solution(int m, int n)` Initializes the object with the size of the binary matrix `m` and `n`.
*   `int[] flip()` Returns a random index `[i, j]` of the matrix where `matrix[i][j] == 0` and flips it to `1`.
*   `void reset()` Resets all the values of the matrix to be `0`.

**Example 1:**

**Input**
\["Solution", "flip", "flip", "flip", "reset", "flip"\]
\[\[3, 1\], \[\], \[\], \[\], \[\], \[\]\]
**Output**
\[null, \[1, 0\], \[2, 0\], \[0, 0\], null, \[2, 0\]\]

**Explanation**
Solution solution = new Solution(3, 1);
solution.flip();  // return \[1, 0\], \[0,0\], \[1,0\], and \[2,0\] should be equally likely to be returned.
solution.flip();  // return \[2, 0\], Since \[1,0\] was returned, \[2,0\] and \[0,0\]
solution.flip();  // return \[0, 0\], Based on the previously returned indices, only \[0,0\] can be returned.
solution.reset(); // All the values are reset to 0 and can be returned.
solution.flip();  // return \[2, 0\], \[0,0\], \[1,0\], and \[2,0\] should be equally likely to be returned.

**Constraints:**

*   `1 <= m, n <= 104`
*   There will be at least one free cell for each call to `flip`.
*   At most `1000` calls will be made to `flip` and `reset`.

**SOLUTION:**

    from random import randint
    
    class Solution:
    
        def __init__(self, m: int, n: int):
            self.m = m
            self.n = n
            self.ones = set()
    
        def flip(self) -> List[int]:
            i, j = randint(0, self.m - 1), randint(0, self.n - 1)
            while (i, j) in self.ones:
                i, j = randint(0, self.m - 1), randint(0, self.n - 1)
            self.ones.add((i, j))
            return [i, j]
    
        def reset(self) -> None:
            self.ones.clear()
    
    # Your Solution object will be instantiated and called as such:
    # obj = Solution(m, n)
    # param_1 = obj.flip()
    # obj.reset()
How to avoid problems on your javaScript code.
Tags: javascript, beginners, programming, tutorial
Published: 2022-06-06 16:14:29

Avoid problems

Why did we go over these examples? Should we remember these peculiarities all the time? Well, not really. Actually, these tricky things will gradually become familiar over time, but there’s a solid way to avoid problems with them:

Treat any comparison with undefined/null except the strict equality
```
===
```
with exceptional care.
Don’t use comparisons 

```
>= > < <=
```
 with a variable which may be null/undefined, unless you’re really sure of what you’re doing. If a variable can have these values, check for them separately.
Luos are waiting for you 🙂
Tags: microservices, opensource, discuss, luos
Published: 2022-06-06 16:05:39

Luos are waiting for you 🙂  We want to make an inventory of projects. These may be completed or in progress.

Luos may be involved in the whole project or only in a small part.

We will reward the owners of the best use cases with a $250 Amazon voucher and three months of dedicated support by Luos engineers 🙂
It's fast (< 2 min) and easy to participate: https://luos.typeform.com/usecases

Several projects will be selected ⭐

![Luos are waiting for you](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pyceqgkk6tuo73mq95qb.png)
Data Types in Javascript
Tags: javascript, beginners, webdev, programming
Published: 2022-06-06 16:01:53

## DATA TYPE
Data type is, in a programming language, a classification that specifies what type of value, that variables hold/store.

In js have seven primitive data types and one non-primitive data type.

## Primitive type
  In js primitive type represents data that is not an Object and that has no methods or properties.

String :
    In JavaScript String is used to store text.  String wrap by quotes.

    Example: 
    const name1 = 'Manikandan";
    const name2 = "Manikandan";
    const name3 = `Manikandan`;

Number :
    Number represents integer and floating-point numbers(decimal numbers).

    Example: 
    const number = 10;
    const number = 20.25;

Boolean :
    Boolean represents logical entities that true and false.

    Example:
    const isFetch = true;
    const isChecked = false;

Undefined : 
    The Undefined data type represents, the variable is declared. But value is not initialized.

    Example: 
    let a;
    console.log(a);  // Undefined

Null :
    The null data type represents an empty or unknown value.

    Example:
    const number = null;

symbol : 
    Data type whose instances are unique and immutable.

BigInt : 
    Its represents integer with arbitrary precision.  

    Example: 
    900719925124740999n

Object :
    An object is a non-primitive data type in JavaScript.
    In js Object is used to store the collection of Data.

    Example:
    const person = {
        firstName: 'Manikandan';
        lastName: 'MK';
        age: 24;
        isEmployee: true;
    }

JavaScript typeof : 
    To find the type of variable, we can use typeof operator.

    Example:
    const name = 'Manikandan'
    console.log(typeof(name));  // return string;

    const id = 1010;
    console.log(typeof(id));  // return number;

    const isChecked = true;
    console.log(typeof(isChecked));  // return boolean;
Removing Git Branch Bloat
Tags: git, productivity, beginners, programming
Published: 2022-06-06 16:01:14


> If you have too many Git branches, bookmark and like this page.

> Note: You'll see `"(^*|master|main|develop|release)"` a lot in the below scripts. This is a regular expression that excludes those long-lived branches so those won't be considered.

To **list** all **local** branches that have been merged into the current branch:

```
git branch --merged | egrep -v "(^*|master|main|develop|release)"
```

To **list all branches** that have been merged into the current branch:
```
git branch -r --merged | egrep -v "(^*|master|main|develop|release)"
```
To **PURGE** all **local** branches that have been merged into the current branch:
```
git branch --merged | egrep -v "(^*|master|main|develop|release)" | xargs git branch -d
```


## STOP!

> Be very, VERY certain you know what you are doing. This following command modifies the shared repo and unless there is a perfect clone, it has the potential to remove branches that people don’t have a reference to. 


To **PURGE** all **REMOTE** branches that have been merged into the current branch:
```
git branch --merged | egrep -v "(^*|master|main|develop|release)" | xargs git push --delete origin
```
Git Anti-patterns
Tags: git, productivity, beginners
Published: 2022-06-06 15:47:06

Git has ENORMOUS flexibility. It can sometimes (always) be intimidating.  So much so, there are [countless](https://dev.to/t/git) articles on "this is better than THAT".  Don't worry, this won't be one of those articles. 

I'm here to air out some dirty laundry. You know, the _anti-patterns_. The stuff that makes us cringe. The cautionary tales.

## The Uncreative

- Same Commit Message, Different Day

```
fb14c9 updates
1fcf56 updates
0e2506 updates
970bc6 updates
ae3aaf updates
2e3aa6 updates
e62616 updates
d5a520 updates
c3a77d updates
b9fba4 updates
```

## The Deal With It Later

- Branches for DAYS, weeks, ...months...years?
![Too Many Branches](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lmn2tl7g2s7pqjmoihfe.png)

## The Silo

![84 years since you pulled down develop](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fza0j05m9ochtwdi7dle.png)

## One Commit To Rule Them All

- You keep force pushing the same commit with different changes

![wait you guys make unique commits](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/f3zwqg3lpvypbzcjlc9m.png)
  
## Squashing is for posers

- Don't like squashing your commits

```
fb14c9 it works
1fcf56 trying something else
0e2506 fixes
970bc6 reply to pr
ae3aaf it doesn't work
2e3aa6 it works again
e62616 something is broken
```
In 99% of cases, Marketing and Sales team always forget this...
Published: 2022-06-06 15:45:28

I came across a term today "Smarketing" from a techonology/saas provider/company.

I know the point here is that they are talking solely about Marketing and Sales, however, nowhere in their document (at all) could I find any reference to their technology or how their "smarketing" team(s) communicate with their IT department.

Why, oh why, do marketing and sales always leave out the tech teams, when it is the products that these teams develop, are getting sold by "smarketing"

Do they forget that there can be no sales, and there can be no marketing without the existance of the technology or IT department involved? Do they forget that it is the features and the funtionality that the tech teams develop, that brings value to the products that are "smarketed"? Or do they really believe that the product owners are only sales or marketing staff?

I've experinced firsthand on more than one occasion, being pitched a product, and that when asked any question about how it works, the "smarketing" is at a loss and typically did not know how it would fit our needs or requirements. This could be solved if they actually involve their tech teams into their knowledge base.

Good luck with "smarketing" is all I can say. Sure you can sell today where it doesn't matter, but when it comes down to the longevity of operations, I'm sure it will be a painful process for those in marketing and sales trying to follow this principle of "smarketing" when asked any questions about the product.
NFT Export | Made with Next JS
Published: 2022-06-06 15:43:43

![NFT Export | Made with Javascript | Next JS](https://res.cloudinary.com/madewithjavascript/image/upload/v1653683888/large_nft_export_made_with_next_js_738551d3af.jpg "NFT Export | Made with Javascript | Next JS")


### Generate, preview and edit your 10,000 NFT collection with metadata in minutes for free.

> ### Free No-Code
> ### NFT Generator
> Generate, preview, edit and download your 10,000 NFT collection with metadata in minutes for free. Created for artists, zero code knowledge required.
> 
> ### Create a 10k collection for FREE
> NFT Export lets you generate and export unlimited NFT collections with no charge, no watermarks, etc. We've worked hard to bring a service like this to enable independent artists experiment with generative art and build amazing collections.
> 
> ### Built for artists
> Create a production-ready NFT collection in a few easy steps:
> 
> - Drag-and-drop traits in PNG format
> - Setup items rarity and collection settings
> - Preview and edit any item
> - Download the assets with metadata
> - Done! Your collection is ready to be deployed.
> 
> ### Launch and sell your NFT collection
> We're working on the set of tools that will let you deploy your NFT collection to Etherium, Polygon and Solana without writing a line of code. Join the waitlist to get early access when the toolkit is released.

## Check out more such amazing projects on our website

[Made with Javascript](https://madewithjavascript.club)

## Want us to feature your project

[Submit your Project to Made with Javascript](https://madewithjavascript.club/submit-project)


You can also write to us for any of your queries at:

[Email Made with Javascript](mailto:madewithjavascript@gmail.com)

## Project already shared on our social media handles.

| SocialMedia | SharedLink |
| ----------- | ---------- |
| Twitter | [NFT Export on Twitter](https://twitter.com/withjavascript/status/1533834414689484802?s=20&t=Ez3LW8FTX1XWwmaxWUxf3Q)
 |
| Medium | [NFT Export on Medium](https://medium.com/@madewithjavascript/nft-export-made-with-next-js-560da3998a89)
 |
| Facebook | [NFT Export on Facebook](https://www.facebook.com/madewithjavascript/posts/pfbid0BVuyzfELHBvXrS61JGSzaPwBG5F5pGDtbvCaMTQf9e6CSGtx4Qn1nTDR6ofPExJdl)
 |
| Tumblr | [NFT Export on Tumblr](https://www.tumblr.com/blog/view/madewithjavascript/686324256030752768?source=share)
 |
| LinkedIn | [NFT Export on LinkedIn](https://www.linkedin.com/feed/update/urn:li:activity:6939600614712635392)
 |
| Pinterest | [NFT Export on Pinterest](https://pin.it/263O2Gl)
 |


Filled Under:
 - [Made with Javascript](https://madewithjavascript.club)    
 - [Made with Next JS](https://madewithjavascript.club/categories/next-js)

Make sure to give this post ❤ 50 ❤ hearts, click the 🦄 unicorns 🦄 and follow 👉 @madewithjavascript 👈 for more such awesome showcases. Show you love for the people who have worked so hard!
Reverse Prefix of Word
Tags: leetcode, dsa, theabbie
Published: 2022-06-06 15:30:39

Given a **0-indexed** string `word` and a character `ch`, **reverse** the segment of `word` that starts at index `0` and ends at the index of the **first occurrence** of `ch` (**inclusive**). If the character `ch` does not exist in `word`, do nothing.

*   For example, if `word = "abcdefd"` and `ch = "d"`, then you should **reverse** the segment that starts at `0` and ends at `3` (**inclusive**). The resulting string will be `"dcbaefd"`.

Return _the resulting string_.

**Example 1:**

**Input:** word = "abcdefd", ch = "d"
**Output:** "dcbaefd"
**Explanation:** The first occurrence of "d" is at index 3. 
Reverse the part of word from 0 to 3 (inclusive), the resulting string is "dcbaefd".

**Example 2:**

**Input:** word = "xyxzxe", ch = "z"
**Output:** "zxyxxe"
**Explanation:** The first and only occurrence of "z" is at index 3.
Reverse the part of word from 0 to 3 (inclusive), the resulting string is "zxyxxe".

**Example 3:**

**Input:** word = "abcd", ch = "z"
**Output:** "abcd"
**Explanation:** "z" does not exist in word.
You should not do any reverse operation, the resulting string is "abcd".

**Constraints:**

*   `1 <= word.length <= 250`
*   `word` consists of lowercase English letters.
*   `ch` is a lowercase English letter.

**SOLUTION:**

    class Solution:
        def reversePrefix(self, word: str, ch: str) -> str:
            try:
                i = word.index(ch)
            except:
                i = 0
            return word[:i+1][::-1] + word[i+1:]