teleren/devto huggingface dataset:
Introduction | Building a Shopping Cart with Symfony
Tags: php, symfony, tutorial, beginners
Published: 2020-12-21 12:51:19

Welcome to my first tutorial to learn the popular PHP Symfony Framework by creating a simple Shopping Cart from scratch.

> A shopping cart on a website facilitates the purchase of a product or service.

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/ul04d5bvc6sq45ea9x94.png)

Why this tutorial?
-------------------
I've been developing with Symfony for more than 8 years and I think it's time for me to share my experience with you through this series of articles. I made this tutorial for you to learn Symfony by doing. I have always learned to use a framework or a library by creating personal or professional projects.

Also, writing this tutorial was an exercise for me. Indeed, knowing how to use Symfony is one thing, knowing how to explain how to use Symfony is another. 

What is it about?
-----------------

The tutorial describes the creation of a shopping cart, from scratch and step by step. We will manage the basic shopping cart features:
- Add products to the cart,
- Update the quantity of products in the cart,
- Remove products from the cart,
- Clear the cart,
- See the list of products in the cart,
- See the quantity of products in the cart,
- See the summary of the cart.

**The checkout and order process won't be developed** but let me know if you are interested, I will try to do it and add some additional steps to this tutorial. Also, **the design is not the goal** of this project, we will just make it functional.

We will try to respect the best practices and use the base concepts of Symfony to allow you to reuse code and create your projects independently.

What you will learn?
--------------------
- Create a project with **Symfony 5** (from scratch),
- Build a Shopping Cart using Symfony 5,
- Use the **most popular Symfony components**,
- Create static and dynamic forms with **Symfony Form**,
- Create pages with **Twig**,
- Store data in session using the **Session** service,
- Create and register **Services** in Symfony,
- Create and Persist entities in a database using **Doctrine**,
- Write custom DQL queries using the **Query Builder** of Doctrine,
- Validate entities with **Symfony Validator**,
- Load fake data with **Doctrine Fixtures**,
- Create a CLI command with **Symfony Console**,
- Write functional tests with **Symfony Browser Kit** and **PHPUnit**.

Who this tutorial is for?
-------------------------
- For PHP developers who want to discover Symfony 5 using a concrete and complex project,
- Developers who want to go beyond the documentation offered by Symfony and take action.

Where are the tutorial resources?
---------------------------------
I created a [repository](https://github.com/qferr/happy-shop) that contains all the code of the shopping cart. If you want, you can clone it somewhere on your local machine:

```
$ git clone https://github.com/qferr/happy-shop
```

Ready to code? Let's start to install and configure our working environment in the first step.
CSS text background
Tags: css, html, beginners, codepen
Published: 2020-12-21 12:50:59

Hello fellows developers,

As a CSS enthusiast I'm always trying to replicate designs I see using CSS.

Today I wanted to create a text background for a paragraph.
I used codepen as always(God Bless Codepen).

At first I added the necessary HTML I knew I wanted on the page:
```html
<section>
  <span class="text-background">2021</span>
  <p>
    “Do the hard jobs first. The easy jobs will take care of themselves.”
Dale Carnegie
  </p>
</section>
```

Now I want my section to be centered on the screen, a dark background and some nice visuals for the body and for that I've added some CSS:

```CSS
body {
  margin: 0;
  height: 100vh;
  width: 100%;
  background: #454545;
  
  display: grid;
  place-items: center;
  text-align: center;
}
```

For my particular design I want to have all the elements centered so I need to center everything inside the section also:

```CSS
section {
  position: relative;
  display: grid;
  place-items: center;
  width: 100%;
}
```

The relative positioning will help me center and arrange the elements inside without having to mess with z-index(do to the fact of html elements order).

Display grid and Place-items center will center the items inside the section.

And the last and most important thing to do is to add position absolute to our text elements and some styling to look nice:

```CSS
.text-background {
  position: absolute;
  font-size: 142px;
  color: #3d3d3d;
}

p {
  position: absolute;
  font-size: 20px;
  color: #eee;
}
```


The final result:
{% codepen https://codepen.io/FlorinCornea/pen/poErpYW %}


Thank you for reading this article and I'm curios if you have another method to achieve this result.
Invalidation AWS CDN Using Boto3
Tags: aws, devops, cloudfront, boto3
Published: 2020-12-21 12:43:48


- This post describe how to remove files from CloudFront edge caches before it expires using python boto3

- To invalidate files, specify either the path for individual files or a path that ends with the * wildcard, which might apply to one file or to many, as shown in the following examples:
 - `/images/image1.jpg`
 - `/images/image*`
 - `/images/*`
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/9p29dpj6f30o0k646a9d.png)
- Using python boto3 [invalidatecdn_demo.py](https://github.com/vumdao/invalidate-cdn/blob/master/invalidatecdn_demo.py)
```
import boto3
import time
import sys


""" Invalidate CDN at s3://static/demo/src """
DISTRIBUTION_ID = 'A1AA1AA11A11AA'

client = boto3.client('cloudfront')


def create_invalidation():
    res = client.create_invalidation(
        DistributionId=DISTRIBUTION_ID,
        InvalidationBatch={
            'Paths': {
                'Quantity': 1,
                'Items': [
                    '/demo/src/*'
                ]
            },
            'CallerReference': str(time.time()).replace(".", "")
        }
    )
    invalidation_id = res['Invalidation']['Id']
    return invalidation_id


def get_invalidation_status(inval_id):
    res = client.get_invalidation(
        DistributionId=DISTRIBUTION_ID,
        Id=inval_id
    )
    return res['Invalidation']['Status']


def run():
    the_id = create_invalidation()
    count = 0
    while True:
        status = get_invalidation_status(the_id)
        if status == 'Completed':
            print("Completed, id: {}".format(the_id))
            break
        elif count < 10:
            count += 1
            time.sleep(30)
        else:
            print("Timeout, please check CDN")
            sys.exit(1)


if __name__ == '__main__':
    run()

```

- Run
```
~()⚡ $ python invalidatecdn_demo.py 
Completed, id: I1CLODB5ZXEQUK
```

- Result
 - In progress
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/b0f6fgc459dkvc1741hh.png)

 - Complete
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/f62t39vkyjr1opqhnoxt.png)

- Ref: https://github.com/vumdao/invalidate-cdn/tree/master
Placeholder title
Tags: dohackathon
Published: 2020-12-21 12:32:28

## What I built

### Category Submission: 


### App Link


### Screenshots


### Description
 

### Link to Source Code

### Permissive License


## Background
(What made you decide to build this particular app? What inspired you?)

### How I built it 
(How did you utilize DigitalOcean’s App Platform? Did you learn something new along the way? Pick up a new skill?)


### Additional Resources/Info
Find 5 differences
Tags: php, pullrequest, github, justkidding
Published: 2020-12-21 12:26:40

---
title: Find 5 differences
published: true
description: I removed the duplicate word "long long" in php-src (Just kidding :d)
tags: PHP, PullRequest, GitHub, JustKidding
cover_image: https://dev-to-uploads.s3.amazonaws.com/i/jyu0l41sjgz4swzhara0.png
---

https://github.com/php/php-src/pull/6527

VS

https://github.com/torvalds/linux/pull/335
How Much Does it Cost to Develop an E-commerce Mobile App?
Tags: discuss, mobile, android, ios
Published: 2020-12-21 12:26:40

The thriving eCommerce sector brings new opportunities for startups and enthusiastic retailers alike. But then, intensifying competition and ever-changing requirements of customers can spoil the party. There, a feature-rich eCommerce mobile app lends a helping hand. Retailers want to harness the power of mobile apps to meet these challenges in a cost-effective and efficient way. However, it is necessary for them to know the cost of eCommerce mobile app development.

These days people prefer to give orders on the move or with the comfort of their home. The dependence on the mobile app is, therefore, increasing day by day. Shopping on the go with extensive search features and secure online payment are the most prevalent trends. As an eCommerce business owner, you can provide these facilities to your customers through an eCommerce app for iOS or Android.

Let’s go through the obvious business benefits of a feature-rich eCommerce mobile app-

Effective Marketing- An eCommerce mobile app acts as a cost-effective and highly efficient marketing tool. It not only meets your customers’ shopping requirements but also enables you to come up with app-based discounts and real-time notifications for promotional offers. In a way, an eCommerce app for Android and iOS can boost customer loyalty.

Data Collection- An eCommerce app needs the user’s email ID and social media account information along with their contact numbers. As a result, eCommerce companies can get valuable data from their existing and prospective customers.

Improved Interactions- A customized eCommerce mobile app facilitates robust and real-time interactions between your company and clients. Apart from searching or shopping anytime, the app enables your customers to raise queries or give suggestions on a 24/7 basis.

