Skip to content

Instantly share code, notes, and snippets.

View marclerodrigues's full-sized avatar

Marcle Rodrigues marclerodrigues

View GitHub Profile
@marclerodrigues
marclerodrigues / creator.rb
Created February 11, 2022 17:59
Ruby Models + Services
class Phones::Creator
attr_reader :phone_params
delegate :contact, to: :phone
def initialize(phone_params)
@phone_params = phone_params
end
def call
@marclerodrigues
marclerodrigues / questao.java
Created September 22, 2021 22:03
Questão em Java para Treinar Switch Case
import java.util.Scanner;
class MyClass {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int dia = scanner.nextInt();
switch(dia) {
case 1: {
@marclerodrigues
marclerodrigues / migratoryBirds.js
Created September 22, 2021 21:28
migratory birds hackerrank problem
// Problem: https://www.hackerrank.com/challenges/migratory-birds/problem
function migratoryBirds(arr) {
// Write your code here
// Contar os tipos e armazenar o valor deles em uma variavel
// Salvar em uma variavel do tipo objeto
const birdsTypes = {
1: 0,
2: 0,
3: 0,
4: 0,
@marclerodrigues
marclerodrigues / exemplo1.js
Created September 11, 2021 14:51
Resumo da Aula X
console.log("heeey")
@marclerodrigues
marclerodrigues / bill.v1.js
Created June 12, 2021 20:14
Bon Appetit Challenge
function bonAppetit(bill, k, b) {
// Write your code here
let total = 0;
for(let i = 0; i < bill.length; i++) {
if (i !== k) {
total += bill[i];
}
}
@marclerodrigues
marclerodrigues / .vimrc
Created June 24, 2020 10:37
Docker + Tests + Vim
map <Leader>r :terminal docker-compose exec spring rspec --order defined --format d %<CR>
@marclerodrigues
marclerodrigues / balanced_string.rb
Last active November 23, 2020 18:57
Leet Code Problems
# Problem: https://leetcode.com/problems/split-a-string-in-balanced-strings/
# @param {String} s
# @return {Integer}
def balanced_string_split(s)
balance = 0
total_count = 0
s.split("").each do |value|
if value == "R"
@marclerodrigues
marclerodrigues / .tmux.conf
Created April 10, 2020 17:43
Tmux Config
# Ring the bell if any background window rang a bell
set -g bell-action any
# Default termtype. If the rcfile sets $TERM, that overrides this value.
set -g default-terminal screen-256color
# Keep your finger on ctrl, or don't
bind-key ^D detach-client
# Create splits and vertical splits
@marclerodrigues
marclerodrigues / example.rb
Created April 3, 2020 15:08
find_each inner works.
# find_each loses order of previous sorted relations
# under the hook it users some primary key ordering
# a workaround to perform iterations in batches is
batch_size = 100
ordered_ids = Model.ordered.pluck(:id)
ordered_ids.each_slice(batch_size) do |slice|
HeavyWork.call(slice)
end
@marclerodrigues
marclerodrigues / bash.sh
Created March 2, 2020 14:34
Using Gem Specific Version
# [gem_name] _[version]_ [args go here]
bundle _1.17.3_ install