Skip to content

Instantly share code, notes, and snippets.

View leonardobrito's full-sized avatar
👨‍💻
Ruby on Rails

Leonardo Brito leonardobrito

👨‍💻
Ruby on Rails
View GitHub Profile
@leonardobrito
leonardobrito / flipping_matrix.rb
Created December 1, 2024 15:35
flipping_matrix
# https://www.youtube.com/watch?v=4rin1enhuQQ
def flippling_matrix(matrix)
n = matrix.size
sum = 0
(0...n / 2).each do |i|
(0...n / 2).each do |j|
puts "[#{i}][#{j}] => [#{i}][#{n - j - 1}] => [#{n - i - 1}][#{j}] => [#{n - i - 1}][#{n - j - 1}]"
sum += [matrix[i][j], matrix[i][n - j - 1], matrix[n - i - 1][j], matrix[n - i - 1][n - j - 1]].max
select distinct city from station where id % 2 = 0; // even
select distinct city from station where mod(id, 2) = 0; // even
select distinct city from station where id % 2 <> 0; // odd
// City Min and Max length alfabeticaly ordered.
select city, LENGTH(city) from station
where LENGTH(city) = (select MIN(LENGTH(city)) from station)
order by city limit 1;
select city, LENGTH(city) from station
where LENGTH(city) = (select MAX(LENGTH(city)) from station)
# frozen_string_literal: true
require 'bigdecimal/util'
# == testing lib ==
class UnitTest
def self.call
tests = public_instance_methods.select do |method|
method.to_s.start_with?('test_')
end
#config/environments/development.rb
config.action_mailer.asset_host = 'http://localhost:3000'
config.action_mailer.delivery_method = :resend
config.action_mailer.resend_settings = {
api_key: 're_SECRET_HERE',
}
#app/mailers/user_mailer.rb
class UserMailer < ApplicationMailer
default from: 'onboarding@resend.dev'
@leonardobrito
leonardobrito / settings.json
Last active May 10, 2022 15:55
Vscode configs
{
"editor.bracketPairColorization.enabled": true,
"editor.guides.bracketPairs": "active",
"editor.fontLigatures": true,
"editor.formatOnSave": true,
"editor.formatOnPaste": true,
"editor.formatOnType": true,
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true,
"source.organizeImports": true
@leonardobrito
leonardobrito / jest.config.js
Created June 19, 2020 05:53
jest config to vuejs
module.exports = {
moduleFileExtensions: [
'js',
'jsx',
'json',
'vue',
],
transform: {
'^.+\\.vue$': 'vue-jest',
'.+\\.(css|styl|less|sass|scss|svg|png|jpg|ttf|woff|woff2)$': 'jest-transform-stub',