teleren/devto huggingface dataset:
📅 Manage GitHub milestones from cli
Tags: github, productivity, tutorial, api
Published: 2022-05-30 21:53:40

## ❔ Intro

Recently we needed to load a lot of issues on a given milestone so they could be properly managed and reported.

Issues were coming from a given list. Manual process was very time consuming... so we wondered how we could achieve this in a much more efficient way, from shell and cli commands.

This short post is about that and shows what kind of things can be achieved with [GitHub Cli](https://cli.github.com/)... and especially how [`cli/cli`](https://github.com/cli/cli) can be used with [`gh api`](https://cli.github.com/manual/gh_api) calls.

## 🎬 Démo

{% youtube wWyUDkghFZI %}

## 🔖 More about GH API

Delopers make feedbacks... and as you can see it below Github is

> _"committed to making it trustworthy, easy to find, and easy to use."_

{% twitter 1529140169185665026 %}

## 🔖 Gist


{% embed https://gist.github.com/adriens/5a66c2aad305b6da7f3a8f7271e6f42d %}
Javascript reduce method explained!
Tags: javascript, webdev, react, frontend
Published: 2022-05-30 21:50:15

#JavaScript

In JavaScript functions composition is the backbone pattern of the functional programming.

Take a function, "reducing" it with something (a value or even another function), and taking its output and feed the next function with it.

Repeat the cycle.

The "reduce" method is the way all of this can be done.

How to implement a custom reduce method?

See illustration below:

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6k9v9y69ena1fu6n5760.jpeg)
Configure Keycloak by a CLI extension
Tags: keycloak, cli
Published: 2022-05-30 21:49:47

> Today I will show you how to configure a Keycloak property by command-line interface.

The main advantage in the Keycloak world is the possibility to extend it. 🔧 Indeed, it exists several way to extend or manage this software and one of these is to use a CLI script.

In this article we will change the value at the startup time of the global property named `staticMaxAge` responsible of the caching for all assets of all themes. To be noted that we cannot configure this value by the UI but only by the standalone(-ha).xml file.

## Search the node path of the property

Whatever the selected Keycloak profile (standalone or cluster mode), we will find the expected node here :

```
server > profile > subsystem:keycloak-server > theme > staticMaxAge
```

## Create the CLI script

As soon as we have the node we have to translate it to JBoss script.

```
embed-server --server-config=standalone.xml

/subsystem=keycloak-server/theme=defaults/:write-attribute(name=staticMaxAge,value=3600)

quit
```

- The first one line indicates to the engine the target profile,
- The second one line writes the expected value in the property (staticMaxAge).

📝 One little tip, you can use a environment variable to fill the property :

```
embed-server --server-config=standalone.xml

/subsystem=keycloak-server/theme=defaults/:write-attribute(name=staticMaxAge,value="${env.KEYCLOAK_ADMIN_STATIC_MAX_AGE:3600})

quit
```

## Push the CLI script in the right folder

If you want to configure your instance at the startup time (the common case for the production environment) you have to push the script in the following path : `/opt/jboss/startup-scripts`

This is an example of my Docker 🐋 configuration :

```
RUN mkdir /opt/jboss/startup-scripts

ADD --chown=jboss:root cli/update_assets_cache.cli /opt/jboss/startup-scripts/
```

## Let me try it

If you want a complete example with a Docker configuration, you can clone the repository https://github.com/ulrich/keycloak-configuration-with-cli

Crédit photo : Vanille
JavaScript LeetCode Valid Anagram
Tags: leetcode, javascript, datastructures, programming
Published: 2022-05-30 22:57:11

---
title: JavaScript LeetCode Valid Anagram
published: true
date: 2022-05-30 21:33:57 UTC
tags: leetcode,javascript,datastructures,programming
series: JavaScript LeetCode
canonical_url: https://relatablecode.com/javascript-leetcode-valid-anagram
cover_image: https://dev-to-uploads.s3.amazonaws.com/uploads/articles/l8yvx9whgotqis7zzxs6.png
---
#### Prompt

An **Anagram** is a word or phrase formed by rearranging the letters of a different word or phrase, typically using all the original letters exactly once.

**Example 1:**

```text
Input: s = "anagram", t = "nagaram" 
Output: true
```

### Analyzing the problem

Let’s this of what the problem is asking. We have to know the contents of the strings we’re analyzing. We also have to make sure that we’re keeping track of the letters as they should be exactly the same to confirm that it is an  **anagram**.

Following that train of thought, we can early return if there is ever a difference in the letters they contain. But what does it mean to have the same letters? Well, essentially it’s mapping out the frequency of each letter for the first word we iterate over. When we iterate over the second word we can double-check with what.

Checking back on the first example provided we can visualize this by counting each letter:

![javascript leetcode](https://cdn-images-1.medium.com/max/285/0*Chfe42aFbcNsbWgg)

Looking at the counts we can use this to validate in place as we iterate over the second word. Let’s see how this would look:

![javascript leetcode](https://cdn-images-1.medium.com/max/265/0*A9HZ5IFUyCpotPHS)

So the first time we run into the n in the second iteration we subtract it from the count. Anytime we go below 0 then we know the words are **not** valid anagrams.

Cool 😎, let’s get to coding.

### The solution

Similar to our [last problem](https://relatablecode.com/javascript-leetcode-best-time-to-buy-and-sell-stock) we can use a hash table.

```js
var isAnagram = function(s, t) {
    if (s.length != t.length) return false;
    const hashTable = {};

    for(let i = 0; i < s.length; i++) {
        if (!hashTable[s[i]]) {
          hashTable[s[i]] = 0;
        }
        hashTable[s[i]]++;
    }

    for(let j = 0; j< t.length; j++) {
        if (!hashTable[t[j]]){
          return false;  
        } 
        hashTable[s[j]]--; 
    }

    return true;
};
```

In the first iteration, we add the frequency of every letter. If it doesn’t exist we create a 0 value at that point.

```js
if (!hashTable[s[i]]) {
    hashTable[s[i]] = 0;
}
hashTable[s[i]]++;
```

On the second iteration, we subtract all values. If no letter ever exists then we’ll hit the number 0 which means we'll return a false.

```js
if (!hashTable[t[j]]){
   return false;  
} 
hashTable[s[j]]--;
```

### Let’s connect

If you liked this feel free to connect with me on [LinkedIn](https://www.linkedin.com/in/relatablecode) or [Twitter](https://twitter.com/relatablecoder)

Check out my free developer roadmap and weekly tech industry news in my [newsletter](https://relatablecode.substack.com/).
RubyBook - a VSCode extension that provides a notebook interface for Ruby code
Tags: ruby, vscode, opensource, typescript
Published: 2022-05-30 21:25:50

Hi All,

I wanted to share a VS Code extension **RubyBook** that I just published. It provides a notebook interface for Ruby code. 📓

This extension spawns a `pry` process in the background to allow users **to create experiences with connected, executable Ruby cells and informational Markdown cells.** 🎉

**GitHub Repo:** https://github.com/rajshah11/ruby-book

**VS Code Extension:** https://marketplace.visualstudio.com/items?itemName=rajshah11.ruby-book

**Demo GIF** - https://dev-to-uploads.s3.amazonaws.com/uploads/articles/n1qopcqt0w3tp0wm4g0w.gif (Embedding in Markdown failing :/)

![RubyBook](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hmvl966rgwcxhb60d02j.png)
Crawling Thousands of URL's? Import sys.
Tags: python
Published: 2022-05-30 21:20:26

This post is mainly here to act as a mental note for me in the future! However, you might find it helpful.

I'm coding a bot that loops through a CSV file of about 15,000 URL's, these are added to a Set when successfully scraped. 

But, when Firefox or Chrome driver couldn't load the website, my bot would require a restart. The scraper function would need to restart again and check to see if the URL was in the Set.

This would throw an exception saying something to the effect of 'maximum recursion depth exceeded'

If you get this error when running your Python code try this:

`import sys
sys.setrecursionlimit(40000)`

Courtesy of [coderjack](https://stackoverflow.com/questions/6809402/python-maximum-recursion-depth-exceeded-while-calling-a-python-object) this will increase the capacity of the stack and allow the code to run.

Be careful with the number you set this to, especially if you are on an old machine. The spinning circle may pay a visit.
Terraform AWS Secrets handling
Tags: terraform, aws, devops, cloud
Published: 2022-05-30 20:35:19

{% youtube pw-g-9N5pLk %}

Terraform and AWS credentials handling? - https://jhooq.com/terraform-aws-credentials-handling/

If you are new to terraform or maybe you have been using the terraform for quite some time then might have felt the need to manage your AWS Credentials inside your terraform file.

In this session we will go through the different ways to set up your AWS Credentials so that you do not have to re-configure the AWS Credentials every time, also we will pay attention on what are the most secure ways to handle your AWS Credentials

Here are three different ways of handling AWS Credentials -


1. Hard coding AWS Credentials(ACCESS_KEY, SECRET_KEY) inside terraform file (*Not recommended)
2. Using /.aws/credentials file along with terraform’s shared_credentials_file settings
3. Configure AWS Credentials as environment variables
Buscar e armazenar valores do HTML em JavaScript
Tags: javascript, beginners, programming
Published: 2022-05-30 20:34:38

Olá,

vou ensinar uma forma de extrair dados de uma classe em HTML usando JavaScript.

Lembrando que ainda estou estudando e essa é uma maneira que encontrei para fixar meus estudos.

Digamos que você deseja retornar o IMC de um paciente, então você precisará filtrar os dados necessários para o cálculo do IMC (explicarei abaixo)

Primeiro, você deverá, como boas práticas, criar um arquivo separado para o JS. Para isso, você deve utilizar o comando:

 `<script src = "folder/nameOfArchive.js"></script>`

 no final de sua classe body.


Após criar o arquivo separado para o JavaScript, vamos buscar os dados que você deseja trabalhar.

Vamos trabalhar só com um paciente, o id dele será #first-patient 
no entanto.


Para fazermos a busca do paciente em JavaScript, devemos usar o DOM 
[Saiba mais em](https://developer.mozilla.org/pt-BR/docs/Web/API/Document_Object_Model/Introduction).

A busca ocorre usando o `document.querySelector()`, é um método que permite que você busque algo específico dentro do documento.

Já sabendo que o id do paciente é #first-patient, faremos a busca usando o #, pois é um Id:

`document.querySelector("#first-patient")`

Porém só isso não basta. Precisamos armazenar o dado buscado em uma variável, então: 

`var patient = document.querySelector("#first-patient")`

Agora temos todos os dados do paciente armazenados em uma variável.

Porém, nós não queremos todos os dados do paciente, precisamos filtrar apenas os dados para calcular o IMC (peso e altura).

Dentro da variável que acabamos de criar, contém os dados que buscamos.

Para isso, usaremos a função `querySelector()` novamente:

`var tdWeight = patient.querySelector(".info-weight")` 

Diferentemente da busca pelo paciente, estamos usando uma busca de classes, não de ID, então por isso usamos o "." na frente da classe.

A variável tdWeight armazena toda a informação da classe info-weight, nós não queremos isso. Nós queremos apenas o valor armazenado dentro dessa classe (peso):

`var weight = tdWeight.textContent`

Aqui nós estamos fazendo uma busca direta na variável tdWeight para retornar apenas o valor, e assim armazenar na variável 'weight'.

Faremos o mesmo com a altura:

`var tdHeight= patient.querySelector(".info-height") `

`var height= tdHeight.textContent`

Pronto. Feito isso, temos os dois valores que precisamos para fazer os cálculos de IMC (peso / (altura * altura))

Porém, para armazenar o valor dentro da classe IMC, precisamos fazer a mesma busca que fizemos com as outras classes:

`var imc = patient.querySelector(".info-imc")`

Aqui nós buscamos a classe info-imc e armazenamos na variável imc.

Precisamos fazer um cálculo para que tenhamos o resultado do IMC, e isso é como tirar doce de criança.

Apenas devemos chamar novamente nossa variável imc e atribuirmos os valores na fórmula citada acima, veja como fica:

`imc = weight / (height * height)`

Simples, né? 

Aqui o nosso retorno, caso weight = 100 e height = 2 seria de:

25.


:D
FizzBuzz Challenge Usando list comprehension!
Tags: python, programming, fizzbuzz
Published: 2022-05-30 19:18:51


Si eres programador o estas aprendiendo a programar seguramente te has encontrado con el FizzBuzz Challenge o lo encontraras.
A continuación hablaremos acerca de este reto y lo implementaremos utilizando list comprehension de python!

**Que es FizzBuzz Challenge**
Se nos pide escribir un programa el cual nos imprima _n_ cantidad de numeros.
Si el numero es multiplo de 3 imprimir Fizz
Si el numero es multiplo de 5 imprimir Buzz
Si el numero es multiplo de 3 y de 5 imprimir FuzzBuzz
Si el numero no es multiplo de ninguno imprimir el numero

**Implementación regular FizzBuzz**
Para entender como funciona nuestra list comprehension primero necesitamos entender como necesita funcionar nuestro programa.
La forma mas sencilla de implementarlo es con un `for` loop y con expresiones `if`

Primero necesitamos iterar por la cantidad de numeros
`for i in range(1, 15):`
En cada iteracion revisaremos nuestras condiciones utilizando nuestro operador modulus `%`
Podemos manejar este operador de forma booleana ya que cuando el resultado de el modulo es 0 nos regresa `False`.
Podemos invertir nuestro resultado booleano utilizando `not` y de esta forma cuando nuestro numero si sea divisible nos regresara `True`, Esta logica la podemos implementar dentro de nuestro `for` loop de la siguiente forma:

```
for i in range(1, 16):
    if not (i%3 and not i%5):
        print("FizzBuzz")
    elif not (i%3):
        print("Fizz")
    elif not (i%5):
        print("Buzz")
    else:
        print(i)

```
Nuestra respuesta en consola seria:
![FizzBuzz console log](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hs5yui7vi38bocqkfs75.png)
Felicidades, ya completaste el FizzBuzz Challenge.

**FizzBuzz con List Comprehension**
Para poder aplicar nuestro list comprehension debemos recordar que al utilizar el operador `*` se repite esa cantidad de veces.
De esta forma podemos utilizar `x = "string"*(not i%5):`
Cuando el Resultado de nuestra evaluación sea False nuestro string no se mostrara.
primero evaluaremos nuestras condiciones.
Ejemplo:
`"Fizz"*(not i%3)` Si `i==2` entonces nuestra evaluacion seria False, Despues evaluamos con nuestro operador `*` y al ser falso ese "String" no se estaria concatenando.

de esta forma:

```
FizzBuzzList = ["Fizz"*(not i%3) + "Buzz"*(not i%5) or i ]
```
Hasta aqui tenemos la parte logica de nuestro list comprehension.
Por cada iteracion pasaremos nuestro string en el que si no se cumple nuestra condicion  no se concatena y cuando no se cumple ninguna condicion se concatena el numero de nuestra iteracion.

Ahora solo nos falta agregar nuestro for loop `for i in range(1, 16)`, en `range()` nuestro primer parametro es inclusivo y el segundo parametro es exclusivo.
De esta forma si necesitamos numeros de el 1 al 15 debemos ingresarle los parametros `1, 16`

Nuestro List Comprehension final quedaria de la siguiente forma:

```
FizzBuzz = ["Fizz"*(not i%3) + "Buzz"*(not i%5) or i for i in range(1, 16)]
```
Espero les haya sigo de ayuda!
Happy Hacking!
Carlo Monroy
Coding habits to improve your efficiency in competitive programming
Tags: productivity, tutorial, discuss, career
Published: 2022-05-30 19:05:13

> Hackathons, like coding challenges, are often run for 1 to 7 days or a set amount of time. One thing you must have noticed is that you have a limited amount of time to complete your code

Participating in coding challenges and hackathons, whether offline or online, is enjoyable and productive. In these contests, you can win a variety of prizes and incentives. You can demonstrate your ability and be rewarded for it. One thing you must have noticed is that you have a limited amount of time to complete your code. You will be outrun by the other challengers until and until you compete effectively and manage your time.

Great programmers and developers are extremely dependable. They estimate the amount of time it will take to finish the assignment, communicate it, and deliver it on time. Here are some suggestions for saving time while competing in a coding competition:

**1. Consider and compile**
You won't always get the program correct the first time, so be patient and learn all of the errors you've made; you can't just eliminate an error and build again. You must go over the entire software again and correctly examine it to avoid wasting your limited time.

**2. Having a fun coding environment**
Prepare your tools before the competition because you could waste countless seconds due to little issues such as your internet connection failing, your browser malfunctioning, and so on. These flaws may also cause you to become distracted and unable to concentrate on your logic. Before you settle down to take on the challenge, make a plan.

**3. Read the questions twice or thrice**
The issue creator has created numerous loopholes in which the user can become imprisoned. You must find a way out of all of these holes. You may get into difficulties unless and until you read the question twice or three times, and you will waste time trying to figure out what went wrong and correcting those errors.

**4. Improve your thinking and comprehension**
You can run code written by other efficient coders to get a sense of what can be done with coding and how it can be done more quickly and logically. Some other efficient coder may have created the program you compiled in 100 lines of code in 50 or fewer lines, saving him time to attempt other coding questions. It's also possible that getting the output through his code took less time. Continue to learn from other brilliant programmers.
Never have I ever used Tailwind
Tags: css
Published: 2022-05-30 19:02:14

🥃 well I know absolutely nothing about it, it's supposed to be this great way of working with CSS and here's me with my scss and my CSS wondering if I will regret not learning it, but I say no, no more, I won't live in fear of not adopting a framework or tooling, I won't join the hype train... I'm sticking to fundamentals until I have a need.

So am I right? Sell me tailwind in the comments I promise I will not be idealistic but pragmatic
Hello internet friends ...
Published: 2022-05-22 16:28:42

My name is Stephanie. I live in Washington and I am currently a hairdresser. I was born in the Philippines and moved to the states when I was 4 years old. Although, we lived in the states and adapted to some of the customs here, my mother also found it very important to keep our native culture embedded in us. I can speak tagalog and english. And fun fact, I am one of 14 kids - long story short, that's step-siblings, half-siblings, and full siblings. 

I have been in the hair industry about five and half years and have been itching for a change. I started my career change journey by doing some pre-requisites for nursing and found that that was not the right path for me. I have loads of clients, given that I work at a salon in Seattle, in the tech world and they have graciously let me pick their brains. I found it so interesting. A friend introduced me to the bootcamp route and I started off learning on freecodecamp.org as I am sure that plenty of people have started on. It worked my brain and really challenged it, but I loved every second of it. It was so amazing to code something and then see the outcome of it right away and the abundance of things you can do to them. 

Flatiron stood out to me because of their Flex program. Because I took some community college classes that were primarily online, I found myself accustomed to the online learning and working full time. I really admire the help Flatiron offers even being in the Flex Software Engineer program because I can learn on my own pace, but I am always able to get help if I need it. I would love to learn more about front end because I like seeing the code that I create come to life. I really enjoyed the pre-work assignment where we re-created the Pharrell Williams poster. Aside from that, I would really be interested in getting into a gaming company and code for them. But all around, I love being a part of the tech world since it changes and evolves everyday and I have a small part in that. 

I can't wait for you all to follow along my journey and read about what I learned. I am so excited for this new chapter in my life and I am taking everything in, no matter how challenging, with open arms.
machine learning
Tags: machinelearning, writing, ai, webdev
Published: 2022-05-30 18:43:23

**
What is  machine learning.?**

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/sdfl2q214758bls6zkdi.png)
Well machine learning is a subfield of artificial intelligence, that focus on building system that learn  and  improve performance  based on what data is fed to them.
Machine learning  technology  is advancing at a fast rate & we are just scratching the surface of its capabilities
Types of machine learning include:

•	Supervised machine learning 
Both the input and output of the algorithm are specified. Algorithm are supplied with labeled training data and defined variables

•	Unsupervised machine learning
Vice-versa of the supervised where trains on unlabeled data. The algorithm scans through data sets and find meaningful connections.

•	Semi – supervised machine learning
Free to explore data fed on its own and develop its own understanding of the data sets.

•	Reinforcement machine learning.
Algorithm is programmed to complete a task and give it positive & negative  as it work out how to complete a task but for the most part , the algorithm decides on its own what steps to take along the way.
**_
Machine learning languages :_**
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0y9y9oa31ym1dbuit4ty.png)
They include

 

1. python – mostly for natural language processing, sentimental analysis & analytics

2. C & C++ - games and robot locomotion 

3.  Java   - network security , cyber attack , fraud detection

4. JavaScript – web APIS

5. R  – statistical and visualization mostly


**_The importance of machine learning?_**

Well it helps make informed decision as it helps enterprises a view of trends in customer behavior and business operations patterns.
It can handle  varieties and large quantities of data 
Able to identify trends and patterns from data. 
It  can be applied to solve problems, such as fraud detection, facial recognition, enable self-driven cars .
It also drives speech recognition technology and Medical diagnosis.
It increases productivity since its ability to automate repetitive tasks .
**_
The disadvantages is_** that it is time consuming and 
Requires a lot of space. May contain errors if fed on wrong analytics.

**Wrapping up**
To wrap up,  choosing the right algorithm depends on : 
Visualization of data,  the size of data, characteristics and type of data and training time required.
The accuracy and speed of the data. The parameters ( numbers that will affect) and features(quantifiable variable of the problem).