teleren/devto huggingface dataset:
Setup for Telescope
Tags: javascript, opensource, docker, webdev
Published: 2023-01-09 23:48:12

**Task**
This week, I try to revisit my setup for running the [Telescope](https://github.com/Seneca-CDOT/telescope) project, a single page website that aggregates blog posts.

**Getting Basic Components**
As I have done this before to contribute to the repo, this is hardly new to me. I start by following the [Environment Setup](https://github.com/Seneca-CDOT/telescope/blob/master/src/web/docusaurus/docs/getting-started/environment-setup.md) document in the repo. Obviously, you need to downland a copy of the project first.
To run the project locally, I need to have:
1. [Node.js](https://nodejs.org/en/download/)
2. [pnpm](https://pnpm.io/)
3. [Docker](https://docs.docker.com/install/)

I always have Node.js installed. Docker is a PaaS for running software. I choose to get [Docker Desktop for Window](https://docs.docker.com/desktop/install/windows-install/) from the listed options for Docker in the setup documentation, and it's just running the installation program. 
For pnpm, as described by the documentation, I installed it by entering the command `npm install -g pnpm` in your command line. This is a package manager like [npm](https://www.npmjs.com/) with some [differences](https://pnpm.io/pnpm-vs-npm#:~:text=npm%27s%20flat%20tree%E2%80%8B,%2Ddisk%20content%2Daddressable%20store.) in file structure and handling of directory dependencies and installation.

**Setup**
When I open the project in [VS Code](https://code.visualstudio.com/), it prompts me about [ESlint](https://eslint.org/) and Docker apps that the project uses, so I make sure to have them.
I run `pnpm install` command to install dependencies in the project while I'm in the project's directory folder.
There are different ways to run the project in the documentation, and I want to run both frontend and backend, so I run `pnpm services:start` to run the project locally. If Docker is running, it should setup to host the project locally. Be sure to run `pnpm services:stop` when you are done, and clear the cache if you need to.
If I need to use the database in some way, like testing login, I make sure to `run cp ./src/db/env.example .env` to get the right env file copy and then run `pnpm db:init` to setup the database.

**Difficulty and Learning**
It's a bit hard to wrap my head around it when I first try to run the project locally, because I didn't have a chance to touch pnpm and Docker before, so I had very little idea of how they work with the project. Of course, this means I get to learn what they are and how to use them for a project like this.
Also, there wasn't an explanation for how to setup the database in the setup documentation at the time, so I had to find it by digging through comments on project's [Slack](https://slack.com/) channel.
After some revisions to the project, there are now less bug in setting up the environment, and the documentation are much clearer.
Hello Guys! i'm new here and a i have a little question
Tags: webdev, css, html, javascript
Published: 2023-01-09 23:21:41

i've seen this effect on the texts, and i wanted to know how did can i do this

<iframe src="https://giphy.com/embed/KfgMOhvB9PSQZvAZ75" width="480" height="236" frameBorder="0" class="giphy-embed" allowFullScreen></iframe><p><a href="https://giphy.com/gifs/KfgMOhvB9PSQZvAZ75">via GIPHY</a></p>
#217: Contains Duplicate
Tags: leetcode, javascript, algorithms
Published: 2023-01-09 23:11:22

Honestly, this was the easiest problem I've come across so far on LeetCode. The directives were as follows:
> Given an integer array `nums`, return `true` if any value appears at least twice in the array, and return `false` if every element is distinct.

Immediately I started thinking about using one of JS's built in data types, specifically `Set()`. Why? Because a set doesn't contain duplicates, so instead of iterating the traditional way, we can just convert the array to a set, back to an array, and compare the lengths to see if there were any duplicates that the set eliminated.

Let's take a look at first converting the array to a set.
```
function containsDuplicate(nums) {
  return new Set(nums);
}
```
Nice - remember that we need to use the new keyword and not just `Set()`. Now, the value stored in that is the list with all duplicates eliminated. Let's convert that back to an array so we can compare more easily.
```
function containsDuplicate(nums) {
  return [...new Set(nums)];
}
```
I'm using the spread operator because it looks cleaner, but you could also use `Array.from()` or any other method. Now, let's look at the final step - comparing the lengths.

why compare the lengths? It's simple - because if there were any duplicates, the set will have deleted them from our new array so the lengths will be different. Therefore, we'll return if they aren't different so we correctly handle the booleans (true if there were duplicates, false if there weren't).
```
function containsDuplicate(nums) {
  return [...new Set(nums)].length != nums.length;
}
```
So there you go. An elegant one-liner that does the job pretty efficiently.
Day 3: Validate your idea quickly in the cloud
Tags: cloud, startup, writing, productivity
Published: 2023-01-09 23:09:32

Have you ever developed something just to discover that no one wants it? This is something that many first-time entrepreneurs face.

Today, I want to show you how the cloud helps you validate and succeed with your idea.

### Why should I validate my idea quickly?

Many first-time entrepreneurs make the major mistake of working on their idea for an extended time without validating it.

After developing an initial concept, they will expand on it, plan out the entire product, and possibly even prepare a business plan. They then hire developers and designers to complete the project. They launch two years later when everything is finished, and nothing happens. Then they recognize that nobody wants to buy their product.

Not having a product-market fit is typical and may be found in any new product or idea, and that is why you should always validate your ideas as soon as possible. Modern cloud platforms can help you validate your ideas faster. Here are my top three things you can do with the cloud to validate your ideas faster.

### 1) You don't have to manage everything.

Creating a prototype can take a long time. Additionally, you may need to employ a development team for specialized tasks. When using the cloud, You can delegate responsibility to the cloud provider and focus on your business.

Many cloud providers provide pre-built solutions that you can employ with a few clicks. You can use managed services if you have greater development knowledge. Managed services allow you, for example, to use a database without being concerned about the underlying server. So you can focus on bringing value to your customer rather than installing the latest patch to your server.

Using managed services allows you to set up entire environments in minutes rather than weeks or months, helping you validate and iterate more quickly. It also significantly minimizes the team size required to validate your proposal.

### 2) You can quickly scale to meet demand.

You never know how your customers will receive your idea.

It may be a major success, and you'll need more servers to keep up with the demand, or it might not be, and you'd like to save money. You can scale up or down your systems in seconds to meet demand when you use the cloud. This way, you can either keep up with increased demand by scaling up or save money by scaling down.

The cloud now powers everything from small personal projects to massive systems like Netflix, and it can scale to meet your needs.

### 3) You can easily change your product.

Your product will evolve!

You can quickly change everything you use in the cloud. Is the product no longer required? Stop or delete it, and you will not pay any additional costs. Do you want greater control over your managed services? Replace them with unmanaged services to have complete control.

Making changes in the cloud takes a few minutes. Therefore you can make changes on the fly, and the cloud will keep up.
Serverless Game
Tags: game, serverless, aws, linkedin
Published: 2023-01-09 22:50:16

---
title: Serverless Game
published: true
description: Serverless game on LinkedIn
tags: #game #serverless #aws #linkedin
cover_image: https://www.pawelpiwosz.net/assets/covers/serverless-long.png
---

I started 2023 with something new. I was wondering, what could be interesting, fresh and exciting. And I found it.

# The Game

I invented... the game. Well, no, I invented **The Game** :) The Game of Serverless. My idea was to make it very interactive, community driven and community building one. That is why as a platform I selected

# LinkedIn

This is the place where we can find so many brilliant and smart people. People eager t oshare their wast knowledge and experience.

## First rule of The Game

Every week (most probably Sunday evening CEST) I publish new requirements for the application and infrastructure. The Players' task is to propose the solution. 

## Second rule of The Game

Important is that solution must utilize Serverless services of AWS.

---

> Quite important disclaimer, I believe. This is the game, for fun. I do not expect and I do not ask for truly mature enterprise solutions. We, you all are paid for that. Here we share the tips and play the game for fun (I repeat myself, I know :) )

---

I play the role of "Game Master". My goal is to try to navigate you into the rocks. Another words, to force the situation, where Players will agree that Serverless is not an option. If this happen, I win :)

You, my dear Players, you receive the requirements and based on it you propose an architecture. You may even draw it, if you wish :)

The set of requirements is simple, at leas for now. In time the level should increase. For now we have business requirements (more or less). Soon we start to discuss non-functional requirements (or quality attributes, if you wish).

## Third rule of The Game

The requirements. Well, the rule here is simple. If I didn't reveal something, you are free to propose whatever you wish (from Serverless area, of course). I collect proposals from all Players and base on it I create new set of requirements.

So, as you can see, it is indeed an interactive game. I have some requirements in mind. But... In a day when I wrote this article, we are in second week and I already had to modify the requirements I gave to Players :) This make it interesting, doesn't it?

# I feel the thrill, how to join?

It is simple, really. I invite everyone to play.

## Fourth rule of The Game

This is the game for fun (did I said that already?). Be nice, kind and happy :)

# Resources

The best starting point is [Github repository](https://github.com/pawelpiwosz/TheGame-Serverless). I collect all data and progress there.

You can join directly in my [LinkedIn profile](https://www.linkedin.com/in/pawelpiwosz/)

# I wait for you there!

Let's have fun!
Day 669 : Siesta
Tags: hiphop, code, coding, lifelongdev
Published: 2023-01-09 22:36:15

_liner notes_:
- Saturday : There was a basketball game happening during my radio show's time slot so I decided to do the show online from my van and not drive to the station. Everything worked really well. I bought a bluetooth adapter for my recorder and was able bring in my cohost over the phone. Previously, I had to do stuff with wires and sometimes it wouldn't work. Had a good time. The recording of this week's show is at https://kNOwBETTERHIPHOP.com

![Radio show episode image of a screenshot from Family Guy with a person holding a newspaper from the Quahog Informant with the headline Petoria Invades U.S. with Peter Griffen sitting in a pool chair with the words Jan 7th 2023 Hootie Hoo](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/z7r9m1nny1n9lxuxmnew.jpg)

- Sunday : Did the study sessions. Got a bunch of stuff done. Watched the first episode of the new "Trigun Stampede" anime. Not bad.

- Professional : Pretty chill day. Had a quick meeting. Spent the rest of the day publishing and adding a new Web Component I made to some sample applications. I also communicated with some other team members about updates to the documentation.

- Personal : I got new side project to a place where I can show it to folks that I want to get involved. While I'm waiting to hear back, I going to work on integrating a payment system. I've been meaning to check out Stripe. I think they have a way of getting up and running quickly. Going to research to see if I can get it working the way I'll need it to.

![The mountain chain of the Dolomites, Italy poking up above the clouds](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xqzydob85vde7xf1vp5z.jpg)

Going to do more research on adding payment to my side project, maybe see if I can set up a test app. Will probably call it early and watch the new episode of "Vinland Saga" then catch a siesta.

Have a great night!

peace piece
Dwane / conshus
https://dwane.io / https://HIPHOPandCODE.com
{% youtube ptQB92zyRmg %}
How to deal with the "It is not possible to unreserve more products of ... than you have in stock" in Odoo.
Published: 2023-01-09 22:26:23

If you're experiencing this issue, you can do the following steps to fix it:

Install this [module](https://github.com/thetrebelcc/Force-OverWrite-All-QTYs) on your testing instance.
Run the workflow for updating the "Force Qty" and then try to cancel/close the stock.picking.

## What causes this error
There can be several reasons for this error, but the most common ones seem to be:

Changing the UOM of the product.
Updating the inventory after changing the UOM.
In both cases, Odoo thinks that you don't have enough product on hand to move the stock.picking record. Simply updating the on-hand inventory will not fix the issue. Due to the fact the 'reserved_quantity' is not updated on the front end. 

## Prevention
To prevent this error from occurring, you should follow these best practices:

Don't update the UOM in between inventory updates.
When updating the on-hand inventory, it's a good idea to unreserve any stock.picking records.

Here is the github repo. 
https://github.com/thetrebelcc/Force-OverWrite-All-QTYs

Follow me on twitter more Odoo/Python

https://twitter.com/tunahorse21?t=ZzU5NNgL0YvTSRpy-6NThA&s=09
Domain-Driven Design e os famosos “Value Objects”
Published: 2023-01-09 22:22:48

Quando começamos a estudar DDD (Domain-Driven Design) acabamos nos deparando com um termo chamado “value objects” (objetos de valor). Neste post vamos entender o que são esses “value objects” ou para os mais íntimos VO’s.

Eles expressão, medem, quantificam ou descrevem ‘algo’ em nosso domínio, eles não tem uma identidade que os diferencie uns dos outros, como por exemplo um ID, são iguais a partir de seus valores, não importa se forem objetos diferentes, mas se tiverem os mesmo valores, são iguais.

Por exemplo, temos um objeto Pessoa e essa pessoa tem uma idade logo essa idade é um VO, pois mede ou quantifica o número de anos que a pessoa viveu. Essa pessoa pode ter um nome, e esse nome descreve como essa pessoa é chamada, então tanto idade quanto nome modelam um todo conceitual, que no nosso exemplo é o objeto Pessoa. Raramente existirão sozinhos, existem para fazer parte de uma entidade.

Outro ponto é que eles são imutáveis, então eu não atualizo o seu valor, se precisar mudar algo, eu o recrio com seus novos dados, sendo um novo objeto.

Alguns exemplos: CPF, endereço, telefone, e-mail, etc…

Então “Value objects” são utilizados para medir, quantificar, descrever, expressar ‘algo’ de forma objetiva, trazendo valor para seu domínio.
Segue post sobre Entidades, outro ponto chave do DDD…

Referências para estudos:

Meu vídeo falando sobre:
[VO's](https://www.youtube.com/watch?v=kJYjmAj1vBM&t=1125s)

[Domain-Driven Design: Atacando as complexidades no coração do software](https://www.amazon.com.br/Domain-Driven-Design-Eric-Evans/dp/8550800651/ref=asc_df_8550800651/?tag=googleshopp00-20&linkCode=df0&hvadid=379739109739&hvpos=&hvnetw=g&hvrand=15262603459976817279&hvpone=&hvptwo=&hvqmt=&hvdev=c&hvdvcmdl=&hvlocint=&hvlocphy=1031693&hvtargid=pla-809277038576&psc=1)

[Implementando Domain-Driven Design](https://www.amazon.com.br/Implementando-Domain-Driven-design-Vernon/dp/8576089521/ref=asc_df_8576089521/?tag=googleshopp00-20&linkCode=df0&hvadid=379748659420&hvpos=&hvnetw=g&hvrand=15262603459976817279&hvpone=&hvptwo=&hvqmt=&hvdev=c&hvdvcmdl=&hvlocint=&hvlocphy=1031693&hvtargid=pla-460804278877&psc=1)

[VO’s e entidades](https://www.youtube.com/watch?v=6Pjod34OCnE)

[C# - Conceitos DDD - Value Object](https://www.macoratti.net/21/03/c_dddvo1.htm)

[O que é DDD - Domain Driven Design](https://fullcycle.com.br/domain-driven-design/)
LeetCode's Defanging an IP Address - Java Solution Beats 100% Memory & 92% Runtime
Tags: java, computerscience, usaco, webdev
Published: 2023-01-09 21:56:58

## Intuition
The problem asks us to replace all periods in an IP address with "[.]". The solution can be very simple by just using the built-in replace() method in the String class to replace all occurrences of "." with "[.]".

## Approach
Define a method defangIPaddr() that takes in a String called address.
Inside the method, use the replace() method to replace all occurrences of "." with "[.]" in the address String.
Return the modified address String.

## Complexity
- Time complexity: O(n), where n is the length of the input address String. This is because the replace() method iterates through the address String once to replace all occurrences of ".".

- Space complexity: O(n), where n is the length of the modified address String. This is because a new String is created with the modified address and is stored in memory.

## Code
```java
class Solution {
    public String defangIPaddr(String address) {
        return address.replace(".", "[.]");
    }
}
```
Getting there
Published: 2023-01-09 21:47:22

Today I learned some really helpful stuff related to mass assignments when you are creating and editing an entry into the database. 

Additionally, I also learned some ways to refactor my code related to link_to and form_with.

Here's the code I learned on assigning mass attributes. 
movie_attributes = params.require(:movie).permit(:title, :description, :id)
Ruby on Rails relationships for models that join on multiple tables.
Published: 2023-01-09 21:44:56

Ruby on Rails offers many tools to link models in your database, sometimes so many that it can be confusing to find the correct solution for your problem. I recently had two models, User and Image, that joined on two tables, Reviews and Favorites. Finding the right solution for this issue took some leg work, but eventually I implemented a clean solution that worked just as I needed it to. Keep reading if you too want to discover how to handle models that join on multiple tables. 

## The problem

I made a web app that had Users and Images. Users and Images both had many favorites and many reviews. Favorites are created when a user favorites an image, and reviews are created when a user reviews an image. 

![DB Layout](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/i5vgt96slewexx5b4q1b.jpg)

I needed both my users to both access what images they have liked and what images they have favorited, and the reciprocal for my images.

If I only had one joins table, I would achieve this relationship with the following code: 

```
class User < ApplicationRecord
has_many :images, through: :reviews
```
However, things start to look wrong when you add in the second relationship:
```
has_many :images, through: :reviews
has_many :images, through: :favorites
```


## The solution

Solving the above problem required me to search in a variety of places and was not the easiest to find, however the solution itself is very simple.

```
has_many :reviewed_images, :through => :reviews, :source => :image
has_many :favorite_images, :through => :favorites, :source => :image
```
This allows me to access the necessary data easily. 

## Usage

Let's say I was playing around with this code in my Ruby console. If I set an instance of my user class equal to u1, I could call that user's favorite images with the syntax u1.favorite_images, and I could call their reviewed images with u1.reviewed_images. Pairing this access with my Controllers and Serializers, we can now send the nested data to the front end so our app operates the way we want it to.
O funcionamento das Conversões de Tipo e sua prática:
Tags: javascript, reactnative, beginners, typescript
Published: 2023-01-09 21:25:06

As conversões de tipo (ou typecasting em inglês) significam a transferência de dados de um tipo de dados para outro.Em outro artigo, citei sobre o fato do JavaScript ser um tipo de linguagem de tipagem fraca, e até mostrei os tipos gerais de dados nesta linguagem que pode consultar por intermédio desse link -> https://dev.to/altencirsilvajr/quais-sao-os-tipos-de-dados-encontrados-no-javascript-e-como-funcionam-37j8  , neste artigo iremos citar muitos tipos de dados e caso seja um iniciante, pode consultar os dados citados por meio do outro artigo.

Devido a fraca tipagem,a conversão ocorre quando o compilador (para linguagens compiladas) ou tempo de execução (para linguagens de script como JavaScript) converte automaticamente os tipos de dados. 


Por exemplo, _alert_ converte automaticamente qualquer valor em uma string para mostrá-lo numa caixa de aviso. As operações matemáticas convertem valores em números. Também há casos em que precisamos converter explicitamente um valor para o tipo esperado.

```
 alert("Participante adicionado: ");
```

```
alert(`Participante removido: ${name}` );
```

Vale lembrar que essas conversões podem ocorrer de maneira _implícita_ ou _explícita_,usando _parSet()_ e por _toString_. Vejamos agora:

- **Meio implícito -**

O código o faz automaticamente, quando uma operação é realizada entre tipos de dados diferentes. Por exemplo, ao adicionar um número a uma string, a string é convertida para número.

```
let NumforStr = "123";
alert(typeof NumforStr); // string
```


- **Meio Explícito -**

Nesse caso ocorre quando você usa uma função de conversão de tipo, como Number(), String(), Boolean(), etc.

```
d = new Date();
Number(d) 
```

- **Meio parSet() -**

Esse é o contrário do meio implícito que foi citado anteriormente. Nesse caso, uma string se torna um número, entretanto é convertido em um número inteiro.

```
parseInt("Hello", 8); // Não é realmente um número
parseInt("546", 2);   // Dígitos não são válidos para representações binárias
```

- **toString -**

O método toString() retorna uma string representando o objeto, converte um valor para uma string. Esse caso em específico é muito utilizado para retornar valores em códigos mais estruturados:

```
function Dog(name) {
  this.name = name;
}

const dog1 = new Dog('Nami');

Dog.prototype.toString = function dogToString() {
  return `${this.name}`;
};

console.log(dog1.toString());
// expected output: "Nami"
```






Obrigado por ler até aqui!