Skip to content

Instantly share code, notes, and snippets.

Avatar
:octocat:
Open source for humanity!

Vitor Oliveira vbrazo

:octocat:
Open source for humanity!
View GitHub Profile
View zigzap.py
# =begin
# # Given a Balanced Binary Tree (BBT)
# # (non-sorted, non-search, containing unique elements)
# 42
# / \
# / \
# / \
# / \
# 81 99
@vbrazo
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]
end
View .travis.yml
env:
sudo: false
language: ruby
cache: bundler
rvm:
- 2.5.1
script: bundle exec rspec
matrix:
allow_failures:
- rvm: ruby-head
View .rubocop.yml
AllCops:
TargetRubyVersion: 2.3
Lint/AmbiguousBlockAssociation:
Description: This cop checks for ambiguous block association with method when param passed without parentheses.
Enabled: false
Lint/UnifiedInteger:
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
# config.ru
require './application/api'
use RackAuthMiddleware
run Rack::Cascade.new [ApiSupport]
# application/middlewares/rack_auth_middleware.rb
class RackAuthMiddleware
UnprocessableHeader = Class.new(ArgumentError)
@vbrazo
vbrazo / Faraday.md
Last active Aug 27, 2018 — forked from hemanth/Faraday.md
HTTP client library is so convenient Faraday of Ruby
View Faraday.md

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
AllCops:
DisplayCopNames: true
Exclude:
- 'bin/*'
- 'config.ru'
- 'config/environments/*'
- 'config/initializers/*'
- 'db/**/*'
- 'vendor/**/*'
- Gemfile
@vbrazo
vbrazo / leap_year_coding_task.md
Last active Jan 4, 2018
Leap Year Algorithm Exam
View leap_year_coding_task.md

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.