Spread Brand Awareness- The eCommerce app development company makes an app in line with your business model, thereby assisting you to increase your brand visibility. E-commerce apps with personalized experience can be a great tool for effective communication with customers.

Though eCommerce apps offer many benefits to retailers and startups, still many business persons have no idea about the cost of eCommerce app development. Let’s dig deep into this matter in this blog.

https://www.suriainternational.com/cost-to-develop-an-e-commerce-mobile-app/
Why Do You Write Tests?
Tags: programming
Published: 2020-12-21 12:24:59

Testing has pros and cons (what doesn't?) and it only makes sense to do things when their benefits outweigh the costs. Usually at least. I hope I am speaking for most people here.

Anyway why do I write tests? I write it because it makes a nice todolist. Yeah it gives you that confidence that your program works correctly (does it though?) and refactoring becomes a cinch (I totally remember what ThisClassIMade20DaysAgo does) but I do it for the todolist because I'm forgetful.

Usually before I'm writing the code I imagine writing the code and a lot of times while imagining all of this I come across these edge cases. I obviously don't want to forget them so I write the tests for them. Or at least make empty tests with a descriptive enough name and comments.

So why do you write tests?
How to grow as a Programmer
Tags: productivity, tips, beginners
Published: 2020-12-21 12:23:36

How to Keep Growing as a Programmer: I know, I know, you follow eat(), sleep(), code(), repeat() routine.

Follow these tips:

**1. Don’t Write Only Codes**
I’m not stopping you to write code but saying that learn the fundamentals of computer science and software engineering. For instance, learn about Testing and debugging. Read up on software design patterns. Learn about deployment and production. Implement or see some data structures and searching/sorting algorithms.

**Keep learning new things**
Make a list of topics that you are weak on or know nothing about, and make an effort to learn more about them.
Find some articles in Magazine, read blogs, listen to podcast etc.

**Acquire soft skills**
Programmers very well know how to write code but they don’t know how to communicate with peoples. You can consider this as a weakness of the programmer. [Read more...](https://www.codesnail.com/how-to-keep-growing-as-a-programmer/)
Why is CSS important?
Tags: css, learning
Published: 2020-12-21 12:22:29

BOLD:CSS is important because it allows web designers, developer, bloggers, and so forth to make our websites unique and attractive. CSS gives us the opportunity to play with a page layout, adjust colors and fonts, add effects to images, etc.

While in the past it was possible to add style via HTML or more simpler CSS, CSS3 has really expanded and allows for more creativity.

Ultimately, it makes our lives easier. CSS allows us to separate the presentation from the structure (HTML) into different files.
CKA & CKAD Completed
Tags: opensource, kubernetes, orchestration, devops
Published: 2020-12-21 12:19:19

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/q2kmuwffzptwtvcheman.png)

Very happy to end this year 2020 with a positive, meaningful, and knowledgeful ending while completing the two eminent certifications in the DevOps field - **Certified Kubernetes Administrator** (**CKA**) and **Certified Kubernetes Application Developer** (**CKAD**) from **Cloud Native Computing Foundation** in association with **The Linux Foundation**.

Always hope for the best and keep trying to achieve whatever we want in difficult times as well. Even if we fail there will be some learning which can be rectified in the next journey.

Another thing like to share with those who are going for the exam of **K8s**, just don't sit for the exam only to get a good position in a career or for a change in a better job role, this will definitely not help you if you don't love this technology, clear out the concept and try hands-on with **K8s** even if that topic is not included in the exam. The main point is that if you don't love the technology you can't work with it in long run and after some time get bored which will affect your career as well.

**KubeAcademy** is also a very good platform developed by VMware to learn **Kubernetes**. All the courses are free and taught by experienced persons. You check it out at - https://kube.academy/.

I like to wish those who are preparing for the exam or learning **K8s** all the best.

BIG THUMPS UP AND LOTS OF LOVE TO Google FOR SHARING SUCH A WONDERFUL TECHNOLOGY WITH THE OPENSOURCE COMMUNITY AND EASILY ACCESSIBLE TO EVERYONE. 👍❤️❤️👍

Keep **learning** and keep **sharing** knowledge. Power of **OPEN SOURCE**.

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/q2kmuwffzptwtvcheman.png)
The Cool Developer
Published: 2020-12-21 12:11:12

Want to look cool in public place or in front of cousins??

