teleren/devto huggingface dataset:
Advent of PBT 2021 - Day 18
Tags: challenge, testing, webdev, javascript
Published: 2021-12-18 09:57:38

---
title: Advent of PBT 2021 - Day 18
published: true
description: Advent of Property Based Testing - Day 18
tags: challenge,testing,webdev,javascript
//cover_image: https://direct_url_to_image.jpg
---

> _Advent of PBT 2021 — Learn how to use property based testing and [fast-check](https://github.com/dubzzz/fast-check) through examples_

Our algorithm today is: **isPalindrome**.
It comes with the following documentation and prototype:
```ts
/**
 * A string s is said to be a palindrome
 * if it reads the same backward and forward
 *
 * @param s - The strings to be assessed
 */
declare function isPalindrome(s: string): boolean;
```

We already wrote some examples based tests for it:
```ts
it("should detect palindromes made of even ascii characters", () => {
  expect(isPalindrome("azza")).toBe(true);
});

it("should detect palindromes made of odd ascii characters", () => {
  expect(isPalindrome("azereza")).toBe(true);
});

it("should detect palindromes made of characters outside of bmp plan", () => {
  expect(isPalindrome("🐱🐴🐱")).toBe(true);
});

it("should detect non palindromes made of even ascii characters", () => {
  expect(isPalindrome("azea")).toBe(false);
});

it("should detect non palindromes made of odd ascii characters", () => {
  expect(isPalindrome("azera")).toBe(false);
});
```

How would you cover it with Property Based Tests?

In order to ease your task we provide you with an already setup CodeSandbox, with examples based tests already written and a possible implementation of the algorithm: https://codesandbox.io/s/advent-of-pbt-day-18-v924d?file=/src/index.spec.ts&previewwindow=tests

You wanna see the solution? Here is the set of properties I came with to cover today's algorithm: https://dev.to/dubzzz/advent-of-pbt-2021-day-18-solution-28h3

---

[Back to "Advent of PBT 2021"](https://dev.to/dubzzz/advent-of-pbt-2021-13ee) to see topics covered during the other days and their solutions.

More about this serie on [@ndubien](https://twitter.com/ndubien) or with the hashtag [#AdventOfPBT](https://twitter.com/search?q=%23AdventOfPBT).
Laravel Arr prepend() function
Tags: php, laravel, programming, beginners
Published: 2021-12-18 09:35:26

Let's start quickly, I found the prepend function and I want to share it with you
I will explain you how to work laravel array prepend() function. We will show example of array prepend function to get array prepend element value in laravel.The Arr::prepend method will push an item onto the beginning of an array
```php
$array = ['php', 'laravel', 'html','css'];
$prepended = Arr::prepend($array,'Vue');
print_r($prepended ); //['Vue', 'php', 'laravel', 'html', 'css']
```
Other use for Dropsdown
```php
User::pluck('name','id')->prepend('Plz Select','');
/*
 all: [ 
  "" => "Plz Select"
  1 => "User k",
  2 => "Euna Dau",
  ......
 ]
*/
```
I hope you enjoyed the code.
WordPress-Umzug: Die 12 besten Migrations-Plugins
Tags: wordpress, hosting
Published: 2021-12-21 14:30:28

---
title: WordPress-Umzug: Die 12 besten Migrations-Plugins
published: true
date: 2021-12-18 09:14:39 UTC
tags: WordPress,hosting
canonical_url: https://bloggerpilot.com/wordpress-umzug/
---

![WordPress Umzug - So gelingt der Hosting-Wechsel](https://bloggerpilot.com/wp-content/uploads/2021/11/wordpress-umzug.png)

Hallo! Wir alle lieben WordPress. Es ist eine wunderbare, leistungsstarke und flexible Plattform, die sich mit der Welt der Webentwicklung weiterentwickelt hat. Jetzt ist es mehr als nur eine Blogging-Plattform - es ist ein vollwertiges CMS, mit dem du dein Unternehmen, deine Website und deine App aufbauen kannst.

Der Original-Artikel erschien auf [WordPress-Umzug: Die 12 besten Migrations-Plugins](https://bloggerpilot.com/wordpress-umzug/).


Wenn eine Website von einem anderen Hosting-Anbieter auf WordPress umgezogen wird, kann das eine sehr komplizierte und zeitaufwändige Aufgabe sein. Egal, ob du am anderen Ende der Leitung sitzt und einen anderen PC verwendest oder deinen jetzigen, die Aufgabe, deine WordPress-Website auf einen neuen Server zu verschieben, kann entmutigend sein. Um dieses Problem zu lösen, ist es ratsam, WordPress-Migrations-Plugins zu verwenden, die immer wichtiger werden, wenn du WordPress häufig benutzt. Außerdem sind sie kostengünstig und können in wenigen Minuten installiert werden.

Mit WordPress gibt es viele Möglichkeiten, deine Website auf einen neuen Hoster zu migrieren. Es gibt verschiedene Plugins, die dir dabei helfen können, aber nicht alle Plugins sind gleich gut. Manche haben Funktionen, die nicht ausreichen, oder weisen Fehler auf, die nicht leicht zu beheben sind. Um sicherzustellen, dass du nur die besten verwendest, findest du hier die 12 besten Migrations-Plugins für WordPress.
Yielding Bells 🔔 - generators in PHP
Tags: php, webdev
Published: 2021-12-18 08:51:30

Today we want us some bells in our Christmas, so let's create them. PHP has a neat feature called generators. Generators are functions that can be used to create iterators, and they don't need a large overhead to create them. For performance sake, let's compare two code snippets.  
**Snippet 1**:
```php
<?php 

function produceBells(int $num)
{
    $bells = [];
    for ($i = 0; $i < $num; $i++) {
        $bells[] = '🔔';
    }
    return $bells;
}
$hundredBells = produceBells(100); // 8.3KB

foreach ($hundredBells as $bell) {
    echo $bell . ' ';
}
```

**Snippet 2**:
```php
function generateBells(int $num)
{
    for ($i = 0; $i < $num; $i++) {
        yield '🔔';
    }
}
$hundredBells = generateBells(100); //544 bytes

foreach ($hundredBells as $bell) {
    echo $bell . ' ';
}
```

Both these snippets will produce this output:  
🔔 🔔 🔔 🔔 🔔 🔔 🔔 🔔 🔔 🔔 🔔 🔔 🔔 🔔 🔔 🔔 🔔 🔔 🔔 🔔 🔔 🔔 🔔 🔔 🔔 🔔 🔔 🔔 🔔 🔔 🔔 🔔 🔔 🔔 🔔 🔔 🔔 🔔 🔔 🔔 🔔 🔔 🔔 🔔 🔔 🔔 🔔 🔔 🔔 🔔 🔔 🔔 🔔 🔔 🔔 🔔 🔔 🔔 🔔 🔔 🔔 🔔 🔔 🔔 🔔 🔔 🔔 🔔 🔔 🔔 🔔 🔔 🔔 🔔 🔔 🔔 🔔 🔔 🔔 🔔 🔔 🔔 🔔 🔔 🔔 🔔 🔔 🔔 🔔 🔔 🔔 🔔 🔔 🔔 🔔 🔔 🔔 🔔 🔔
> Is that a hundred bells? I sure hope so, I get lost when counting them!

The question is now, which is less memory intensive, and why is **Snippet 2**?! I ran both snippets with profile-mode on Xdebug and found the following result:  

| Snippet | Type | Memory usage |
| ------ | ------ | ------ |
| **1** | Array | 8280 bytes |
| **2** | Generator | 544 bytes | 

As we can see, the generator is a lot more memory efficient than the array. The reason for this is that generators are lazy, and only generate the values when they are needed. This means that the memory usage is only as high as the amount of values that are actually needed. And as we loop through one item at a time to echo it out, that is as much memory as will be used. You could output a million of these things if you like, and the memory usage would not be that much higher. (In fact, it remained at 544 bytes when I ran it.)

So what's the cost? Generators, while memory efficient, are not as time efficient. My machine is not stable enough (poor potato), to do a fair benchmarking. But at a thousand bells we got 9.2 ms for the array and 11.6 ms for the generator. So is it worth it for you to use generators? That question has not only to do with time versus memory cost. If you don't know how often you will need to access an array (or iterator) value, you may need to use a generator anyway.

## What about you?
Have you ever tried a generator before? What use cases do you have or think you would have for generators? Comment below and let us know what you think ✍

## Further Reading
* Generators Overview: https://www.php.net/manual/en/language.generators.overview.php
How to Code an API Call with React!
Tags: react, javascript, tutorial
Published: 2021-12-18 08:16:11

Hey **fellow creators**

Let's code an *API Call* with React. 
This is pretty common and you need to master it if you want to use React.
 
If you prefer to watch the video **version**, it's right here :

{%youtube bBjsFmagQXc%}

##1. The hooks you need!

You need to import two hooks:

```react
import {useState, useEffect} from "react";

function App(){
	return(
		<div className="app">
			<h1>React API Call</h1>
		</div>
	)
}

export default App;
```

Now create your state which will start at false since at first you don't have any data:

```react
import {useState, useEffect} from "react";

function App(){

	const [imgURL, setImgURL] = useState(false);

	return(
		<div className="app">
			<h1>React API Call</h1>
		</div>
	)
}

export default App;
```


##2. Fetch an API

Find a random image API and do a fetch when the component is mounted, using the hook *useEffect()*. 


Let's start by simply logging the response of the fetch to check if it's working:

```react
useEffect(() => {
	fetch('https://source.unsplash.com/random/600x800')
	.then(res => console.log(res))
}, [])
```

It will be triggered after the first render of the component!

Since the response is not JSON, you don't need to parse it, you can just extract the URL from it.

```react
useEffect(() => {
	fetch('https://source.unsplash.com/random/600x800')
	.then(res => setImgURL(res.url))
}, [])
```

Now you can add the image to your JSX:

```react
return(
		<div className="app">
			<h1>React API Call</h1>
			{imgURL && <img src={imgURL} />}
		</div>
	)
```


You're using the short circuit operator, meaning that it'll only render the image if *imgUrl* is true.

If you refresh the page, you'll see that you have a different image each time!

This is how you can do a pretty *basic API call with React*!


Come and take a look at my **Youtube channel**: https://www.youtube.com/c/TheWebSchool

*See you soon!*

Enzo.
Don't Post Your College Programming Problems in Stack Overflow
Tags: programming, beginners, tutorial
Published: 2021-12-18 08:04:27

Don't post your college programming problems in Stack Overflow and here's why...

I am a first-year IT college student and for the last 2 months, I have a Stack Overflow account for asking my coding problems in my Programming subject. I asked for my homework and solving problems. When I have hard time to search most of error codes, it never answers my questions. When I asked my friends and classmates, they didn't answer my problem in coding. My last resort is posting the error on Stack Overflow. 

When I posted my code on Stack Overflow, things are not like what I expected. I thought that they will answer all my questions and get many upvotes. I got many downvotes and even though I got the answer I needed, they never liked the question. I posted another question, hopefully I got what I expected to be. It turns out, I got another downvotes and one answers says that "It has so much errors...", "Don't post your college homework questions in Stack Overflow, it was highly discouraged"

![Stack Overflow Question](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pl9it8p0h3c6x24p6tk7.jpg)

I forgot to say that my subject requires only this knowledge and my professor doesn't accept some functions and variables that were not yet discussed. My questions should be improved but because I was new to the community, it was like I was not welcome in the community.

If you are new in programming and still having a hard time on coding especially if you are first year college in Computer Courses, here are most acceptable things you need to consider.

1. Ask GOOGLE

- You need to ask Google if you have any coding topics that you were not able to understand. You may search on Google and Youtube for some answers. You may also read some similar problems on Stack Overflow BUT DON'T POST IT.

2. Ask a fellow coder

- If you have a friend who is a coder or yet a professional developer and are willing to help you on coding problems, you may ask them.

3. Ask in the Programming Groups

- Ask in the programming groups (like in Facebook) and they are willing to help you to solve your problems.

There are so much thing to learn on the internet. A message to fellow coders out there, always welcome to criticisms and more improvements. For professional coders, always welcome to help other future coders and always remember that you experienced just like them. Be friendly to everyone.
10 HTML anchor tag usages you must know(in short videos)
Tags: html, codenewbie, beginners, tutorial
Published: 2021-12-18 08:03:41

As a webdev, you must have used the anchor(a) tag ample times. The regular usages are, linking to a webpage, opening the page in a new tab, or linking to a page section.

However, there are other usages, you should know as well. I have created a short video series to cover all the usages. The series also includes a video to style anchor tag. I hope you find them helpful and enjoy watching them.

> If you like the content, please [SUBSCRIBE](https://www.youtube.com/tapasadhikary?sub_confirmation=1) to the channel for the future content

## Introduction

{% youtube neWThioR5hw %}

## 1. How to link to a webpage?

{% youtube 14FMaWBraHk %}

## 2. How to link to a page section?

{% youtube b13_b9-dU34 %}

## 3. How to link to an email app?

{% youtube y5-H80Fgt00 %}

## 4. How to link to a phone app?

{% youtube HsNRjcwmYrI %}

## 5. How to link to a JavaScript function?

{% youtube vz2ri3TpHcE %}

## 6. How to download a file?

{% youtube Fbt-MCbzRKs %}

## 7. How to open the page in the new tab/window?

{% youtube MabUqWfBt6M %}

## 8. What about the new tab opening and Security concerns?

{% youtube FsWgQt0_OeY %}

## 9. How to link to parent frames?

{% youtube eDbTlVFpreo %}

## 10. How to use the ping attribute for tracking?

{% youtube wZ9dzzlbIK8 %}

## Bonus: How to style an anchor tag?

{% youtube iv1grAVAG1w&t=136s %}

TADA!!! We are done. I hope you enjoyed the videos, and it was worth your time. I have written an in-depth article on the same topic and published it on freeCodeCamp. You may want to take a look,

> [The HTML <a> Tag – Anchor Tag Example Code](https://www.freecodecamp.org/news/the-html-a-tag-anchor-tag-example-code/)

<hr />

Let's connect. I share my learnings on JavaScript, Web Development, and Blogging on these platforms as well,

-  [Follow me on Twitter](https://twitter.com/tapasadhikary) 
-  [Subscribe to my YouTube Channel](https://www.youtube.com/tapasadhikary?sub_confirmation=1) 
- [Side projects on GitHub](https://github.com/atapas)
Chrome extension for binge watchers
Tags: javascript, webdev, productivity
Published: 2021-12-18 08:03:32

Just a week of engineering and developed this very useful chrome extension for all the binge-watchers. 🚀  

![Chrome Extension Video progress indicator](https://devlabworks.s3.ap-south-1.amazonaws.com/ezgif.com-gif-maker.gif)

💻 This extension will display a numeric percentage on the top right side of the player and will show the progress of the video completed.

Either Binge-watching or just exploring youtube videos, always be informed of the video progress in the form of a percentage. Being an engineer, I always have an eye for User Experience in any product that I use.

So while watching videos on major OTT platforms, after switching to full screen, I had to hover over the screen again and again to check the remaining time and the same scenario occurred during college days while preparing for exams, long lectures on youtube watching at 2X speed and that too one day before the exam, it was hard for me to cope-up with those lectures and waiting when it will end.

So in order to ease my life, I developed this extension. After successfully testing it on youtube, extended the support for Netflix, Amazon Prime Video, Disney HotStar, and many other platforms.

I’ve added it on google chrome store

You can try and do let me know if there is any room for improvement.

[Chrome Store Link](https://bit.ly/3yEUUis)
[Website Link](https://bit.ly/3Eeh6l2)

Have some questions? Would love to connect on [LinkedIn](https://www.linkedin.com/in/ali-abbas-software-developer/)
How we upload File with some data to nodeJS using Simple Form
Tags: node, javascript, webdev, database
Published: 2021-12-18 07:50:27

## Configuration
first you have to install some libraray to your to your project

> npm i express multer mongoose

## index.js

```
app.use(express.static(__dirname('/public'))
//set folder as static folder
app.use(express.urlencoded({extended:false}))
//set req.body of data are accessible from index.html
```

```
`<form action="/api/post" method="post" enctype="multipart/form-data" >
<input type="text" name="name"/>
<input type="email" name="email"/>
<input type="file" name="file" id="file" />
<nput type="submit" />
</form>`
```

## index.js

```
`const upload = multer({ dest: 'uploads/' })

const app = express()
//this code for single file upload
app.post('/api/post', upload.single('file'), function (req, res, next) {
  const {name,email}=req.body
  // req.file is the `file` file
     res.send({name,email,filename:req.file.filename})
  // req.body will hold the text fields, if there were any
})
```

`
What free Reddit proxy’s I can trust?
Published: 2021-12-18 07:36:12

Residential proxies are in the spotlight nowadays and this is so for a good reason. Either it is for account management, market research or purchasing limited-edition sneakers — data-center IP addresses might not be enough.

There have been too many questions about how to buy residential proxies. Here are four reasons for choosing Roxlabs:

1. Have a large IP proxy pool. Worldwide, it has 90 million residential IP and network coverage in more than 200 countries.

2. Have the fastest network connection speed. The unique feature of Roxlabs architecture is that it can provide single hop connection for residential proxies. Traffic is not routed through end-user devices, so there is no bottleneck.

3. Provide free trial. After a new user is registered, 500MB traffic is automatically received, which can be directly extracted and used without limiting the amount of IP.

4. Relatively favorable price. Only $3 / GB can start the residential proxies program, provide the best price in the market, and the quality is like the best-selling product, or even better.
Case-sensitive and Case-insensitive String Comparisons in PowerShell
Tags: powershell, quicktip
Published: 2021-12-18 07:34:08

I wrote a PowerShell script the other day and, while doing so, discovered an interesting fact about string comparison in PowerShell that is quite contrary to .NET (and thus unfamiliar for me): string comparisons are case-insensitive by default.

This caught me off-guard since my particular use case required a case-sensitive comparison. I managed to get case-sensitive comparisons to work and thought I'd share it.

## Using the Equals operator (-eq/-ceq)

When you would like to see if two strings are exactly the same, you can make use of the equals operator.

### Case-Insensitive Equals (-eq)
You can use `-eq` to perform a case-insensitive string comparison.

```powershell
❯ "Ivan Kahl's Blog" -eq "ivan kahl's BLOG"
True
```

### Case-Sensitive Equals (-ceq)

If you would like to do a case-sensitive string comparison, you can use `-ceq`:

```powershell
❯ "Ivan Kahl's Blog" -ceq "ivan kahl's BLOG"
False
```

## Using the Like operator (-like/-clike)
You can also use patterns for string comparisons using the Like operator in Powershell.

### Case-Insensitive Like (-like)
If you want to use a pattern for string comparison and not worry about the case, use `-like`:

```powershell
❯ "Ivan Kahl's Blog" -like "ivan kahl's*"
True
```

### Case-Sensitive Like (-clike)
If you do want to check case while using string patterns, you can make use of `-clike`:

```powershell
❯ "Ivan Kahl's Blog" -clike "ivan kahl's*"
False
```

## Closing

I hope you found this quick tip useful. If you have any questions or thoughts, please leave a comment below.
Atom With Auto Complete
Published: 2021-12-18 07:33:32

Nothing works!!!
Atom has blocked access to its servers shoudl the IP belong to an Iranian IP range. 

Trying 
`source torsocks on`
failes because the IP seems to be blacklisted.

Using a paid VPN service semi-worked as it did allows some resources to be accessible but seems some other servers have a comperhensive list that may block other IP addresses
`wget -qO - https://packagecloud.io/AtomEditor/atom/gpgkey | sudo apt-key add -
sudo sh -c 'echo "deb [arch=amd64] https://packagecloud.io/AtomEditor/atom/any/ any main" > /etc/apt/sources.list.d/atom.list'
sudo apt-get update
Install Atom`


Spell checker wont work
sudo apt-get install hunspell
sudo apt-get install hunspell-en-gb
sudo apt-get install myspell-en-gb myspell-tools myspell

then this was found:
https://hackernoon.com/setting-up-atom-as-a-python-ide-a-how-to-guide-o6dd37ff
Top 10 Machine Learning APIs
Tags: machinelearning, ai
Published: 2021-12-18 06:42:19

Top ten APIs for your Machine learning projects from **RapidAPI** 

**1️⃣ OOPSpam Spam Filter**

OOPSpam Anti-Spam API helps you better identify spam content for contact forms, comment systems, blogs, live chat, etc.
[API Link](https://t.co/l7ATJ7fIYG)

**2️⃣ Speech Recognition English**

Speech Recognition English API can convert any English voice to text.

[API Link](https://t.co/Rmj8oezaO7)

**3️⃣ Deep Face Detect**

Deep Face Detect API is based upon a deep neural network architecture powered by GPU acceleration. Provides coordinates for all faces detected in an image and supports face sizes as tiny as 24x24 pixels.

[API Link](https://t.co/yh3Y36DhI2)

**4️⃣ Face Mask Detection**

Face mask detection API can recognize all the faces in the image and say whether people have masks or not.

[API Link](https://t.co/sOt52Q4Ave)

**5️⃣ Face Detection and Facial Features**

This API provides face coordinates for all faces detected in an image.

[API Link](https://t.co/VimVhmYpu8)

**6️⃣ Paraphrasing Tool**

A paraphrasing tool API can automatically rewrite sentences, phrases, or paragraphs.

[API Link](https://t.co/CWbERgDhLW)

**7️⃣ General Detection**

This ready-to-use API offers high-accuracy detection of different types of objects framing them with bounding boxes and predicting their class.

[API Link](https://t.co/AiDHybmfYJ)

**8️⃣ Deepmind**

Deepmind API detects different things in images.

[API Link](https://t.co/SpbMIk0yBt)

**9️⃣ OCR text extract**

A Powerful optical image character recognition (OCR) for over 20 languages and with machine-zone readable support.

[API Link](https://t.co/W3nj4AskkY)

**🔟 Text To Speech**

Text To Speech API can convert any text to voice.

[API Link](https://t.co/YdMuvBtBqm)

Really helpful APIs give it a try.

To handle APIs using only 
VS CODE editor see my previous post about Postman👇
[Do not use Postman use VS code](https://dev.to/saifullah/i-dont-need-to-use-postman-anymore-51pp)