teleren/devto huggingface dataset:
Quick Tip: Use Node to Create Random Strings
Tags: javascript, softwaredevelopment, coding, node
Published: 2023-09-02 01:51:37

---
tags: javascript,softwaredevelopment,coding,nodejs
canonical_url: https://seankegel.com/quick-tip-use-node-to-create-random-strings
---

![Generate random string with Node](https://cdn-images-1.medium.com/max/1024/1*nnX7iKIxBr42dgOHvj3Bxg.png)

How many times have you worked on an application and you needed a random alpha-numeric string? Did you try to provide a list of numbers and characters in a string and pass in a length to randomly generate a string with a loop?

Using Node.js, this can be a lot simpler. You just need to use the crypto library which is built-in.

```js
const { randomBytes } = require(“node:crypto”);

function randomString(length) {
  if (length % 2 !== 0) {
    length++;
  }
  
  return randomBytes(length / 2).toString("hex");
}

const string = randomString(8);
// string = "df5ec630"
```

A few issues with this is the length passed to the randomBytes method needs to be an even number so it can be divided in half. Otherwise, the string returned will be twice the length of the length passed in. This is why the condition is part of the function.

As a bonus, if you just quickly need a random string to use outside of an application, you can just go into your terminal, type node to go into the REPL, then add require(‘node:crypto’).randomBytes(8).toString(‘hex’).

```bash
node
Welcome to Node.js v20.4.0.
Type ".help" for more information.
> require('node:crypto').randomBytes(8).toString('hex')
'568b6620639fdf54'
```

If you want to generate a random string without even going into the REPL, you could use the following:

```bash
node -e “console.log(require(‘node:crypto’).randomBytes(8).toString(‘hex’))”
```

On a Mac, you can even add | pbcopy to the command to have the string copy right to your clipboard.

```bash
node -e “console.log(require(‘node:crypto’).randomBytes(8).toString(‘hex’))” | pbcopy
```

Just remember, when using the command from the terminal or REPL, the length passed to randomBytes will be half the length of what is outputted. So if you need a random string of 8 characters, pass 4 as the length.

I hope this quick tip was helpful. Let me know if the comments if you’ve seen any optimizations to the code above or if there’s an easier way to generate random strings.

Thanks for reading!
Funções - C
Tags: programming, computerscience, algorithms
Published: 2023-09-02 01:11:55

- As funções permitem agrupar um bloco específico de comandos que são executados quando a função é chamada. 


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

- Os parâmetros passam os valores que serão representados pelas funções. Eles devem ser explicitados no cabeçalho da função juntamente com seu respectivo tipo.


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

- Na declaração os parâmetros são intitulados PAR METROS FORMAIS, porém na chamada da função eles passam a ser definidos como PAR METROS ATUAIS/REAIS.

- Os parâmetros são passados de acordo com sua POSIÇÃO, o primeiro atual (chamada) define o primeiro real (declaração). O segundo atual define o segundo real e assim sucessivamente.


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

- Na linguagem C é permitido que a declaração da função 
seja feita antes de especificá-la.


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


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

1. - Escopo das variáveis: o escopo de uma variável é definido como o bloco de um código é válido. Com isso, são definidas as seguintes regras: 

1.1 - As variáveis valem no bloco que são definidas; 
1.2 - As variáveis definidas dentro de uma função recebem o nome de variáveis locais; 
1.3 - Os parâmetros formais de uma função valem também somente dentro da função; 
1.4 - Uma variável definida dentro de uma função não é acessível em outras funções, MESMO ESTAS VARIÁVEIS TENHAM NOME IDÊNTICOS. 


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


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

1.2 - Retorno: o retorno é a “saída” da função, ou seja, é o que ela vai enviar de volta para quem a chamou. Uma função sem parâmetros é chamada de lista de parâmetros vazios e uma função sem retorno possui o próprio void como retorno. 

=> sem parâmetros e sem retorno

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

=> com parâmetros e sem retorno


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

=> sem parâmetros e com retorno 

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

=> com parâmetros e com retorno 

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

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/sdv4342bxmvj4onoj9kz.png)
Manipulação de portas no Arduino usando registradores e operações lógicas
Tags: arduino, programming
Published: 2023-09-02 01:07:38

