Skip to content

Instantly share code, notes, and snippets.

View iammateus's full-sized avatar
🎯
Focusing

Mateus Soares iammateus

🎯
Focusing
View GitHub Profile
openapi: 3.0.0
info:
title: Mateus API
description: A simple API with one route
version: 1.0.0
paths:
/hello:
get:
summary: Get a friendly greeting
description: Returns a simple greeting message
@iammateus
iammateus / genArr.js
Created July 11, 2022 14:21
JS: generate random integer array of random size
function getRandomIntInclusive(min, max) {
min = Math.ceil(min);
max = Math.floor(max);
return Math.floor(Math.random() * (max - min + 1) + min); //The maximum is inclusive and the minimum is inclusive
}
const genArr = () => {
const arr = [];
for(let i = 0; i < getRandomIntInclusive(0, 100); i++){
arr.push(getRandomIntInclusive(0, 100))
import removeIslands from '../../src/remove-islands';
describe('removeIslands', () => {
it('should work 1', () => {
expect(removeIslands([
[1, 0, 0, 0, 0, 0],
[0, 1, 0, 1, 1, 1],
[0, 0, 1, 0, 1, 0],
[1, 1, 0, 0, 1, 0],
[1, 0, 1, 1, 0, 0],
function createMatrix(rows: number, colls: number) : number[][] {
const matrix = [];
for (let i = 0; i < rows; i++) {
const row = [];
for (let j = 0; j < colls; j++) {
row.push(0);
}
matrix.push(row);
}
return matrix;
(ns tutorial.fibonacci
(:gen-class))
(defn fibonacci
"Returns the fibonacci sequence of a given length"
[ len ]
(def fibonacci-sec (atom (seq [ 0 1 ])))
(dotimes [counter (- len 2)]
(def first-num (nth @fibonacci-sec counter))
(def sec-num (nth @fibonacci-sec (+ counter 1)))
@iammateus
iammateus / string-utils.clj
Created January 4, 2022 23:43
Invert string in Clojure
(ns tutorial.string-utils
(:gen-class))
(defn invert_str
"Invert a string"
[value]
(def end (- (count value) 1))
(loop [index end result ""]
(if (not= -1 index)
(recur (- index 1) (str result (.charAt value index))) (println result))))
@iammateus
iammateus / cpf.clj
Last active January 4, 2022 00:49
CPF validation in Clojure
(ns tutorial.cpf
(:gen-class))
(defn validate_first_part
[cpf]
(loop [index 0 counter 0]
(def incre (* (- 10 index) (Integer/parseInt (.toString (.charAt cpf index)))))
(if (= index 9)
(do
(def lastDigit (Integer/parseInt (.toString (.charAt cpf 9))))
# Number of Visible Nodes
# There is a binary tree with N nodes. You are viewing the tree from its left side and can see only the leftmost nodes at each level. Return the number of visible nodes.
# Note: You can see only the leftmost nodes, but that doesn't mean they have to be left nodes. The leftmost node at a level could be a right node.
# Signature int visibleNodes(Node root) {
# InputThe root node of a tree, where the number of nodes is between 1 and 1000, and the value of each node is between 0 and 1,000,000,000
# OutputAn int representing the number of visible nodes.
# Example
# 8 <------ root
# / \
# 3 10
<?php
/**
* Validates a 2-digit area code not composed by zeroes.
* @link http://www.anatel.gov.br/legislacao/resolucoes/16-2001/383-resolucao-263.
* @return bool
*/
function validate (string $areaCode): bool
{
Install Hyper
Website:
https://hyper.is/
Install ZSH:
https://github.com/ohmyzsh/ohmyzsh/wiki/Installing-ZSH
Install Oh My Zsh