Skip to content

Instantly share code, notes, and snippets.

View dnovais's full-sized avatar
🏠
Working from home

Diego Novais dnovais

🏠
Working from home
View GitHub Profile
@dnovais
dnovais / Install_oh_my_zsh_on_ubuntu.md
Created December 28, 2023 01:45
Install oh my zsh on ubuntu
@dnovais
dnovais / binary_search.rb
Last active August 31, 2023 04:09
Binary Search Algorithm
def binary_search(list, item)
end
@dnovais
dnovais / simple_search.rb
Created August 31, 2023 03:15
Simple Search Algorithm
list = [1, 2, 3, 4, 5, 6, 7, 30, 32, 12, 21, 22, 56, 70, 62]
list = list.sort
find = 21
list.each do |item|
puts "The number #{find} is here!" if item == find
end
@dnovais
dnovais / poc_dsl_ruby_generate_crystal.rb
Created July 19, 2023 13:20
Poc - DSL - Ruby generate Crystal
class CrystalDSL
attr_reader :code
def initialize(&block)
@code = ''
instance_eval(&block) if block_given?
end
def generate(&block)
instance_eval(&block) if block_given?
@dnovais
dnovais / ruby_generate_crystal.rb
Created July 19, 2023 12:57
Ruby Generate Crystal
def generate_crystal_code(class_name, method_name, parameter_type, parameter_name)
code = <<~CRYSTAL
# Generated Crystal code
module MyModule
class #{class_name}
def initialize(#{parameter_name} : #{parameter_type})
@#{parameter_name} = #{parameter_name}
end
def #{method_name}
@dnovais
dnovais / oop.rb
Created February 10, 2023 14:18 — forked from serradura/oop.rb
Código produzido na live "A verdadeira Orientação a Objetos" em 09/02/2023
####################################
# Pilares da Orientação a Objetos: #
####################################
# 👍 Abstração. | >
# 👍 Encapsulamento | > > Composição 🙌
# 👍 Polimorfismo | >
# 👎 Herança
@dnovais
dnovais / postgres-brew.md
Created August 11, 2022 03:11 — forked from ibraheem4/postgres-brew.md
Installing Postgres via Brew (OSX)

Installing Postgres via Brew

Pre-Reqs

Brew Package Manager

In your command-line run the following commands:

  1. brew doctor
  2. brew update

Matchstick factory Challenge

A matchstick factory has to put n matchsticks in boxes. The factory has the following three types of boxes:

A big box holds 50 matchsticks A medium box holds 20 matchsticks A small box holds five 5 matchsticks The boxes can’t have fewer matchsticks than they can hold; they must be full.

Implement the boxes/1 function in the MatchstickFactory module. The boxes/1 function returns the number of boxes of each size needed to accommodate all the matchsticks and the number of remaining matchsticks as a map (The map is included in the started code). It should work like this:

@dnovais
dnovais / print_string_x_times_without_loop.md
Created January 21, 2022 17:49
Print 'Hello world!' 50 times without a loop

Print 'Hello world!' 50 times without a loop

Usando recursividade

def print(times: 1, msg:)
  puts msg
  times += 1
  print(times: times, msg: msg) unless times > 50
end
@dnovais
dnovais / entendendo_o_codigo.md
Last active January 20, 2022 21:33
Entendendo o código para o problema do diamante e areia.

O problema

Dado um conjunto de caracteres, você precisará extrair os "diamantes" ( <>) e as "areias" ( . ) da expressão e no final exibir a quantidade de diamantes extraídos

Expressão: <<.<<..>><>><.>.>.<<.>.<.>>>><>><>>

  • Extrair os diamantes e areias da expressão até que não haja mais o que ser extraído;
  • Exibir a quantidade de diamantes extraídos;;

A solução proposta pelo RDSM (@das_rm)