teleren/devto huggingface dataset:
Symfony, Elasticsearch - model data layer - Part 5 Tutorial
Published: 2022-06-03 14:50:58

Hi, the 5th article devoted to the theme: “How to work with ElasticSearch using Symfony PHP framework” already ready for reading. Here will speak about model data layer and ONGR symfony bundle. All details are here: "[Symfony, elasticsearch - model data layer](https://sergiiblog.com/symfony-elasticsearch-model-data-layer/)". Have a pleasant reading.
Recover Binary Search Tree
Tags: leetcode, dsa, theabbie
Published: 2022-06-03 14:30:37

You are given the `root` of a binary search tree (BST), where the values of **exactly** two nodes of the tree were swapped by mistake. _Recover the tree without changing its structure_.

**Example 1:**

![](https://assets.leetcode.com/uploads/2020/10/28/recover1.jpg)

**Input:** root = \[1,3,null,null,2\]
**Output:** \[3,1,null,null,2\]
**Explanation:** 3 cannot be a left child of 1 because 3 > 1. Swapping 1 and 3 makes the BST valid.

**Example 2:**

![](https://assets.leetcode.com/uploads/2020/10/28/recover2.jpg)

**Input:** root = \[3,1,4,null,null,2\]
**Output:** \[2,1,4,null,null,3\]
**Explanation:** 2 cannot be in the right subtree of 3 because 2 < 3. Swapping 2 and 3 makes the BST valid.

**Constraints:**

*   The number of nodes in the tree is in the range `[2, 1000]`.
*   `-231 <= Node.val <= 231 - 1`

**Follow up:** A solution using `O(n)` space is pretty straight-forward. Could you devise a constant `O(1)` space solution?**SOLUTION:**

    # Definition for a binary tree node.
    # class TreeNode:
    #     def __init__(self, val=0, left=None, right=None):
    #         self.val = val
    #         self.left = left
    #         self.right = right
    class Solution:
        def inorder(self, root, append):
            if root:
                self.inorder(root.left, append)
                if append:
                    self.vals.append(root.val)
                else:
                    root.val = self.vals[self.i]
                    self.i += 1
                self.inorder(root.right, append)
        
        def recoverTree(self, root: Optional[TreeNode]) -> None:
            self.vals = []
            self.inorder(root, True)
            self.vals.sort()
            self.i = 0
            self.inorder(root, False)
How to use custom font in java swing....
Tags: java, swing, font, desktop
Published: 2022-06-03 14:23:16

Hello there, I am back again.

Today i am going to show you how you can use custom font or how you can customize your fonts in java swing.So, Let's get started...

First we need to create a Frame..

```java
import javax.swing.JFrame;

public class CustomFont extends JFrame{

    public CustomFont()  {
        this.setBounds(300,100,400,300);
        this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    }
    
    public static void main(String[] args) {
        CustomFont frame=new CustomFont();
        frame.setVisible(true);
    }
}

```java
This will create a nice frame.

I do not want to use any `Layout` for that i need to add this line in the `Constructor`

```java
this.setLayout(null);
```

Now i want to use custom font in a textField.For that i need to create a field.

First import `JTextField`

```java
import javax.swing.JTextField;
```

Declare textField as a `private class field` 

```java
private JTextField text;
```

Now create and add textField to the frame

```java
text=new JTextField();
text.setBounds(20,20,150,30);
add(text);
```

Now i want to customize this fields font
For that i need to create an instance of `Font` class.You can create an instance of font class like this.

First import `Font` class

```java
import java.awt.Font;
```

Then

```java
Font font=new Font("Fira Code",Font.PLAIN,12);
```

First you need to give Font Name then Font Style and Font size.Now you need to add the font to the field.

```java
 text.setFont(font);
```

Now your field should have a customized font.
What Interesting Python 🛰️ projects have you built ?
Tags: programming, python, discuss, watercooler
Published: 2022-06-03 14:21:51

What Python interesting projects have you or your friends create lately ?
This is a very interesting 15 minutes Python tutorial on how to build an International Space Station tracker in real-time and showing the real-time movement of the ISS on the map.


{% youtube 5UWeOfdESZE %}
My First NPM Package react-native-paginated-modal-picker
Tags: reactnative, javascript, npm, github
Published: 2022-06-03 14:21:37

Hello Everyone,

Four months ago, I developed an NPM package.

It is named react-native-paginated-modal-picker.

It basically is a single and multiple react native modal picker with pagination.

I Managed to use react natives' components only (without any external packages)!

You can find documentation on how to start using it on NPM/GitHub 

NPM:  [react-native-paginated-modal-picker](https://www.npmjs.com/package/react-native-paginated-modal-picker).

GitHub (With an Example):  [react-native-paginated-modal-picker](https://github.com/AhmedHalbas/react-native-paginated-modal-picker).

Please don't hesitate to tell me what you think.

Thanks for reading :D
How to Create a Service Website That Converts?
Tags: website, web, wedevelopment
Published: 2022-06-03 14:20:37

{% youtube TJrACi0rLKY %}

Hi! How to create a service website that converts? Our Head of Design will share some expert tips about how to make any website work. Get some leads!

Enjoy! You can also read the article at [Frontend House](https://frontendhouse.com/experts-zone/how-to-create-a-service-website-that-converts-experts-zone-24).
📜Awesome Page Scroll Effect | HTML & CSS✨
Tags: html, css, beginners, webdev
Published: 2022-06-03 14:20:28

**How to make Awesome Full Page Scroll Effect using html &css Using HTML & CSS, step-by-step from scratch.
Let’s create a nice scroll animation with just 4 lines of code!**

{% youtube uV8kH5RgSZU %}

**Markup**

```html
<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>CSS SNAP EFFECT</title>
  <link rel="stylesheet" href="style.css">
</head>

<body>

  <div class="container">

    <section class="one">
      <h1>First Page</h1>
    </section>

    <section class="two">
      <h1>Second Page</h1>
    </section>

    <section class="three">
      <h1>Third Page</h1>
    </section>

    <section class="four">
      <h1>Web Dev</h1>
    </section>
  </div>

</body>

</html>
```

**CSS**
```css
@import url('https://fonts.googleapis.com/css2?family=Poppins&display=swap');

* {
	margin: 0;
	padding: 0;
	box-sizing: border-box;
	font-family: "Poppins", sans-serif;
}

.container {
	scroll-snap-type: y mandatory;
	overflow-y: scroll;
	height: 100vh;
}

section {
	height: 100vh;
	display: flex;
	justify-content: center;
	align-items: center;
	scroll-snap-align: start;
}

h1 {
	color: rgb(226, 226, 226);
	text-shadow: 1px 1px 4px #000;
}

.one {
	background-color: rgb(36, 164, 138);
}
.two {
	background-color: rgb(211, 79, 79);
}
.three {
	background-color: rgb(67, 91, 175);
}
.four {
	background-color: rgb(191, 64, 191);
}
```

🛴 Follow me on: 
Facebook: https://bit.ly/3cp2S5W
YouTube: https://bit.ly/3oBQbc0
Twitter: https://bit.ly/3zejZ6f
This Week in Python
Tags: python, discuss
Published: 2022-06-03 14:17:19


**Fri, June 03, 2022**


This Week in Python is a concise reading list about what happened in the past week in the Python universe. 


## Python Articles

- [Compiling Black with mypyc](https://ichard26.github.io/blog/2022/05/31/compiling-black-with-mypyc-part-1/) – Release 22.1.0 of Black was special, not only was it the first stable version of Black, it was also the first release to ship with mypyc compiled wheels, doubling performance 
- [People in your software supply chain](https://sethmlarson.dev/blog/people-in-your-software-supply-chain) – The people behind Python packages
- [Pointers, strings, and (im)mutability](https://dleybz.medium.com/pointers-strings-and-im-mutability-680b15dd4a70)
- [Callables: Python's "functions" are sometimes classes](https://www.pythonmorsels.com/class-function-and-callable/)
- [What’s in which Python](https://nedbatchelder.com/text/which-py.html) – summary of what features appeared in which versions of Python


## Projects

- [dunk](https://github.com/darrenburns/dunk) – Prettier git diffs
- [huey](https://github.com/coleifer/huey) – a little task queue for python
- [Pipe](https://github.com/JulienPalard/Pipe) – A Python library to use infix notation in Python
- [python-patterns](https://github.com/faif/python-patterns) – A collection of design patterns/idioms in Python
- [DeepFaceLive](https://github.com/iperov/DeepFaceLive) – Real-time face swap for PC streaming or video calls
Paracetamol.js💊| #132: Explica este código JavaScript
Tags: javascript, webdev, spanish, programming
Published: 2022-06-03 14:17:08

## **<center>¿Cuál es el orden de ejecución del siguiente código JavaScript?</center>**
#### <center>**Dificultad:** <mark>Avanzado</mark></center>

```js
async function asyncFunc() {
  console.log('asyncFunc() starts'); 
  return 'abc';
}

asyncFunc().
  then(x => { 
    console.log(`Resolved: ${x}`);
  });
console.log('Task ends'); 
```

A. `asyncFunc() starts`, `Resolved: abc`, `Task ends`
B. `Task ends`, `asyncFunc() starts`, `Resolved: abc`
C. `asyncFunc() starts`, `Task ends`, `Resolved: abc`
D. Ninguna de las anteriores

Respuesta en el primer comentario.

---
M-One Personal Assistant v1.0
Tags: python, assistant, personal, mone
Published: 2022-06-03 14:10:09

Hello guys, 
M-One is a personal assistant who can help you with some simple tasks.
I wrote this program in Python language and I hope it is interesting and useful for you.

## About

I work for minor tasks such as opening websites such as Google, announcing time and date, converting text to audio, creating qrcode, extracting information from wikipedia, downloading photos, etc., translating texts, displaying stored WiFi passwords, displaying public IP You, shut down the computer, create a folder and delete it, the ability to delete files on the computer, and all other features.

This program has two user interfaces: Typing and Listening.

## Installation

To launch the program, first install the required packages and then use the program safely.

Use the `help` command to display the program commands.

## Core Dependencies

* Python 3 (3.9.7)
* translate
* speech_recognition
* webbrowser
* wikipedia
* requests
* pyqrcode
* datetime
* pyttsx3
* urllib
* time
* os

Project at GitHub: https://github.com/Mhadi-1382/M-One-personal-assistant

Information v2.0: https://dev.to/mhadi2003/m-one-personal-assistant-v20-3c6f

Information v2.4 + GUI v1.0: https://dev.to/mhadi2003/m-one-personal-assistant-v24-update-friday-june-24-2022-gui-v10-l4e

> In the future, some features of this program will be added and some of its shortcomings will be eliminated.
You dear ones can also express your opinions and suggestions.
Follow Friday: Ruby Edition (3 June 2022)
Tags: watercooler, meta, ruby, rails
Published: 2022-06-03 14:10:03

---
title: Follow Friday: Ruby Edition (3 June 2022)
published: true
description: 
series: Follow Friday
tags: watercooler, meta, ruby, rails
cover image: https://dev-to-uploads.s3.amazonaws.com/uploads/articles/abs9mm22gbx068oux2d2.png
---

_Happy Friday, friends! 🎉 Follow Friday is your weekly opportunity to shout out fellow DEV Community members doing awesome work. Check out the comments and follow someone new!_

If you’ve been around a while, you might know that DEV is built with [Ruby on Rails](https://dev.to/t/rails). So this week I'm wondering: **who's your favorite DEV author writing about Ruby, Rails, Sinatra, or anything else in the Rubyverse?**

_**Formatting tip**: to populate a card with a follow button, use the liquid tag syntax `{% embed https://... %}` and insert the URL of your favorite author's profile._

Join in on the #FollowFriday fun by tagging your favorite Rubyist (and why you love their posts!) ⤵️
Max Area of Island
Tags: leetcode, dsa, theabbie
Published: 2022-06-03 14:00:47

You are given an `m x n` binary matrix `grid`. An island is a group of `1`'s (representing land) connected **4-directionally** (horizontal or vertical.) You may assume all four edges of the grid are surrounded by water.

The **area** of an island is the number of cells with a value `1` in the island.

Return _the maximum **area** of an island in_ `grid`. If there is no island, return `0`.

**Example 1:**

![](https://assets.leetcode.com/uploads/2021/05/01/maxarea1-grid.jpg)

**Input:** grid = \[\[0,0,1,0,0,0,0,1,0,0,0,0,0\],\[0,0,0,0,0,0,0,1,1,1,0,0,0\],\[0,1,1,0,1,0,0,0,0,0,0,0,0\],\[0,1,0,0,1,1,0,0,1,0,1,0,0\],\[0,1,0,0,1,1,0,0,1,1,1,0,0\],\[0,0,0,0,0,0,0,0,0,0,1,0,0\],\[0,0,0,0,0,0,0,1,1,1,0,0,0\],\[0,0,0,0,0,0,0,1,1,0,0,0,0\]\]
**Output:** 6
**Explanation:** The answer is not 11, because the island must be connected 4-directionally.

**Example 2:**

**Input:** grid = \[\[0,0,0,0,0,0,0,0\]\]
**Output:** 0

**Constraints:**

*   `m == grid.length`
*   `n == grid[i].length`
*   `1 <= m, n <= 50`
*   `grid[i][j]` is either `0` or `1`.

**SOLUTION:**

    class Solution:
        def DFS(self, grid, i, j, m, n):
            if i >= 0 and j >= 0 and i < m and j < n and grid[i][j] == 1:
                grid[i][j] = 0
                self.ctr += 1
                for x, y in [(i - 1, j), (i + 1, j), (i, j - 1), (i, j + 1)]:
                    self.DFS(grid, x, y, m, n)
        
        def maxAreaOfIsland(self, grid: List[List[int]]) -> int:
            m = len(grid)
            n = len(grid[0])
            mArea = 0
            for i in range(m):
                for j in range(n):
                    if grid[i][j] == 1:
                        self.ctr = 0
                        self.DFS(grid, i, j, m, n)
                        mArea = max(mArea, self.ctr)
            return mArea
I created Rattle_motivater 🐍🐍🐍
Tags: webdev, showdev, productivity, python
Published: 2022-06-03 13:58:13

Hello my dear developers i created Rattle_motivater you can motivate yourself with motivational quotes try it now for free.

Motivater link-https://rattleofficial.github.io/motivater

Source code-https://github.com/rattleofficial
Convert number to string in JS
Tags: javascript, webdev, react, programming
Published: 2022-06-03 13:35:58

> _Looking at the title, you might think it's a simple task that any noob can complete. right??_
> _However, the actual question was, write a function that accepts an args as a number and returns the string version of the same number, given that you cannot use string methods like function toString(), or initialise a variable with an empty string, or use any other tricks._

_So we will approach this problem by keeping two points in mind_
- Every number is formed from digits 0-9;
- Divide and conquer rule
- Recursion
 

```
let stringNum;
const arr = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]
let temp;
function convertToString(num) {
  if (num > 0) { // condition will give the string but in reverse order.
    const dividend = num % 10;
    if (temp) {
      temp += arr[dividend];
    } else {
      temp = arr[dividend];
    }
    convertToString(Math.floor(num / 10)); // recursion
  } else {
// here we will reverse the string to get the actual number in string format.
    for (let i = temp.length - 1; i >= 0; i--) {
      if (stringNum) {
        stringNum += temp.charAt(i);
      } else {
        stringNum = temp.charAt(i);
      }
    }

  }
  return stringNum;
}

const result = convertToString(125)
console.log(result) // "125"
```
_Please give it a shot and let me know what you think._

Please ❤️ it and share it your with friends or colleagues. Spread the knowledge.

---

Thats all for now. Keep learning and have faith in Javascript❤️
Encode and Decode TinyURL
Tags: leetcode, dsa, theabbie
Published: 2022-06-03 13:30:39

> Note: This is a companion problem to the [System Design](https://leetcode.com/discuss/interview-question/system-design/) problem: [Design TinyURL](https://leetcode.com/discuss/interview-question/124658/Design-a-URL-Shortener-(-TinyURL-)-System/).

TinyURL is a URL shortening service where you enter a URL such as `https://leetcode.com/problems/design-tinyurl` and it returns a short URL such as `http://tinyurl.com/4e9iAk`. Design a class to encode a URL and decode a tiny URL.

There is no restriction on how your encode/decode algorithm should work. You just need to ensure that a URL can be encoded to a tiny URL and the tiny URL can be decoded to the original URL.

Implement the `Solution` class:

*   `Solution()` Initializes the object of the system.
*   `String encode(String longUrl)` Returns a tiny URL for the given `longUrl`.
*   `String decode(String shortUrl)` Returns the original long URL for the given `shortUrl`. It is guaranteed that the given `shortUrl` was encoded by the same object.

**Example 1:**

**Input:** url = "https://leetcode.com/problems/design-tinyurl"
**Output:** "https://leetcode.com/problems/design-tinyurl"

**Explanation:**
Solution obj = new Solution();
string tiny = obj.encode(url); // returns the encoded tiny url.
string ans = obj.decode(tiny); // returns the original url after deconding it.

**Constraints:**

*   `1 <= url.length <= 104`
*   `url` is guranteed to be a valid URL.

**SOLUTION:**

    class Codec:
    
        def encode(self, longUrl: str) -> str:
            return longUrl
            
    
        def decode(self, shortUrl: str) -> str:
            return shortUrl
            
    
    # Your Codec object will be instantiated and called as such:
    # codec = Codec()
    # codec.decode(codec.encode(url))
CSS short-hands all the time, a good idea?
Tags: webdev, css, beginners, codenewbie
Published: 2022-06-03 13:25:25

Yes yes, I know we all love using shorthand properties wherever we can while writing our CSS, but have you ever considered about the possibilities where you were trying to get something done, set a certain property on a certain element and you would just end up seeing either no results or something totally unwanted? Well I have, a lot of times but I didn't figure it out until very recently when I was just scrolling down the YouTube homepage and I came across a video from "**Kevin Powell**", I believe a lot of you know him and he made a specific video on how using shorthand properties sometimes can result in unnecessary headache.

Lets get into some of the examples:

### Margin:

> margin: 0

As we all know it is a shorthand for:
* margin-top
* margin-right
* margin-bottom
* margin-left

{% codepen https://codepen.io/hamza-777/pen/MWQXVWL %}

In the example above if you see the code properly I intended to have a top and bottom margin of 1rem for both text fields but due to the .center class being after the .text class its properties take priority and the margin top and bottom become 0.

A possible solution is to use the individual properties:

{% codepen https://codepen.io/hamza-777/pen/abqKYwd %}

But if you find doing this inconvenient the there is another better solution at your disposal as you can see in the example below:

{% codepen https://codepen.io/hamza-777/pen/wvyXmqE %}

Here you have now seen two new properties or maybe you are already familiar with these:

* margin-inline:
  * Handles margin on the horizontal axis.
  * Is a shorthand for:
     * margin-inline-start
     * margin-inline-end
* margin-block 
  * Handles margin on the vertical axis
  * Is a shorthand for:
     * margin-block-start
     * margin-block-end

Also, padding is kind of similar shorthand property so keep in  mind to use individual properties when needed.

### Background:

Now, just like margin property background property is a shorthand too but it is a shorthand for a bunch of other properties which can sometimes lead to unintended results, one such situation could be when you are trying to add an image as a background but you already have another class that sets:

> background: #111

This can sometimes be problematic as it will set all other individual properties to initial value. Also I won't go deep into this topic as people prefer to do things their own way and some even prefer using frameworks instead of writing their own CSS.

Here's the link to the YouTube video if you want to be evn clear about this topic:

[Kevin Powell CSS Shorthands](https://www.youtube.com/watch?v=iGkK-5il6Mk)
Code Smell 138 - Packages Dependency
Tags: javascript, npm, node, security
Published: 2022-06-03 13:16:46

*There's an industry trend to avoid writing code as much as possible. But this is not for free*

> TL;DR: Write your code unless you need an existing complex solution

# Problems

- [Coupling](https://dev.to/mcsee/coupling-the-one-and-only-software-design-problem-2pd7)

- [Security problems](https://nakedsecurity.sophos.com/2022/05/25/poisoned-python-and-php-packages-purloin-passwords-for-aws-access/)

- Architectural complexity

- [Packages Corruption](https://www.bleepingcomputer.com/news/security/dev-corrupts-npm-libs-colors-and-faker-breaking-thousands-of-apps/)

# Solutions

1. Import and implement trivial solutions

2. Rely on external and mature dependencies

# Context

Recently, There's a trend to rely on a hard to trace dependencies.

This introduces coupling into our designs and architectural solutions.

# Sample Code

## Wrong

[Gist Url]: # (https://gist.github.com/mcsee/32a73793d00fc672138e1a98bbdc9aa8)
```javascript
$ npm install --save is-odd

// https://www.npmjs.com/package/is-odd
// This package has about 500k weekly downloads
// https://github.com/i-voted-for-trump/is-odd/blob/master/index.js

module.exports = function isOdd(value) {
  const n = Math.abs(value); 
  return (n % 2) === 1;
};
```

## Right

[Gist Url]: # (https://gist.github.com/mcsee/751b57a8178500e9143ea2081237ffaf)
```javascript
function isOdd(value) {
  const n = Math.abs(value); 
  return (n % 2) === 1;
};

// Just solve it inline
```

# Detection

[X] Automatic 

We can check our external dependencies and stick to the minimum.

We can also depend on a certain concrete version to avoid hijacking.

# Tags

- Security

# Conclusion

Lazy programmers push reuse to absurd limits.

We need a good balance between code duplication and crazy reuse.

As always, there are rules of thumb but no rigid rules.
 
# More Info

- [Poisoned Packages](https://nakedsecurity.sophos.com/2022/05/25/poisoned-python-and-php-packages-purloin-passwords-for-aws-access/)

- [Packages Corruption](https://www.bleepingcomputer.com/news/security/dev-corrupts-npm-libs-colors-and-faker-breaking-thousands-of-apps/)

- [Copyright Threats](https://qz.com/646467/how-one-programmer-broke-the-internet-by-deleting-a-tiny-piece-of-code/)

- [Malware in Packages](https://therecord.media/malware-found-in-npm-package-with-millions-of-weekly-downloads/)

# Credits

Photo by [olieman.eth](https://unsplash.com/@moneyphotos?) on [Unsplash](https://unsplash.com/s/photos/security-box)
  
Thanks to Ramiro Rela for this smell

* * *

> Complexity kills. It sucks the life out of developers, it makes products difficult to plan, build and test, it introduces security challenges, and it causes end-user and administrator frustration.

_Ray Ozzie_
 
{% post https://dev.to/mcsee/software-engineering-great-quotes-26ci %}

* * *

This article is part of the CodeSmell Series.

{% post https://dev.to/mcsee/how-to-find-the-stinky-parts-of-your-code-1dbc %}
Kadence Conversions - WordPress Popup Plugin
Tags: wordpress, kadencewp, popup, wordpressplugins
Published: 2022-06-03 15:42:59

---
title: Kadence Conversions - WordPress Popup Plugin
published: true
date: 2022-06-03 13:14:40 UTC
tags: WordPress,KadenceWP,popup,WordPressPlugins
canonical_url: https://bloggerpilot.com/kadence-conversions/
---

![Kadence Conversions - WordPress Pop-up Plugin](https://bloggerpilot.com/wp-content/uploads/2021/11/kadence-conversions.png)

Das WordPress-Plugin Kadence Conversions macht es simpel möglich, Pop-Ups für...

Der Original-Artikel erschien auf [Kadence Conversions - WordPress Popup Plugin](https://bloggerpilot.com/kadence-conversions/).