Skip to content

Instantly share code, notes, and snippets.

Open source for humanity!

Vitor Oliveira vbrazo

Open source for humanity!
View GitHub Profile
# =begin
# # Given a Balanced Binary Tree (BBT)
# # (non-sorted, non-search, containing unique elements)
# 42
# / \
# / \
# / \
# / \
# 81 99
vbrazo / rotate_a_matrix_90_degrees.rb
Last active Aug 24, 2019
How to rotate a matrix 90 degrees in Ruby
View rotate_a_matrix_90_degrees.rb
# Transpose a matrix
# Make [[1,2,3], [4,5,6], [7,8,9]] becomes [[1,4,7], [2,5,8], [3,6,9]]
class Array
def my_transpose
size.times do |i|
0.upto(i) do |j|
self[i][j], self[j][i] = self[j][i], self[i][j]
View .travis.yml
sudo: false
language: ruby
cache: bundler
- 2.5.1
script: bundle exec rspec
- rvm: ruby-head
View .rubocop.yml
TargetRubyVersion: 2.3
Description: This cop checks for ambiguous block association with method when param passed without parentheses.
Enabled: false
Description: This cop checks for using Fixnum or Bignum constant.
Enabled: false
View gist:ef26e442d2573c481436461910193b90
## Hints & what we're looking for
* We're more **interested in the process** than in the final result. You
probably won't finish the whole task in the given time.
* You are free to **use anything you use in your daily work**, including
websites like Google or StackOverflow.
* You can use any language or tool you want, but we recommend that you use the
language you feel most comfortable with and keep it super simple.
**You don't need a database or framework**, a simple command line script that
computes the values and prints them to the console is just fine for us. You
View rack_auth_middleware.rb
require './application/api'
use RackAuthMiddleware
run [ApiSupport]
# application/middlewares/rack_auth_middleware.rb
class RackAuthMiddleware
UnprocessableHeader =
vbrazo /
Last active Aug 27, 2018 — forked from hemanth/
HTTP client library is so convenient Faraday of Ruby

HTTP client library is so convenient Faraday of Ruby

Faraday's so convenient Ruby HTTP client library

The development of the API wrapper [RestClient gem] or I [rest_client_gem]
What you need for OAuth was using [Net / HTTP] [net_http] + [OAuth gem] the [oauth_gem]

After reading the source of the API library [Twitter gem] and [twitter_gem] [Instagram gem] such as [instagram_gem]
Thing [Faraday gem] that [faraday_gem] had been commonly used

View .rubocop.yml
DisplayCopNames: true
- 'bin/*'
- ''
- 'config/environments/*'
- 'config/initializers/*'
- 'db/**/*'
- 'vendor/**/*'
- Gemfile
vbrazo /
Last active Jan 4, 2018
Leap Year Algorithm Exam

Given a year, report if it is a leap year.

The tricky thing here is that a leap year in the Gregorian calendar occurs:

  • on every year that is evenly divisible by 4
  • except every year that is evenly divisible by 100
  • unless the year is also evenly divisible by 400

For example, 1997 is not a leap year, but 1996 is. 1900 is not a leap year, but 2000 is.