Prerequisite:


- Cool Dev T-shirt 

- Laptop

- Internet



![image.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1608552025525/GKqaaxC_p.png)

Open this website and randomly press buttons in keyboard: 



- 
https://hackertyper.net/


**Connect**

- Twitter: https://twitter.com/NewGenDeveloper

**Support**

- https://www.buymeacoffee.com/newgendeveloper
Weekly Challenge 092
Tags: perl, weeklychallenge, perlweeklychallenge
Published: 2020-12-21 12:08:09


[Challenge 092](https://perlweeklychallenge.org/blog/perl-weekly-challenge-092/)

# TASK #1 › Isomorphic Strings

## Task

You are given two strings `$A` and `$B`.

Write a script to check if the given strings are [Isomorphic](https://www.educative.io/edpresso/how-to-check-if-two-strings-are-isomorphic). Print `1` if they are otherwise `0`.

## My solution

This seems pretty straight forward, so not much explanation required. :)

Strings that are different length can't be isomorphic, so I return 0 if that happens. I then compare the first string to the second string, and then compare in the other direction. This is to prevent something like `abcb` matching `xyxy`.

For the function, I walk through the string using a for loop and substr. If we have seen the first character before, I return 0 if the map is something different. If we haven't seen the string, then we store it for later use.

## Examples

```
» ./ch-1.pl abc xyz
1

» ./ch-1.pl abb xyy
1

» ./ch-1.pl sum add
0
```

# TASK #2 › Insert Interval

## Task

You are given a set of sorted non-overlapping intervals and a new interval.

Write a script to merge the new interval to the given set of intervals.

## My solution

This is one of those tasks where I'm interested in how other Team PWC members solved it as much as my own attempt. Like task one last week I've written a solution that works, but I'm not sure it's the best solution.

This is the way I solved this task. The term 'new interval' refers to the last two numbers.

* Grab all the numbers in the input. Remove the last two (the new interval) and put the rest of the numbers in a hash.
* Loop through a sorted list of the hash (the start number for each interval).
* If the new interval is after the end ($new_start > $end), then move to the next interval.
* If the new interval is before the start ($new_end < $start), then add the new interval to the hash and return. 
* If we got here, it means the interval intersects the new interval. If the start of the new interval is less the start of the interval, we move the start. We take the same action with the end, and remove any intervals we subsumed in the process.
* If we have gone through the list of intervals, then it means the new interval is after the last interval. We add the interval to the hash, and return
* Finally I print out the result.

## Examples

```
» ./ch-2.pl "(1,4), (8,10) (2,6)"
(1,6), (8,10)

» ./ch-2.pl "(1,2), (3,7), (8,10) (5,8)"
(1,2), (3,10)

» ./ch-2.pl "(1,5), (7,9) (10,11)"
(1,5), (7,9), (10,11)
```
Web Audio API weirdness on iOS
Tags: webaudio, thesession, ios, bug
Published: 2021-01-11 11:14:42

---
title: Web Audio API weirdness on iOS
published: true
date: 2020-12-21 11:49:50 UTC
tags: webaudio,thesession,ios,bug
canonical_url: https://adactio.com/journal/17709
---

I told you about how [I’m using the Web Audio API on The Session](https://adactio.com/journal/17698) to generate synthesised audio of each tune setting. I also said:

> Except for some weirdness on iOS that I had to fix.

Here’s that weirdness…

Let me start by saying that this isn’t anything to do with requiring a user interaction (the Web Audio API insists on some kind of user interaction to prevent developers from having auto-playing sound on websites). All of my code related to the Web Audio API is inside a `click` event handler. This is a different kind of weirdness.

First of all, I noticed that if you pressed play on the audio player when your iOS device is on mute, then you don’t hear any audio. Seems logical, right? Except if using the same device, still set to mute, you press play on a `video` or `audio` _element_, the sound plays just fine. You can confirm this by going to [Huffduffer](https://huffduffer.com) and pressing play on any of the `audio` elements there, even when your iOS device is set on mute.

So it seems that iOS has different criteria for the Web Audio API than it does for `audio` or `video`. Except it isn’t quite that straightforward.

On some pages of [The Session](https://thesession.org), as well as the audio player for tunes (using the Web Audio API) there are also embedded YouTube videos (using the `video` element). Press play on the audio player; no sound. Press play on the YouTube video; you get sound. Now go back to the audio player and suddenly you _do_ get sound!

It’s almost like playing a `video` or `audio` element “kicks” the browser into realising it should be playing the sound from the Web Audio API too.

This was happening on iOS devices set to mute, but I was also getting reports of it happening on devices with the sound on. But it’s that annoyingly intermittent kind of bug that’s really hard to reproduce consistently. Sometimes the sound doesn’t play. Sometimes it does.

Following my theory that the browser needs a “kick” to get into the right frame of mind for the Web Audio API, I resorted to a messy little hack.

In the event handler for the audio player, I generate the “kick” by playing a second of silence using the JavaScript equivalent of the `audio` element:

```
var audio = new Audio('1-second-of-silence.mp3');
audio.play();

```

I’m not proud of that. It’s so hacky that I’ve even wrapped the code in some user-agent sniffing on the server, and I _never_ do user-agent sniffing!

Still, if you ever find yourself getting weird but inconsistent behaviour on iOS using the Web Audio API, this nasty little hack could help.
MSG to PDF Converter 
Tags: msgtopdf, converter, software, convert
Published: 2020-12-21 11:20:29

<p>Birdie <a href="https://www.birdiesoftware.com/msg-to-pdf/"><b>MSG to PDF Converter</b></a> is a perfect and most reliable application to easily convert MSG file to PDF with attachments.It allows you to move multiple MSG files to PDF format at a time without any data loss. The tool also supports all Outlook and Windows OS platforms.
HTTP Status codes
Tags: web, frontenddev
Published: 2020-12-21 11:15:20

---
title: HTTP Status codes
published: true
description: 
tags: #web #frontenddev
cover_image: https://images.unsplash.com/photo-1503252947848-7338d3f92f31?ixid=MXwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHw%3D&ixlib=rb-1.2.1&auto=format&fit=crop&w=1489&q=80
---

HTTP Stands for Hyper Text Transfer Protocol and it’s a way of communicating between web browsers and web servers.

One of the ways that http is used to communicate between web browsers & web servers is http status code, It provides a number that represent the current state of the operation in the webpage.

Here are some examples:

Informational responses (100–199)
Successful responses (200–299)
Redirects (300–399)
Client errors (400–499)
Server errors (500–599)


![http status code example](https://dev-to-uploads.s3.amazonaws.com/i/oprwyrcgq7rmc4i15s22.jpg)


If you want to read more, These links will do the work:

[http](https://developer.mozilla.org/en-US/docs/Web/HTTP
)
[http-status-code](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status)

Cheers.
Why are there duplicate subscription emails sent to me?
Tags: help, meta
Published: 2020-12-21 11:14:16

---
title: Why are there duplicate subscription emails sent to me?
published: true
description: 
tags: help, meta
---

![](https://raw.githubusercontent.com/mrdulin/pic-bucket-01/master/20201221191203.png)

As you can see, the subjects of the subscription email are the same, and the contents are almost the same. Can you optimize it?
Start creating your own code art
Tags: react, design
Published: 2020-12-21 10:58:35

This will be a simple post for all the artists/ creators out there. Have you always wondered of creating graphic art too, well Adam did too?

* So Adam started by creating a react app

```
$ npx create-react-app p5reactArtProject
```
* then Adam install `react-p5-wrapper`, coz he knows React.

* Then Adam deleted all the precode from `App.js`.

* Adam created a component called `Art` and then inside it a file named `Art.js`


Let's see the example.

```{js}
import React from 'react';
import P5Wrapper from 'react-p5-wrapper';

const SecondArt = () => {
	let canvas;
	var height = window.innerHeight;
	var width = window.innerWidth;

	const sketch = (p) => {
		console.log('p', p);

		const drawLines = (x, w, stroke, color) => {
			for (var i = 10; i < 1000; i += 10) {
				p.stroke(color);
				p.strokeWeight(stroke);
				p.strokeCap(p.SQUARE);
				p.line(x + w + 50 + i, w + 50, x + w + 50 + i, w + 400);
			}
		};

		p.setup = () => {
			canvas = p.createCanvas(width, height);
		};

		p.draw = () => {
			p.background('#000');
			for (let w = 0; w < 490; w += 70) {
				drawLines(100, w, w / 70, 'cyan');
				drawLines(195, w, 6 - w / 70, 'red');
			}
		};
	};

	return <P5Wrapper sketch={sketch}></P5Wrapper>;
};

export default SecondArt;
```