teleren/devto huggingface dataset:
How to record webcam with python to a file
Published: 2021-12-03 22:20:18

This is a good example how as a programmer you have to keep searching before you get the right solution. 

I started with this script from [this site](https://www.codespeedy.com/save-webcam-video-in-python-using-opencv/)

```
import cv2
#Capture video from webcam
vid_capture = cv2.VideoCapture(0)
vid_cod = cv2.VideoWriter_fourcc(*'XVID')
output = cv2.VideoWriter("videos/cam_video.mp4", vid_cod, 20.0, (640,480))
while(True):
     # Capture each frame of webcam video
     ret,frame = vid_capture.read()
     cv2.imshow("My cam video", frame)
     output.write(frame)
     # Close and break the loop after pressing "x" key
     if cv2.waitKey(1) &0XFF == ord('x'):
         break
# close the already opened camera
vid_capture.release()
# close the already opened file
output.release()
# close the window and de-allocate any associated memory usage
cv2.destroyAllWindows()
```

There are two errors in this script. First I got this response:

```
at 'mp4 / MP4 (MPEG-4 Part 14)'
OpenCV: FFMPEG: fallback to use tag 0x7634706d/'mp4v'
```

So I google a bit, and you have to create the folder videos first to make it work. 

The second bug was that the size of the webcam input should match the output size, in this script (640,480). So I executed this script to get the resolution:

```
import cv2

#Capture video from webcam
vid_capture = cv2.VideoCapture(0)
width  = vid_capture.get(3)  # float `width`
height = vid_capture.get(4)  # float `height`
print(width)
print(height)
```

It gave me 1280 x 720, then I updated the original script to these sizes and now it worked! Here is the complete script:

```
import cv2

#Capture video from webcam
vid_capture = cv2.VideoCapture(0)
vid_cod = cv2.VideoWriter_fourcc(*'XVID')
output = cv2.VideoWriter("videos/cam_video.mp4", vid_cod, 20.0, (1280,720))

while(True):
     # Capture each frame of webcam video
     ret,frame = vid_capture.read()
     cv2.imshow("My cam video", frame)
     output.write(frame)
     # Close and break the loop after pressing "x" key
     if cv2.waitKey(1) &0XFF == ord('x'):
         break

# close the already opened camera
vid_capture.release()
# close the already opened file
output.release()
# close the window and de-allocate any associated memory usage
cv2.destroyAllWindows()
```

And now it worked! How is your experience with using scripts online and finding solutions for bugs in it?
Solving day 3 of Advent of Code 2021 in JavaScript
Tags: challenge, adventofcode, javascript, video
Published: 2021-12-03 21:56:54

---
title: Solving day 3 of Advent of Code 2021 in JavaScript
published: true
description: JavaScript walkthrough of Advent of Code 2021 (day 3)
tags: challenge, AdventOfCode, javascript, video
series: Advent of Code 2021 in Javascript
---

{% youtube z7hb5zXQQ3w %}
Form Validation with CSS
Tags: beginners, html, css, webdev
Published: 2021-12-03 21:51:27

In this post, I will show you how to validation the required form fields with CSS.

**If you want to see full version of this project or all HTML-CSS projects look this [Repository](https://github.com/enesskilic/html-css-projects)**

<hr />

> Create HTML

```html
  <form>

    <!--==== Add required attribute to input tag  ====-->
    <input type="password" required />
    
    <button type="submit"> Login </button>

  </form>
```

> CSS

```css
form:invalid button {
  pointer-events: none;
}

form:valid button {
  pointer-events: initial;
}
```

> My output with some styles

{% codepen https://codepen.io/eneskilic/pen/rNGOMze %}
Need an idea?
Tags: beginners, learning, productivity
Published: 2021-12-03 21:39:31

When learning how to code, one of the biggest challenges can be figuring out what projects to work on to improve your skills. I was faced with this problem when I first started learning and I eventually thought to myself "Software Engineering/Coding is about solving problems, I should create something to solve this problem I'm having". I then made a small program in Python that takes a word in the english language and combines it with an action word, such as "creator", "game", or "-inator". It's a very simple program but it has helped me start a few small projects in my early days to hone my skills. 

The project can be found [here](https://github.com/bengouma/ideas).
Apama Advent Calendar - 03 Dec 2021 - Apama for domain experts
Tags: iot, cumulocity, apama, streaminganalytics
Published: 2021-12-08 12:28:43

---
title: Apama Advent Calendar - 03 Dec 2021 - Apama for domain experts
published: true
date: 2021-12-03 21:32:30 UTC
tags: iot, cumulocity, apama, streaminganalytics
canonical_url: https://tech.forums.softwareag.com/t/apama-advent-calendar-03-dec-2021-apama-for-domain-experts/253719
---

_This is Day #3_ _of a short series of brief tips, tricks, hints, and reminders of information relating to the Apama Streaming Analytics platform, both from Software AG as well as from the community._ 

Visit the original post in the [Software AG Tech Community](https://tech.forums.softwareag.com/t/apama-advent-calendar-03-dec-2021-apama-for-domain-experts/253719) and learn how Cumulocity IoT Analytics Builder allows the domain expert to focus on solving their business problem, rather than the underlying plumbing, and improve their time to value.

_Note that some posts may be published a day or two early or late (e.g. Mon-Fri) so you may find you have bonus days with more than one post!_
Biggest Change o My life
Tags: career, programming, beginners, webdev
Published: 2021-12-03 21:03:50

Hello folks, I am Basically a Mechanical Engineer by Education but I just loved coding. I was always passionate about the web and BTS of Web like how these Websites looks So Coool! 
Hence Decided to pursue my Career in web development. So i did a basic research from where should I start?
And I comeup with the conclusion of basic languages like html and css.
So I started with the Basic Html and CSS which almost Done now. Will start JavaScrip from this week. 
Please drop down your precious Suggestions below and comment your thoughts.
Thankyou.
⚠️ [PHP] N'écrivez pas ce type de code en production ⚠️
Tags: php
Published: 2021-12-03 20:58:43

Vous connaissez surement le callback hell en JS ?
Mais connaissez-vous le **`array_` hell** en PHP ?

Voici ma solution de la partie 1 du jour 3 de l'Advent of Code 😄

![Advent of code Jour 3](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/sfm1ur8dfspmcqhqf3nn.png)
 

Mais cette complexité m'a fait réviser certaines fonctions 👇!


## Le `array_` hell

Tout d'abord, ce que j'appelle 🔥 `array_` hell 🔥 :

Si on cumule des appels aux différentes méthodes `array_`, le sens de lecture se retrouve inversé par rapport au traitement réalisé.

➕ d'info dans [mon article "Revue : Refactoring to collections"](https://www.jimmyklein.fr/refactoring-to-collections/)

---


## On en profite pour réviser un peu

1/ `array_count_values` : retourne un tableau contenant les valeurs du tableau comme clés et leur fréquence comme valeurs.

![array_count_values](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/q9h8ivkw19i7ox396byb.png)

---

2/ Savez-vous comment transformer un tableau à deux dimensions en transposant les colonnes en lignes et les lignes en colonnes ❓

Avec `array_map` en lui passant comme callback la valeur `null` et en utilisant comme deuxième argument le spread operator sur le tableau 🤩

![array_map](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/28et6ubj4zsn6y9bzvld.png)

---

3/ Un petit rappel sur les fonctions fléchées disponible depuis PHP 7.4 ❤️

Cela permet de définir de manière plus concises les fonctions anonymes.

![arrow functions](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vl4lxlpdzapl3j5g36y1.png)

---

4/ Et pour finir, la méthode `strtr` qui permet de remplacer des caractères dans une chaîne 🎆

![strtr](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/h61uwgvz4rb5hk3wule2.png)

---

## Merci d'avoir lu, et restons en contact !

Si vous avez aimé cet article, partagez-le autour de vous 🙏

Vous pouvez aussi me retrouver sur [Twitter](https://www.twitter.com/frjimmyklein)

Si vous souhaitez recevoir des tips de ce genre directement dans votre boîte mail, [inscrivez-vous à ma dev letter](http://bit.ly/klnjmmdevletter).
Hackpack.io: The most active community of engineers preparing for technical interviews
Tags: interview, career, launch
Published: 2021-12-03 20:54:42

https://hackpack.io/

## Why create Hackpack?

Studying for Google and FB interviews was an incredibly isolating and directionless experience for me. It took me 2 years to break into FB, and those two years were miserable.I was lonely and I hated studying these topics. I never knew if I was studying the right content and I kept getting burned out, making the process take even longer.

This is why I build [Hackpack.io](https://hackpack.io/), to make the experience of studying for programming interviews not suck and to help people conquer the burnout that creeps in every few months. We've found that being a part of a hyper active community makes the ride smoother and gets members to be more consistent with their studying

Apply today!
DPS909 - Release 0.4 Post 1
Published: 2021-12-03 20:23:45

I am approaching this weeks blog post slightly late, as I had a few issues. 

For our course in open source development, we were tasked with finding a repository to work on, where we could either add a new functionality, fix a family of bugs, or find a bug that would take many reviews and plenty of time to figure out and get merged.

After searching through many different open source repositories, I was unable to find anything that peaked my interest. I was struggling and was slowly loosing hope. However, one thing that kept on occurring was my ongoing PR fixes for my release 0.3 external project [Meshery](https://meshery.io/). My [ongoing PR](https://github.com/meshery/meshery.io/pull/617) was full of reviews, and I was constantly making small changes based off those comments. That is when it sparked to me that this pull request was essentially what our professor was looking for in release 0.4, so I decided to do two things.

1) Look through issues in the same repository, and see if there was any other kind of work that I can pick up, things such as features or bugs.
2) Reach out to my professor, and see if it is possible to extend my PR work from release 0.3 into release 0.4, as the content work for that PR increased, due to more requested changes.

So for release 0.4, I am going to be continuing my work on my existing [PR](https://github.com/meshery/meshery.io/pull/617), and also begin to work on [issue-605](https://github.com/meshery/meshery.io/issues/605), and that would make up my scope of the release 0.4 project.

My goals:
1) Finish off the PR for the Legend, and get it merged as soon as possible.
2) Begin slowly chipping away at the newsletter subscription bug, and begin the process of getting PR feedback, so that way I have enough time to hopefully merge my changed before the due date of release 0.4
Rethinking Teamwork with Range
Tags: techtalks, podcast, management, devops
Published: 2021-12-03 20:04:53


{% spotify spotify:episode:6hNM8sVOjSuew4iCn3AAQG %}

"*Where* is the future of work" is almost as important a question as, "*What* is the future of work?"

That's why the minds behind [Range](https://www.range.co/) are on a mission to keep teams connected, focused and productive no matter where they're working.

Dan Pupius, CEO and co-founder of Range, joins us this week to discuss the need for better, more collaborative tools as work becomes increasingly team and project based. Dan believes software development was the vanguard to the 21st century work model: when a distinction between 'normal' work and hybrid work will no longer exist because all work will be hybrid work.

## Episode Highlights Include:
* Why current management models are designed around factories
* What is [hybrid](https://linearb.io/blog/asynchronous-development/) work and is it the future?
* Hybrid work best practices
* How a sense of belonging helps teams move faster
* The reasons work has become increasingly team-based

## Join the Dev Interrupted Community
With over 2000 members, the Dev Interrupted Discord Community is the best place for Engineering Leaders to engage in daily conversation. No sales people allowed. [Join the community >>](https://discord.com/invite/devinterrupted)

![https://discord.com/invite/devinterrupted](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fly50ko28731rxpffgyw.png)
Don't force push to git!
Tags: webdev, github
Published: 2021-12-03 19:56:16

This was not new to me anymore, but still...

Recently, I had to do some fixes in a code base that I used to edit without any collaborators, so I got a little sloppy about proper collaboration workflows.

I thought let's reuse yesterday's branch name (bad idea!)

Same branch that had been deleted on GitHub after successful merge. I created another branch of the same name for my fixes, and after doing some more coding than I had expected, I did a local rebase and proceeded to push to the remote repository.

## What to do when branches have diverged?

`git push -f` ? (no! Don't!! Bad idea!!!)

Because now a coworker was working on the same code, and they actually had the same idea to use the same branch name, and they had already pushed their code to GitHub.

After force-pushing my code changes, I wanted to review his pull request. Only to find nothing but my own code inside the pull request.

If I had used

`git push --force-with-lease`

my push would have been rejected, and I would have seen the information about another divergent change right on my command line (and probably in my IDE as well, if it allows force pushing at all).

We were lucky, as git as decentralized system, that my coworker still had the code and could force-push over mine.

Unnecessary trouble: I should have known better! I learned about `--force-with-lease` years ago. See: [git-scm.com/docs/git-push](https://git-scm.com/docs/git-push#Documentation/git-push.txt---force-with-leaseltrefnamegtltexpectgt) I just didn't care at that moment.

## Lesson learned

Lesson learned: if you have to force push, do it with lease!

While it does not prevent you messing up your own work, at least you won't destroy other people's code mistakenly.
¿Que es React JS? ⚛
Tags: react, javascript, programming, webdev
Published: 2021-12-03 19:42:25

React es una biblioteca de JavaScript para construir interfaces de usuario interactivas. Fue creado por el ingeniero de software de Facebook Jordan Walke y se lanzó en mayo de 2013.


### Principales caracteristicas:

📌 Declarativo: Facilita el razonamiento sobre su aplicación y tiene como objetivo ser eficiente y flexible. Diseña vistas simples para cada estado en su aplicación, y React actualizará y renderizará de manera eficiente el componente correcto cuando cambien sus datos. La vista declarativa hace que su código sea más predecible y más fácil de depurar.
  
📌 Basado en componentes: React nos permite crear componentes de UI reutilizables. Podemos decir que cada aplicación que desarrolles en React estará formada por piezas llamadas "componentes". Los componentes facilitan mucho la tarea de crear interfaces de usuario. Puede ver una interfaz de usuario dividida en varias piezas individuales llamadas componentes y trabajar en ellas de forma independiente y fusionarlas todas en un componente principal que será su interfaz de usuario final.

📌 Virtual DOM: Se trata de una copia o representación en memoria del DOM(Document Object Model). El Virtual DOM, a diferencia del DOM real, pesa muy poco y utiliza escasos recursos (procesador, memoria RAM, etc) para ser creado. Así que, en caso de que un componente cambiase su estado, React compararía los cambios realizados en el Virtual DOM, vería qué elemento o elementos han cambiado, y actualizaría solo esas partes en el DOM real. De este modo se evita renderizar toda la página cada vez que haya cambios. Esto proporciona una mayor rapidez y un gran rendimiento.

---

### Ventajas:
🔹 Alto rendimiento, React es conocido por su alta eficiencia y flexibilidad. Se puede integrar fácilmente con diferentes tecnologías. Se puede usar tanto para el lado del cliente como para el lado del servidor.
🔹 Existe una gran cantidad de documentación y recursos disponibles en la web que hace que la curva de aprendizaje sea muy fluida.
🔹 La arquitectura basada en componentes de React ayuda a aumentar la reutilización del código y facilita bastante el mantenimiento de proyectos a gran escala.

### Desventajas: 
🔸 React requiere una amplia gama de herramientas para funcionar correctamente y ser compatible con otras tecnologías.
  

### Algunas de las empresas que lo usan son:
Muchas empresas grandes utilizan react para el desarrollo de sus aplicaciones, tales como: 
- Netflix 
- Facebook 
- Instagram 
- WhatsApp 
- Airbnb 
- PayPal 
- Microsoft

Para mas información consulta: https://es.reactjs.org/ 

---

📌 Mis Redes: 🔵[Facebook](https://www.facebook.com/gdcode7) | 💼[LinkedIn](https://www.linkedin.com/in/gastondanielsen/) | 💻[Github](https://github.com/gdcodev)
Snyk Introduces Python Poetry support for securing your Python projects
Tags: product, devtools, python, announcements
Published: 2021-12-03 19:40:22

---
title: Snyk Introduces Python Poetry support for securing your Python projects
published: true
description: 
tags: product, devtools, python, announcements
cover_image: https://community.snyk.io/images/ZQpHac2-nnFESyuyS6MNjPS2_moYyj2CkAU2MwDQV2I/s:1000:420/aHR0cHM6Ly9jb21t/dW5pdHkuc255ay5p/by9yZW1vdGVpbWFn/ZXMvaS9teWwyd2h4/eXl0OGJwNjViZDRt/YS5wbmc
---

We are very happy to announce that the Snyk CLI now supports testing [Python Poetry](https://snyk.co/python-poetry-support-snyk-cli) projects 🎉

Poetry is a great solution for all your Python dependency management, packaging and publishing needs, and we've been keen to support it for a while.

CLI support for Poetry is available from version 1.423, see this blog post too about [Snyk for Potery by a Python developer](https://snyk.io/blog/python-poetry-package-manager/) for more details.

Keep track of the [Snyk Python documentation](https://docs.snyk.io/products/snyk-open-source/language-and-package-manager-support/snyk-for-python) for Python Poetry and more updates to come.

And watch this space for more [#announcements](https://community.snyk.io/t/announcements) as we'll be extending our support in the near future… 🤗
Project 1 blog
Published: 2021-12-03 19:35:21

I had many ideas while at the drawing table trying to figure out what kind of application I wanted to build. It was overwhelming at first but I took a deep breath and started organizing my thoughts and ideas and found one that I stuck with. My girlfriend, which is a bartender had just recently started her own business and was looking for someone to build a website for her. I started researching cocktail/drink API'S and found what I was looking for. I clicked around and gathered the information that was on the API and got to work organizing what functions I wanted this site to do.

Once I found the API I wanted to use, I needed to have access to all the data on the site to start building my API. After linking my Javascript file through my index.html, I fetched all of the drinks from the public API, https://www.thecocktaildb.com/api/json/v1/1/search.php?f=a, and rendered the drinks to the page using DOM manipulation.

There was a lot of information in the array that would have cluttered my API, so I decided to create a function that would only pull certain information; the name of the drink, a picture, the alcohol used and the instructions. Once I refreshed the page, it started looking promising.

Now that I had the drinks and the information I needed on the page. I wanted to organize it even more, I wanted the user to have the option of not only seeing all the drinks on the page, they can also have the option to go strait to the alcohol of their liking. You like whiskey? great, theres going to be a button for that. Gin? guess what? theres a button for that. If theres any alcohol that you want to see recipes for, there will be a button for it.

To make a button I went to the html file and made a div class that would hold the buttons for each drink and then went back created a const that wound grab the button element, added an event listener and tied it to the filter drinks function that sorted through all the drinks and displayed all the drinks by the ingredient. now all there was left to do was to style it and add a like button.
Last Chance to Join the 2021 GitHub Actions Hackathon on DEV!
Tags: meta, actionshackathon21
Published: 2021-12-03 18:43:00

---
title: Last Chance to Join the 2021 GitHub Actions Hackathon on DEV!
published: true
description: Don't miss your shot at using GitHub Actions to build an amazing workflow — while getting prizes for it! 
tags: meta, actionshackathon21
cover_image: https://dev-to-uploads.s3.amazonaws.com/uploads/articles/y8214wmw56743rin6lo9.png
---

#### **This is your final reminder that the 2021 GitHub Actions Hackathon on DEV closes on Wednesday, December 8th, 2021 @ 11:59 PM PT** _(8 AM UTC the following day)_

--- 

The 2021 GitHub Actions Hackathon is nearing an end and we've already seen so many incredible submissions from the community (seriously — go check them out [here](https://dev.to/t/actionshackathon21)). With that said, we know that early submissions aren't everyone's style and some of you are more of the last minute types 😉 So consider this your official nudge to get that GitHub Actions Hackathon project in while you can! 

> <mark>As a reminder, all participants with a valid submission will receive a limited edition profile badge and a sticker pack. 10 runners up will win all of that plus $250 USD cash (or the equivalent value in your local currency) and a $150 USD gift code to the [DEV shop](https://shop.dev.to/). Five lucky grand prize winners will receive a sticker pack, a limited-edition profile badge, $1,500 USD in cash, and $300 USD at the DEV shop!<mark> 

**[>> Click here to find out how to participate](https://dev.to/devteam/join-us-for-the-2021-github-actions-hackathon-on-dev-4hn4)**

Want to share an update on your project or connect with other participants? Check out the [community update thread](https://dev.to/devteam/share-your-github-actions-hackathon-2021-updates-57k). 

Need help with your submission? Have a question about the hackathon rules or GitHub Actions? Head over to the [help thread](https://dev.to/devteam/github-actions-hackathon-2021-help-thread-1lk0) to connect with the DEV and GitHub teams directly. 

Good luck, all our participants! We can't wait to announce the winners later this month 🎉 

---
_Click [here](https://dev.to/devteam/join-us-for-the-2021-github-actions-hackathon-on-dev-4hn4) to read the hackathon rules and get started._ ✨
Advent.js🎅🏼| #3: El Grinch quiere fastidiar la navidad
Tags: javascript, adventjs, spanish, webdev
Published: 2021-12-03 18:39:36

## [El Grinch quiere fastidiar la navidad](https://adventjs.dev/challenges/03)

El Grinch está abriendo las cartas que iban a Santa Claus y las está dejando hechas un lío. 😱

Las cartas son una cadena de texto que incluyen regalos y paréntesis `()`.

Para saber si una carta es válida ✅, debes comprobar que los paréntesis cierran correctamente y que, además, no vayan vacíos.

¡Pero ojo! Porque el Grinch ha dejado llaves `{` y corchetes `[` dentro de los paréntesis que hacen que no sean válidas. Por suerte sólo los ha dejado en medio de los paréntesis...

Ejemplos:

```js
"bici coche (balón) bici coche peluche" // -> ✅
"(muñeca) consola bici" // ✅

"bici coche (balón bici coche" // -> ❌
"peluche (bici [coche) bici coche balón" // -> ❌
"(peluche {) bici" // -> ❌
"() bici" // ❌
```

Crea una función que pasándole el texto de la carta, devuelva `true` si es válida y `false` si no lo es. ¡Y acaba con la travesura del Grinch!

Completa el reto!

--- 

Mi solución:

{% jsitor https://jsitor.com/embed/v22gAPcTC %}

---
Puedes seguir a @midudev y estar pendiente de los retos de Advent.js 

{% twitter 1466086678507008003 %}