Cada porta no Atmega328p possui três registradores principais: DDRx (Data Direction Register), para setar o modo das portas;
PORTx, usado para escrever na saída digital da porta;
PINx, usado pelo buffer de entrada para que possamos ler o seu estado.

Irei usar o registrador DDRB para fins de ilustração, porém todos os outros casos são análogos.

O registrador DDRx (DDRB, por exemplo) assim como PORTx e PINx, possui 8 bits, e cada um dos bits controla uma das portas, como mostra o diagrama a seguir: 

7 | 6 | 5 | ...
--- | --- | ---| ---
DDx7 | DDx6 |DDx5| ...

```cpp
#define DDB 7
#define DDB 6
#define DDB 5
.
.
.
```
Assim, para configurar a porta 3 como saída, fazemos um shift à esquerda:

```cpp
1 << DDB3
```
de forma que agora DDRB tem o seguinte valor:

7 | 6 | 5 | 4 | 3 | 2 | 1 | 0
--- | --- | --- | --- | --- | --- | --- | ---
0 | 0 | 0 | 0 | 1 | 0 | 0 | 0


A operação OU (|) sempre resulta em 1 quando um dos operandos é 1, bit a bit, como descrito na  [tabela de operações lógicas de |](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B):

11111111 | 10100000 = 11111111

10011110 | 00001001 = 1001111


Sempre que queremos modificar apenas um bit no registrador DDRB para ligado, ou seja uma das oito portas como entrada ou saída, podemos modificar apenas o bit da porta correspondente para ligado (1), com a seguinte operação:

```
DDRB = DDRB | (1 << DDB3)
```
 temos agora que  o bit relativo a DDB3 está ligado (1).
