Skip to content

Instantly share code, notes, and snippets.

View vbrazo's full-sized avatar
Open source for humanity!

Vitor Oliveira vbrazo

Open source for humanity!
View GitHub Profile
vbrazo / stripe_integration.rb
Created April 26, 2023 04:18
Ruby Stripe Integration
# Set new Stripe API token
Stripe.api_key = 'sk_test_token'
# create new account
account = Stripe::Account.create({type: 'standard'})
# generate link for user to associate account
account_id = Stripe::AccountLink.create({
refresh_url: '',
# =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 August 24, 2019 18:34
How to rotate a matrix 90 degrees in Ruby
# 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]
sudo: false
language: ruby
cache: bundler
- 2.5.1
script: bundle exec rspec
- rvm: ruby-head
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
## 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
require './application/api'
use RackAuthMiddleware
run [ApiSupport]
# application/middlewares/rack_auth_middleware.rb
class RackAuthMiddleware
UnprocessableHeader =
vbrazo /
Last active August 27, 2018 23:47 — 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

DisplayCopNames: true
- 'bin/*'
- ''
- 'config/environments/*'
- 'config/initializers/*'
- 'db/**/*'
- 'vendor/**/*'
- Gemfile
vbrazo /
Last active January 4, 2018 17:19
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.