Skip to content

Instantly share code, notes, and snippets.

View paulodutra's full-sized avatar

Paulo Dutra paulodutra

View GitHub Profile
@paulodutra
paulodutra / validate-genre.py
Created July 29, 2023 15:57
An example using python to receive the genre of person and validate it.
validacao = False
while (validacao is False):
sexo = str(input('Informe o seu sexo, sendo M - Masculino e F- Feminimo: '))
if sexo == 'M' or sexo == 'm' or sexo == 'F' or sexo == 'f':
validacao = True
else:
validacao = False
@paulodutra
paulodutra / random-number.py
Created July 29, 2023 15:45
An example using python for hit random number.
import random
tentativas = 0
palpite = False
numSorteado = random.randint(1,10)
while (palpite is False):
num = int(input('Digite um numero: '))
if num != numSorteado:
tentativas = tentativas + 1
else:
@paulodutra
paulodutra / count-logic-example2.py
Created July 25, 2023 13:24
Second example using count logic
count = 0
for c in range(1,7):
letter = str(input('Digite a primeira {} vogal: '.format(c)))
if letter == 'A' or letter == 'a':
count = count + 1
print('Você informou a vogal A {} vezes'.format(count))
@paulodutra
paulodutra / count-logic.py
Created July 25, 2023 13:22
An example using count
sum = 0
count = 0
for c in range(1,7):
num = int(input('Digite o {} valor: '.format(c)))
if num % 2 == 0:
sum = sum + num
count = count + 1
print('Você informou {} números PARES e a soma foi {}'.format(count, sum))
@paulodutra
paulodutra / for-range.py
Created July 25, 2023 13:20
An example using for and range
for i in range(1,3):
print(i)
@paulodutra
paulodutra / for.py
Created July 25, 2023 13:19
An example using for and array of strings in python
names = ['Maria', 'João', 'Jose', 'Cleiton', 'Pedro']
for name in names:
print(name)
function firstAttack() {
if [monsterA.speed == monsterB.speed] then
if[monsterA.attack > monsterB.attack] then
monsterAttack = monsterA
monsterDefense = monsterB
else
monsterAttack = monsterB
monsterDefense = monsterA
fi
else if [monsterA.speed > monsterB.speed] then
@paulodutra
paulodutra / 1-create-typescript-project.sh
Last active April 12, 2023 18:52
1 - Create a simple project with typescript and jest
npm init -y
npm i typescript [email protected] @types/node @types/[email protected] [email protected] --save-dev
@paulodutra
paulodutra / example-swagger-user.yaml
Created January 14, 2023 00:29
Example of documentation using swagger write in yaml
swagger: "2.0"
info:
description: "Prover acesso ao recurso de usuários."
version: "0.0.1"
title: "Lista de Usuários"
termsOfService: "http://swagger.io/terms/"
contact:
name: Paulo
email: "[email protected]"
license:
@paulodutra
paulodutra / golang-install-grpc.txt
Last active December 15, 2022 14:09
golang installation with protocol buffter compiler and plugins for working gRPC with golang
1. First make the download the Go installer: curl -k https://go.dev/dl/go1.19.4.linux-amd64.tar.gz -o go.1.19.14.linux-amd64.tar.gz
2. You need remove any previous Go installation (if it exists), and then extract the file downloaded before: rm -rf /usr/local/go && tar -C /usr/local -xzf go1.19.4.linux-amd64.tar.gz
3. Add the go PATH in PATH environment variable: export PATH=$PATH:/usr/local/go/bin
4. Open the profile file: vim ~/.profile
5. In the end profile file add the go PATH: PATH=$PATH:/usr/local/go/bin
6. Install de protocol buffter compiler: apt install protobuf-compiler
7. Install the go plugins for working with gRPC:
go install google.golang.org/protobuf/cmd/[email protected]
go install google.golang.org/grpc/cmd/[email protected]
8. Update your PATH with protoc complier can find the plugins: