Skip to content

Instantly share code, notes, and snippets.

View iammateus's full-sized avatar
🎯
Focusing

Mateus Soares iammateus

🎯
Focusing
View GitHub Profile
public function searchBuilder(Request $request)
{
try {
$sort_by = null;
$search_type = $request->has("search_type") ? $request->get("search_type") : "";
$search = (new Volunteers)->with('businessesVolunteers', 'peopleVolunteers', 'demands', 'events', 'actingAreas', 'serviceTypes')->newQuery();
{
"version": "0.2.0",
"configurations": [
{
"name": "Listen for XDebug",
"type": "php",
"request": "launch",
"port": 9000,
"stopOnEntry": true,
"pathMappings": {
Install Hyper
Website:
https://hyper.is/
Install ZSH:
https://github.com/ohmyzsh/ohmyzsh/wiki/Installing-ZSH
Install Oh My Zsh
<?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
{
# 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
@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))))
@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))))
(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)))
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;
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],