Skip to content

Instantly share code, notes, and snippets.

View leandronsp's full-sized avatar

Leandro Proença leandronsp

  • Brazil
View GitHub Profile
@leandronsp
leandronsp / README.md
Last active June 9, 2021 12:11
[Challenge 001] Create a simple Login form (no action required)

Login form

Implement a simple web page containing a login form, composed by the following form elements:

  • Email text field
  • Password field
  • "Login" button

Requirements:

@leandronsp
leandronsp / Vagrant
Created August 9, 2021 12:01
Vagrant
# -*- mode: ruby -*-
# vi: set ft=ruby :
projects = %w[
project-1
project-2
etcetc
]
Vagrant.configure("2") do |config|
@leandronsp
leandronsp / package.yaml
Created August 10, 2021 00:57
Minimal Haskell project using Stack
name: my-project
library:
source-dirs:
- app
- src
- lib
dependencies:
- base >= 4.7 && < 5
- ...
@leandronsp
leandronsp / README.md
Last active September 13, 2021 22:59
Callable pattern in Ruby

Usage

repository = UsersRepository.new

Registration.call(repository, "[email protected]", "pass")
@leandronsp
leandronsp / 001-main.rb
Last active August 3, 2022 03:57
OOP in Ruby without classes
leandro = new_instance(Account, "Leandro", 0)
john = new_instance(Account, "John", 100)
send_message(leandro, :deposit, 50)
send_message(john, :deposit, 10)
send_message(leandro, :print_balance)
# => Leandro's balance: 50
send_message(john, :print_balance)
@leandronsp
leandronsp / Pulumi.dev.yaml
Last active October 23, 2021 22:06
Provisioning a Kubernetes cluster on GKE using Pulumi
config:
gcp:project: "my-project-created-on-gcp"
@leandronsp
leandronsp / README.md
Created October 23, 2021 22:22
NGINX on Kubernetes

Create the pod on the cluster

kubectl apply -f nginx-pod.yaml
@leandronsp
leandronsp / sum_range.rb
Created December 4, 2021 15:30
Sum all numbers in a consecutive range
require 'benchmark'
def sum_range_using_for_loop(min, max)
range = (min..max)
sum = 0
for n in range
sum = sum + n
end
@leandronsp
leandronsp / main.rb
Created December 4, 2021 21:50
How to reduce time complexity of nested loops
require 'faker'
require 'benchmark'
def generate_groups
(1..1_000).map do |id|
{ id: id, name: Faker::Educator.primary_school }
end
end
def generate_users(groups_ids)
@leandronsp
leandronsp / benchmark-web-concurrency
Last active December 23, 2021 18:05
Ruby web server - concurrency benchmark
ab -n 20 -c 5
Req per seconds Time per req (ms)
Threads – IO 232 21
Fibers – IO 450 11
Threads – External Req 1.85 2703
Fibers – External Req 7.97 627