Skip to content

Instantly share code, notes, and snippets.

View anchietajunior's full-sized avatar
💭
Working Hard

José Anchieta anchietajunior

💭
Working Hard
View GitHub Profile
@anchietajunior
anchietajunior / distances.rb
Created May 23, 2020 20:03
Implementation
def distance_between_locations(locations)
def distance(location_one, location_two)
rad_per_deg = Math::PI/180
radius_in_meters = 6371 * 1000
dlat_rad = (location_two[0]-location_one[0]) * rad_per_deg
dlon_rad = (location_two[1]-location_one[1]) * rad_per_deg
@anchietajunior
anchietajunior / miojo.rb
Last active May 23, 2020 19:59
Implementation and CLI
puts "Type the cooking time: "
cooking_time = gets.chomp.to_i
puts "Type the first hourglass time: "
hour_glass_one = gets.chomp.to_i
puts "Type the second hourglass time: "
hour_glass_two = gets.chomp.to_i
def calculate_minimum_time(cooking_time, hour_glass_one, hour_glass_two)
minimum_time = 0
=begin
Write some code, that will flatten an array of arbitrarily
nested arrays of integers into a flat array of integers.
e.g. [[1,2,[3]],4] -> [1,2,3,4].
Your solution should be a link to a gist on gist.github.com
with your implementation.
When writing this code, you can use any language you're
comfortable with. The code must be well tested and documented.
@anchietajunior
anchietajunior / pull_request.md
Last active February 12, 2020 16:10
This is a PR template

Pull Request Description

This PR aims to do something (detailed description).

Type (Feature, Fix, Config, etc)

  • Bug fix
  • New feature
  • Breaking change
  • This change requires a documentation update
default: &default
adapter: postgresql
encoding: unicode
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
development:
<<: *default
database: your_database_development
host: localhost
username: postgres
# Each
arr = ["Luke", "Leia", "Vader"]
arr.each do |name|
p name
end
# Times
name = "Mary"
3.times do
prefix = "My name is"
name = "John"
p "#{prefix} #{name}"
end
name = "Mary"
3.times do
prefix = "My name is"
p "#{prefix} #{name}"
end
@anchietajunior
anchietajunior / initrepo.shell
Created October 31, 2019 12:44
Init a new repo
git init
git add .
git commit -m "First commit"
class Subscription
def initialize(user)
@user = user
end
def call
create_payment!
create_invoice!
rescue StandardError => e
puts e.message