A operação & sempre resulta em 0 [quando um dos operandos é 1 ou 0](https://en.wikipedia.org/wiki/Logical_conjunction), de forma que essa operação é muito conveniente quando queremos desligar um bit (ou seja, setar uma posição para 0):

11111111 & 10100000 = 10100000

11111111 & 00001000 = 00001000

11111111 & 00000000 = 00000000

Assim, para desligar o bit relativo a DDB3, podemos fazer:

```
DDRB = DDRB & (1 << DDB3)
```

de forma que desligamos o bit relativo a porta 3 no registrador DDRB.
ScrollView does not show the full content
Tags: reactnative, scrollview
Published: 2023-09-02 01:00:47

ScrollView does not show the full content
-----------------------------------------

As a software developer, you might have encountered the frustrating situation where a ScrollView refuses to show the full content. You scroll and scroll, but it seems like the end of the content is always out of reach. Don't worry, you are not alone in this struggle. In this article, we will explore some common reasons why this issue occurs and how to resolve it.

One possible reason for the ScrollView not displaying the full content is that the content might be exceeding the available space. It's like trying to fit an elephant into a tiny box. In this case, you need to check the dimensions of the ScrollView and make sure it has enough height to accommodate all the content. Remember, elephants need room to roam!

Another culprit could be the layout of the content within the ScrollView. If the content is not properly laid out, it might overflow or get cut off. Double-check your layout and ensure that the content is correctly aligned and positioned. Remember, a well-organized party is more enjoyable than a chaotic one!

Additionally, the ScrollView might not be configured to scroll vertically. It's like having a car without wheels – it won't go anywhere. Make sure that the ScrollView is set to scroll vertically by setting the appropriate properties or attributes. Remember, wheels make the world go round!

If you are using a ScrollView within a nested layout, such as a LinearLayout or RelativeLayout, make sure that the parent layout is not restricting the size of the ScrollView. It's like trying to fit a whale into a fishbowl – it just won't work. Adjust the parent layout to allow the ScrollView to expand freely. Remember, whales need the ocean!

Lastly, if you are using a ScrollView in a RecyclerView or ListView, you might encounter issues with scrolling. This could be due to conflicts between the scrolling behaviors of the ScrollView and the RecyclerView/ListView. In such cases, you might need to handle the scrolling events manually to ensure smooth scrolling. Remember, sometimes you need to take the wheel!

Now that you are armed with some tips to tackle the ScrollView woes, go forth and conquer! Remember, debugging can be a rollercoaster ride, but with a little humor, you can enjoy the twists and turns along the way.

### References:

*   [Example 1](https://www.example1.com)
*   [Example 2](https://www.example2.com)
*   [Example 3](https://www.example3.com)
Looking for open source project with web3.js or ether.js
Tags: opensource, web3, javascript
Published: 2023-09-02 01:00:07

Hi guys!

Anybody here know some open source project with web3.js or ether.js that look for contributor?

I am currently new in open source world and really want to learn something new. I also have passionate in big data and financial services. If you guys have info, please let me know. 

Thanks guys! Hope you guys are well 😁
Stages of building a country house
Published: 2023-09-02 00:06:30

Building a house is a very responsible and at the same time interesting business, which consists of several stages:

1. Planning and design: This stage involves deciding on the size, layout, and features of the house. It is important to get professional help with this stage to ensure that the house is well-designed and meets your needs.

2. Site preparation: This stage involves clearing the land, grading the site, and installing utilities

3. Foundation: This is the base of the house and it is important to get it right. The foundation should be strong enough to support the weight of the house and it should be properly waterproofed.

4. Superstructure: This is the frame of the house and it is made of wood, steel, or concrete.

5. Exterior finishes: This stage involves adding siding, roofing, and windows to the house.

6. Interior finishes: This stage involves adding flooring, walls, and ceilings to the house.

7. Wiring and plumbing: This stage involves installing the electrical and plumbing systems in the house.

8. HVAC: This stage involves installing the heating, ventilation, and air conditioning system in the house.

9. Landscaping: This stage involves adding plants, trees, and other landscaping features to the property.

10. Moving in: This is the final stage and it is time to enjoy your new country house!

The time it takes to build a country house will vary depending on the size and complexity of the project. However, it is typically a multi-year process.
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kvhw28lp3085t1p78jx6.jpg)
What is important in modern interior design?
Published: 2023-09-01 23:55:50

There are many factors that are important in modern interior design, but some of the most important include:

Functionality: The space should be functional and meet the needs of the people who will be using it. This means that it should be well-organized and have enough space for everything that needs to be stored.

Aesthetics: The space should be aesthetically pleasing and reflect the owner's personal style. This means choosing colors, materials, and furniture that are pleasing to the eye and create a cohesive look.

Sustainability: The space should be sustainable and use materials that are environmentally friendly. This means choosing materials that are recycled, recyclable, or made from sustainable sources.

Comfort: The space should be comfortable and inviting. This means choosing furniture that is soft and inviting and using lighting that is soft and warm.

Personalization: The space should be personalized and reflect the owner's personality. This means choosing colors, materials, and furniture that the owner loves and that make them feel at home.
Here are some additional tips for modern interior design:
Top trends in interior design
Published: 2023-09-01 23:54:17

Natural materials: People are becoming more and more aware of the importance of protecting the environment and this is reflected in interior design. Popular natural materials are wood, stone, leather and natural fiber textiles.

Eclectic Mix: More and more people are moving away from strict design rules and prefer to mix and match different styles and periods. This creates unique and personalized spaces.

Expressive elements: Nowadays, people want their homes to reflect their personality. Expressive elements such as artwork, furniture and décor can help create a unique atmosphere.

Internal and external connection: People are spending more and more time at home, so they want to create a sense of connection between the inner and outer world. This can be done by using natural materials, opening up space for a garden, or using panoramic windows.

Smart technologies: Smart technologies are becoming more accessible and popular. They can help make our homes more comfortable, energy efficient and safer.
Entendendo Requisitos Funcionais e Não Funcionais
Tags: management
Published: 2023-09-01 23:18:23

Olá!!!! Neste tutorial!, vamos explorar dois conceitos fundamentais no desenvolvimento de software: Requisitos Funcionais e Requisitos Não Funcionais. Compreender a diferença entre eles é crucial para o sucesso de qualquer projeto, independentemente da metodologia ou ferramentas que você esteja usando.

**Requisitos Funcionais**

O que são?

Requisitos Funcionais descrevem as funcionalidades específicas que um sistema deve realizar. Em outras palavras, eles detalham o que o sistema deve fazer.

📘 Referência: [IEEE Guide to Software Requirements Specifications](https://ieeexplore.ieee.org/document/278253)

Exemplos:
- Um sistema de gerenciamento de biblioteca deve ser capaz de emitir cartões de sócio.

- Um site de comércio eletrônico deve permitir que os usuários adicionem itens ao carrinho de compras.

Como identificá-los?

Geralmente, os requisitos funcionais são identificados durante a fase de coleta de requisitos e são documentados em um Documento de Requisitos de Software (SRS).

📘 Referência: [Software Requirements, por Karl Wiegers](https://vdocuments.net/software-requirements-third-edition.html)

**Requisitos Não Funcionais**

O que são?

Requisitos Não Funcionais, por outro lado, descrevem como um sistema realiza uma determinada função, em vez de quais funções ele deve realizar. Eles são muitas vezes relacionados à experiência do usuário, desempenho, ou conformidade com regulamentos.

📘 Referência: Non-Functional Requirements in Software Engineering, por Lawrence Chung

Exemplos:
- O sistema deve ser capaz de suportar 500 usuários simultaneamente.
- Todos os dados devem ser criptografados.

Como identificá-los?

Requisitos não funcionais são frequentemente descobertos por meio de entrevistas com stakeholders ou são derivados de padrões industriais ou regulamentações.

📘 Referência: [ISO/IEC 25010:2011 Systems and software engineering
](https://www.iso.org/standard/35733.html)

**Por Que São Importantes?**

Entender a diferença entre Requisitos Funcionais e Não Funcionais é crucial para desenvolver um produto de alta qualidade que atenda tanto às necessidades do usuário quanto aos padrões da indústria. Também é fundamental para a criação de User Stories, Features e Tasks eficazes em um ambiente de gerenciamento de projetos, como o que discutimos no Azure DevOps.

Espero que este tutorial tenha esclarecido as diferenças entre Requisitos Funcionais e Não Funcionais e por que ambos são importantes para o sucesso do seu projeto.
📊 Unleash the Power of Azure Data Lake Analytics: Taming Big Data 🌊
Published: 2023-09-01 23:12:59

Introduction:
---------------
In today's data-driven world, organizations deal with enormous volumes of data daily. Azure Data Lake Analytics provides a robust platform to process and analyze big data efficiently. In this comprehensive guide, we'll delve into the world of Azure Data Lake Analytics and explore how to harness its capabilities. 💪🔍

### **Understanding Azure Data Lake Analytics**

Azure Data Lake Analytics is a serverless analytics service that empowers organizations to analyze data of all sizes. It seamlessly integrates with Azure Data Lake Storage, enabling data engineers, data scientists, and analysts to process and gain insights from massive datasets without the hassle of infrastructure management. 🏞️💼

### **Step 1: Prepare Your Data**

Before diving into Azure Data Lake Analytics, ensure your data is stored in Azure Data Lake Storage Gen1 or Gen2. This step is crucial as it serves as the foundation for your big data analysis.

### **Step 2: Create Your Data Lake Analytics Account**

1. In the Azure portal, click on "+ Create a resource."
2. Search for "Data Lake Analytics" and select it from the search results.
3. Click "Create" and fill in the required details such as account name, subscription, and resource group. Choose the desired data lake storage account.

### **Step 3: Write U-SQL Scripts**

Azure Data Lake Analytics uses U-SQL, a powerful language that combines SQL and C#. You'll write U-SQL scripts to transform and analyze your data.

Here's a simple example of a U-SQL script to count the number of records in a dataset:

```sql
@data = EXTRACT ...
FROM "/path/to/data.csv"
USING Extractors.Csv();

@result =
    SELECT COUNT(*) AS Count
    FROM @data;

OUTPUT @result
TO "/path/to/output.csv"
USING Outputters.Csv();
```

### **Step 4: Submit and Monitor Jobs**

1. Submit your U-SQL script as a job to your Data Lake Analytics account.
2. Monitor job progress and status in the Azure portal or using Azure PowerShell/CLI.

### **Step 5: Review and Visualize Results**

After your job is complete, you can review and visualize the results using various tools like Power BI, Azure Data Studio, or Jupyter notebooks. Transform your raw data into meaningful insights! 📈📊

### **Step 6: Optimize Performance**

Azure Data Lake Analytics offers performance tuning options. Adjust data distribution, partitioning, and indexing to optimize query execution times and improve overall efficiency.

### **Conclusion**

Azure Data Lake Analytics is a formidable tool for processing and analyzing big data at scale. 🌟 With its integration with Azure Data Lake Storage and the power of U-SQL, you can gain valuable insights from your massive datasets without the hassle of infrastructure management.

Embrace the world of big data analytics with Azure Data Lake Analytics, and unlock the potential of your data to drive smarter decisions and innovation! 🚀📉
Creating a Virtual Machine and Installing the Web Server Role in Windows Server
Published: 2023-09-01 22:56:13

In today's digital age, the ability to set up and manage virtual machines is a crucial skill for IT professionals. In this guide, we will walk you through the process of creating a virtual machine and installing the web server role on Microsoft Windows Server.

### **Step 1: Sign in to Azure Portal**

1.1. Open your web browser and navigate to the Azure portal at [https://portal.azure.com](https://portal.azure.com).

1.2. Sign in with your Azure account credentials. If you don't have an Azure account, you can create one following the on-screen instructions.

### **Step 2: Create a Virtual Machine**

2.1. Once you're logged in, click on the "+ Create a resource" button in the left-hand menu.

2.2. In the Azure Marketplace search bar, type "Windows Server" and press Enter.

2.3. Choose a Windows Server version from the search results. Typically, Windows Server 2019 is a good choice.

2.4. Click the "Create" button to begin configuring your virtual machine.

### **Step 3: Configure Virtual Machine Settings**

3.1. Fill out the basic settings for your virtual machine:

   - **Project details**: Select your subscription, resource group, and region.

   - **Instance details**: Give your VM a unique name and choose an availability option. For testing purposes, you can select "No infrastructure redundancy required."

   - **Image**: Choose the Windows Server image you selected earlier.

   - **Size**: Select an appropriate size for your VM based on your performance and cost requirements.

3.2. In the "Administrator account" section, set a username and a strong password. This will be your login information for the VM.

3.3. Leave other settings as their default values for now, or customize them as needed.

3.4. Click the "Review + create" button to review your settings and then click "Create" to create the virtual machine.

### **Step 4: Connect to the Virtual Machine**

4.1. Once the VM is deployed, go to the VM's overview page.

4.2. Under "Settings," click on "Connect."

4.3. Download the Remote Desktop Protocol (RDP) file to connect to your VM.

4.4. Open the RDP file and enter the username and password you set during VM configuration.

### **Step 5: Install Web Server Role**

5.1. Once connected to your VM, open the "Server Manager" by clicking on the Windows icon in the taskbar and selecting "Server Manager."

5.2. In Server Manager, click on "Add roles and features."

5.3. Follow the wizard to add the "Web Server (IIS)" role.

5.4. Complete the installation by accepting the default role services or customizing them as needed.

5.5. Once installed, you can access the default IIS web page by opening a web browser and entering the VM's IP address or DNS name.

Congratulations! You've successfully created a virtual machine in Azure and installed the web server role on Windows Server. You can now start hosting and managing web applications on your VM.