teleren/devto huggingface dataset:
Serverless + JS: Um bot de web-scrapping diário
Tags: tutorial, webscrapping, serverless, javascript
Published: 2022-11-14 20:32:38

### Introducao
Se você está procurando uma maneira eficiente de coletar informações da web e não quer se preocupar com a infraestrutura de servidores, você precisa conhecer o poder do Serverless. O Serverless é um framework que permite criar arquiteturas sem servidores orientadas a eventos. Isso significa que você pode se concentrar nos eventos e comportamentos esperados em seus projetos, em vez de se preocupar com as máquinas que devem executá-los.

Ao usar o Serverless, você pode economizar tempo e dinheiro, pois só paga pelos recursos que usa. Além disso, para os desenvolvedores iniciantes, o Serverless oferece a possibilidade de criar projetos sem ter que lidar com a complexidade da infraestrutura.

Neste post, mostrarei como criei um bot de web-scrapping diário usando Serverless e JavaScript para informar o cardápio do restaurante universitário da minha faculdade pelo Telegram. O projeto está disponível em meu repositório GitHub (https://github.com/guisteink/sls-menu-service), e vou presumir que você tenha um conhecimento básico em Serverless.

### Configuracoes de infraestrutura
O maximo que voce vai precisar saber configurar de infra nesse projeto sera isso. 
```
provider:
  name: aws
  runtime: nodejs12.x
  memorySize: 128
  stage: v2
  region: sa-east-1
  timeout: 30
```
Simples assim!

Duas funções são executadas diariamente às 10h45 e 15h45 para capturar o almoço e o jantar do dia, respectivamente. Essas funções são agendadas via Lambda e consomem o método de scraping do site que contém o cardápio diário. Em seguida, a mensagem é tratada com alguns regex para melhor identificação no Telegram e enviada para o bot, que direciona a mensagem para o grupo (https://t.me/cardapioufes).

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

### Funcoes
O handler dispara o mecanismo citado, e pode ser ativado de duas maneiras: 
 - Pelo job agendado;
 - Por uma chamada http (POST) na rota.

Tambem existe o endpoint para receber o cardapio diario via REST, dando um GET na rota. Em casos de consumo da API.
```
functions:
  getMenuOfTheDay:
    handler: src/endpoints/getMenuOfTheDay.handler
    events:
      - http:
          method: GET
          path: /menu
  sendLunchMessageToGroup:
    handler: src/endpoints/scheduleEvent.handler
    events:
      - http:
          method: POST
          path: /message/almoco
      - schedule:
          rate:
            - cron(45 13 * * * *)
          enabled: true
          input:
            dish: almoco
```


### Conclusao
Esse é apenas um exemplo do que é possível fazer com a arquitetura Serverless. Com ela, você pode criar projetos escaláveis e eficientes, economizando tempo e dinheiro. Além disso, com o Serverless, você pode se concentrar na lógica do seu projeto, em vez de se preocupar com a infraestrutura de servidores.


### Referencias
* https://www.udemy.com/course/serverless-framework/
* https://core.telegram.org/bots
* https://github.com/guisteink/sls-menu-service
Create an Object from dot notation
Tags: javascript, frontenddeveloper
Published: 2023-12-28 05:02:19

---
title: Create an Object from dot notation
published: true
date: 2022-11-14 20:29:00 UTC
tags: JavaScript, frontenddeveloper
canonical_url: https://drmsite.blogspot.com/2022/11/create-object-from-dot-notation.html
---

![By Oleksandr Klymovych via scopio](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/t7kfvxad6yv4s2rv01pu.jpg)
Image by [Oleksandr Klymovych](https://scop.io/collections/vendors?q=Oleksandr%20Klymovych)

I was puzzled about this all afternoon. I came up with a terrible workaround using `eval`. Tonight, I did some more research and found [this answer](https://stackoverflow.com/questions/31464393/javascript-how-to-create-an-object-from-a-dot-separated-string#31464652) on StackOverflow. I've adapted it, and it seems to work a treat:

```javascript
(() => {

  const obj = {}

  const expand = (output, mystr, value) => {
    const items = mystr.split(".") // split on dot notation
    let ref = output // keep a reference of the new object
    // loop through all nodes, except the last one
    for (let i = 0; i < items.length - 1; i++) {
      if (!ref[items[i]]) {
        // create a new element inside the reference
        ref[items[i]] = {}
      }
      ref = ref[items[i]] // shift the reference to the newly created object 
    }
    ref[items[items.length - 1]] = value // apply the final value
    return output // return the full object
  }

  const arr = [
    "thingOne.thingTwo.thingThree",
    "thingOne.thingTwo.thingFour",
    "thingyOne.thingyTwo.thingyThree",
    "thingyOne.thingyTwo.thingyFour"
  ]

  arr.forEach(a => {
    expand(obj, a, true)
  })
  
  console.log(obj)

})()

```

I was nearly there on my tod, TBH, but wussed out at the end; this is lovely! It produces this object:

```javascript
{
  "thingOne": {
    "thingTwo": {
      "thingThree": true,
      "thingFour": true
    }
  },
  "thingyOne": {
    "thingyTwo": {
      "thingyThree": true,
      "thingyFour": true
    }
  }
}

```
Release 0.3-External
Tags: playwright, opensource, javascript, github
Published: 2022-11-14 20:25:22

For release 0.3, we had a few parts that we needed to accomplish in the assignment. This blog post will discuss my experience with contributing to an external repository. The repository of choice was [front](https://github.com/BVPyro/front).

front is the repository for the frontend to the website of the [BVPK e.V.](https://bvpk.org/) In simple terms, it's a static website with some forms for new members and donation functionality. The front- and backend of the application run on **Next.js**. The project is deployed with docker-compose on a Debian server. 

### Issue
[Issue #3](https://github.com/BVPyro/front/issues/3)
**Part 1:**
The author wanted testing for his repository so I tried it out with jest. I wasn't sure what they wanted as they only specified tests. Though I wasn't sure about the tests so I was using the tests to see if they would match the snapshot when being run. I did this for multiple pages. Though I was trying a new method. Instead of just testing the file out right, I had the test file create a snapshot of what was the expected output. It would then compare what it was receiving and compare it with the snapshot. If it did not match then the test would fail.to run the code the user has to use `npm run test`.

**Part 2:**
I also decided to also implement **end to end** tests using [**playwright**](https://playwright.dev/docs/writing-tests). Though this kind of testing was completely new to me. So I had to read the documentation on how playwright is implemented, and how to test _e2e_. It took a bit of time to understand but, eventually I understood. 

So I created basic tests for routing within the home page. So I fired up the server locally using `npm run start` and looked through some of the routes used on the home page. I've written the test in a way that it would only work once `localhost:3001` is being used, otherwise it would fail. to run the code the user has to use `npm run test:e2e`.

####Thoughts

The author never really conveyed how the code should be tested so I had to make due with what I did know how to do. Though straying out of my comfort zone when it came to creating these tests. Using snapshots was completely new to me, had to do a lot of reading using [this link](https://jestjs.io/docs/snapshot-testing#:~:text=Snapshot%20tests%20are%20a%20very,file%20stored%20alongside%20the%20test.). Learning playwright was also an interesting experience, though a welcome one. I now have some experience using a different kind of testing tool.
Tips for being a better Software Engineer
Tags: productivity, engineering, career
Published: 2022-11-14 20:24:58

Recently I finished reading a pretty good engineering book, so I decided to write an article about this, summarizing the main ideas. The book is "The Unwritten LAWS OF ENGINEERING", a classic.

## Don't worry too much with small things

You should only worry about the things that matter. This doesn't mean that you should ignore the details of your system, but you have to start from a "macro vision", and then refine it along the development process, until you reach the "micro vision".

## Demonstrate the ability to get things done

Show your boss that you are capable of get things done. Solve bugs, deliver new features, take bigger responsibilities. As Nike says: **Just Do It** - but with quality, obviously.

## Be straight to the point

When you are writting a documentation, a report or during a call with your team, it' very important to be consise and clear in your statements. By doing this, you can repass the maximum of significant information in the minimum time. **Get to the point, nobody likes attending to an 1 hour meeting, that could have been a short call or even a simple email.**

## Don't be too timid - expose your ideas

Speaking is difficult, even more if you are shy, but try to express yourself, expose your ideas. People who don't say nothing, are usually credited with having nothing to say.

## Maintain your boss informed of your progress

Had some progress in a task? Let your boss know.

## Optimize the meetings

Meetings can be very boring and also uneffective. Some tips to optimize it:
- Meetings should not be neither too large nor too small
- Prepare for the meeting
- Start the meeting giving a context of the main theme, some people may have forgotten
- Avoid off-topic discussions.
- Finish the meeting with a recap

## Take the risk, don't seek too much comfort

Managers and developers tend to seek the maximum comfort during the planning of the project, which is not good. Too much comfort means slower evolution. So, Take the risk! It's good sometimes, it enforces you to evolve, be more productive and competitive in the market.

## Do not criticize a subordinate in front of others

By doing this, you are causing a damage in both prestige and morale. Don't do this. Never. Also, never try to transfer the blame to someone else, if it is your fault, take the responsibility.

## Give feedback and ask for feedback

Your team partners need (and want) to know how they are doing, and you want to know how you are doing. So, the solution is very simple: feedbacks. You don't build high performance engineering teams without constant feedback.
Data Reveals Interesting New Insight Into How Leadership Styles Impact the Quality of Projects
Tags: programming, projectmanagement, productivity, webinar
Published: 2022-11-14 19:58:11

Join us on December 7th at 11am CT as we discuss a modernized approach to technical project management. We'll breakdown the do’s and do not's with three experienced developers and team leads. 

Register HERE: https://my.demio.com/ref/afxjbwFFofGQ5jY1
Basic info of Web storage API/localStorage/sessonStorage
Published: 2022-11-14 19:38:33

**Web storage API:**
API allows us to store, read, update and delete data in the browser.
Web storage API has two items-

- localStorage.
- sessionStorage.


**localStorage data:** localStorage is used to keep data permanent. The data never gets lost even in localStorage if the browser is closed. For which developers in most cases use local storage. 


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

Explanation of this code: We already know that localStorage permanently stores the value. setItem stores or sets the value. Or username is a key value and Nimki is a value. We have to just remember this one is key or the value must be a string.   


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

This is set in the browser. It creates keys or values.

Now, need to get the values from the console.

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

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

If need to update the values then need to change only the keys or values only, other codes are the same.

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

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

set or update both are similar codes and also get. So now, need to know how to remove this from local storage-

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


Many times developers need to pass an array and object and then minor changes to the code are required. 


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

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

here is only added JSON.stringify but the other codes are similar. Here most important thing is, Only JSON.stringify is needed when passing arrays and objects to local storage. But it needs to be JSON.parse in the case of gate items. 


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

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



**sessionStorage:** It works session-wise. sessionStorage works the same as localStorage but the deferent is- if the browser is closed the data will be lost in sessionStorage.
Go LIVE with Drag & Drop - React and NodeJS App
Tags: webdev, deployments, react, node
Published: 2022-11-14 19:31:22

---
title: Go LIVE with Drag & Drop - React and NodeJS App
published: true
description: This material explains how to deploy live full-stack projects using a simple drag & drop interface - Go LIVE, a new service provided by AppSeed.
tags: webdev, deployments, react, nodejs
cover_image: https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mdpjlndv63jlfw82wgbv.jpg
canonical_url: https://blog.appseed.us/go-live-with-drag-drop-react-nodejs/
---
Hello Coders! 

The video mentioned in this article demonstrates how to [deploy LIVE full-stack projects](https://appseed.us/go-live/) using only the URL of the target repository as input. The implementation uses an **open-source Python Library** that builds a simplified interface over **Render**, the infrastructure used for deployment. 

During the demonstration, three `projects are deployed` via a `drag & drop` gesture without touching the code or even pulling the sources locally. *Thanks for reading!*

> `The resources` used in this material:

- 👉 [App Generator](https://appseed.us/generator/) - `free service` (no account required)
- 👉 [Render API Wrapper](https://github.com/app-generator/deploy-automation-render) - `free library` (MIT License)
- 👉 [LIVE Deployer](https://appseed.us/go-live/) - service available for `PRO Users` (not free)

---

## VIDEO Transcript

- ✅ Access the [LIVE Deployer](https://appseed.us/go-live/) tool
- ✅ **Explain the concept**
- ✅ [Generate](https://appseed.us/generator/) a new **React & NodeJS** product
- ✅ `Deploy` the generated project `using Drag & Drop`
- ✅ Deploy LIVE [React Horizon UI](https://appseed.us/product/horizon-ui/api-server-nodejs/)
- ✅ Deploy LIVE [Flask API Server](https://github.com/app-generator/api-server-flask)
- ✅ Re-Configure `Horizon UI` to use the `Flask API`

{% embed https://www.youtube.com/watch?v=RfLBoCh7u1E %}

---

> `Thanks for reading!` For more resources and support, please access:

- 🚀 Free [support](https://appseed.us/support/) provided by AppSeed (email & Discord)
- 👉 More [free apps](https://appseed.us/apps/open-source/) crafted in Flask, Django, and [React]
API for listing all instance in a cross region compartment
Published: 2022-11-14 19:11:31

Hi,

I have a query around a cross region compartment. I'm trying to discover all the instances created in a compartment will an API call return instances across all regions to which compartment spans or only instances present in selected region. As I can see, API call url used to get list of instances has region embedded and I don't have access to other regions I'm not able to run it and get results.

https://iaas.ap-mumbai-1.oraclecloud.com/20160918/instances?compartmentId=ocid1.compartment.oc1..aaaa......
Python print() function
Tags: beginners, tutorial, python
Published: 2022-11-14 18:59:18

## 🖨 Print Function:
**print()** function is a built-in function of python for displaying  value of an expression written inside the parentheses as an output.
When we write a set of code and want to see any text output on the screen, we use the print() function.For example:
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/q1ibd4slocpq5qfjg0vr.png)

---

##💥A cool way to format your print statements:

- Way 01:

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


- Way 02:

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/da6lmjayipq9s2mdhtrw.png)
LATAM será potencia en Open Source
Tags: latam, opensource, community, spanish
Published: 2022-11-14 18:37:05

Es la conclusión que me traigo después de haber vivido en carne propia el CCOSS.

Hay muchísimas personas talentosas en la región, eso siempre ha sido un hecho, pero creo todo lo que se ha estado construyendo por años esta por empezar a dar frutos, muchísima evangelización que se esta traduciendo en participación a proyectos Open Source. 

Les platico un poco de mi experiencia en el evento. 

Llegué temprano al Centro de Diseño Intel en Guadalajara, el cual esta increíble, tienen más de 1,800 ingenierxs trabajando en hardware y software, de México para el mundo, además nos explicaban que tienen alianzas con centros de investigación del gobierno. 

Empezamos un poco tarde, ya saben los problemas técnicos que ocurren siempre que haces un evento presencial que deseas transmitir además en vivo. 

Las primeras dos charlas estuvieron bastante buenas, me encantó todo lo que estan haciendo en ElectroniCats, mis respetos por estar diseñando y comercializando esas placas open source que resuelven problemas y acercan la robótica a México y LATAM, todas las puertas que han abierto estoy seguro de que son solo el principio de lo que van a lograr. 

Después me tocó a mi participar, estaba super nervioso, había dado charlas presenciales en universidades, pero esta vez el público se sentía más exigente, estaba frente a personas que seguramente tenían una expectativa alta de mi, muchas veces he mencionado que me considero introvertido, hoy era uno de esos días. 

Fue de mucha ayuda el que hubiera una pantalla al frente en la que podía ver mi presentación y los puntos claves, ahi mismo me refugié cuando no quería ver a nadie para no verme nervioso. 

A la hora de las preguntas, sentí que ya había llegado a la cima y había parado de subir, de aquí lo que viniera sería como ir de bajada, camino a mi asiento vi a varias personas echándome miradas de: lo hiciste bien. Incluso alguien en el baño me felicitó. 

No fui yo, sino fueron TODAS las personas que participaron en el evento lo que me convence que LATAM será potencia Open Source, la cantidad de contribuciones que han hecho y el conocimiento que tienen.

Estoy seguro que muchos estamos parados y muchos estarán parados sobre los hombros de gigantes y que bueno, el esfuerzo de todas las personas debe de considerarse. 

Lo que viene para LATAM de Open Source, estoy seguro será increíble, quienes no crean en ello, bájense del barco, dejen a los que lo lograrán en paz, en el camino a lograrlo… 

Tal vez hayas llegado hasta aquí sin ver ningún dato, este post no va de ello, una disculpa, pero es un recuento de lo motivado que salí al ver a tanto talento reunido hablando de Open Source en LATAM que decidí escribir esto. 

De hecho se viene otro post del CCOSS pronto…
Best way to choose a programming font!!
Tags: webdev, vscode, programming, javascript
Published: 2022-11-14 18:35:18


Eyestrain is a real issue for software developers, and the font they choose to work with plays a big role in that. If they choose a font that’s not designed well enough, the punctuation or characters may be hard to distinguish, which makes them have to concentrate and focus more to make them out, which leads to headaches, eyestrain, and a generally lower productivity rate than ideal.

For that reason, [programmingfonts](https://www.programmingfonts.org/) exist! It has 100+ types of fonts, and also it has a preview which is cool because you can see what it looks like before download and install it.


![programming-fonts-example](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3ohptqnpsukfdx5d4c84.png)

Let me know which one you liked the most!
Continuous integration pipeline
Tags: opensource, javascript, jest, node
Published: 2022-11-14 18:30:11

## Overview

This week I've been working on setting github CI(Continuous integration) workflow, as well as wrote tests for another project.

## Workflow set up

To set up [workflow](https://github.com/mnosov622/simple-ssg1/actions/runs/3402442050) I added nodeJS.yml file that **runs on any push or PR to main branch.**

nodeJS.yml file:

```
name: Node.js CI

on:
  push:
    branches: [ "main" ]
  pull_request:
    branches: [ "main" ]

jobs:
  build:

    runs-on: ubuntu-latest

    strategy:
      matrix:
        node-version: [14.x, 16.x, 18.x]
        # See supported Node.js release schedule at https://nodejs.org/en/about/releases/

    steps:
    - uses: actions/checkout@v3
    - name: Use Node.js ${{ matrix.node-version }}
      uses: actions/setup-node@v3
      with:
        node-version: ${{ matrix.node-version }}
        cache: 'npm'
    - run: npm ci
    - run: npm run build --if-present
    - run: npm test

```

The structure of the file may look complex at first glance, but it turned out it's very easy-to-read.

## Writing tests to another project

It was very enjoyable process: talking with maintainer, making the suggestions in the code that he asks.

For me, I was very lucky to have a great partner, who has a very clean and concise project with appropriate code. It didn't take much time to understand how the code works.

For my [PR](https://github.com/gulyapulya/SSGulnur/pull/18) I did basic tests checking the functions for unexpected output.

I got experience writing tests for another project, fixing the code, while maintainer got experience reviewing my code.


## Tests, test and tests

As I see, it's never enough of writing tests, but we can and we should cover the basics of testing to prevent our tool from unexpected behavior. 

It's very important to collaborate with your peers, so they can test your project. They might find some issues, that you could never find on your own :)


## Continuous integration is a must

CI saves us a lot of time. For example, if someone makes a PR to the project, he can see that his code didn't pass the tests. Hence, he could immediately go and make necessary changes in the code.

## Automation

It's a great practice to automate repetitive things. With the help of github CI workflow we could save our time, write the code once and let it do the work for us.
Deno Install/Upgrade steps
Tags: deno
Published: 2022-11-14 18:28:56

### Installation :

Using Shell (macOS and Linux):

```bash
curl -fsSL https://deno.land/x/install/install.sh | sh
```

Using PowerShell (Windows):

```bash
irm https://deno.land/install.ps1 | iex
```

Using [Scoop](https://scoop.sh/) (Windows):

```bash
scoop install deno
```

Using [Chocolatey](https://chocolatey.org/packages/deno) (Windows):

```bash
choco install deno
```

Using [Homebrew](https://formulae.brew.sh/formula/deno) (macOS):

```bash
brew install deno
```

Using [Nix](https://nixos.org/download.html) (macOS and Linux):

```bash
nix-shell -p deno
```

Build and install from source using [Cargo](https://crates.io/crates/deno):

```bash
cargo install deno --locked
```

To check version :

```bash
deno --version
```

To Update  :

```bash
deno upgrage

#For Specific Version
deno upgrade --version 1.0.1
```
Reference: [Deno Installation Official] (https://deno.land/manual@v1.28.0/getting_started/installation)