Skip to content

Instantly share code, notes, and snippets.

View linqueta's full-sized avatar
🏠
Working from home

Lincoln Rodrigues linqueta

🏠
Working from home
View GitHub Profile
@linqueta
linqueta / enriching_results.ex
Last active June 25, 2024 20:25
Rematch Scripts
defmodule RematchEnrichingResults do
alias HGForce.Schemas.Integration
alias HGForce.Repo
alias HGForce.Schemas.IntegrationOAuthToken
alias SFDCEx.RestAPI
import Ecto.Query
def call(data_category, integration_ids) do
@linqueta
linqueta / color.rb
Created February 2, 2020 22:10
Dummy - Testing
# spec/dummy/app/models/color.rb
class Color < ActiveRecord::Base
def hex
MyGem.rgb_to_hex(red, green, blue)
end
end
@linqueta
linqueta / spec_helper.rb
Created February 2, 2020 22:09
Dummy - Setting spec helper
# spec/spec_helper.rb
# ...
require File.expand_path('../spec/dummy/config/environment.rb', __dir__)
ENV['RAILS_ROOT'] ||= File.dirname(__FILE__) + '../../../spec/dummy'
require 'rspec/rails'
# ...
@linqueta
linqueta / my-gem.gemspec
Created February 2, 2020 22:08
Dummy - adding rspec rails
# my-gem.gemspec
# ...
Gem::Specification.new do |spec|
# ...
spec.add_development_dependency 'rspec-rails'
end
@linqueta
linqueta / application.rb
Created February 2, 2020 22:07
Dummy - Requiring gem
# spec/dummy/config/application.rb
# ...
require 'my-gem'
module Dummy
class Application < Rails::Application
# ...
array = [[0, 1], [2, 3]]
array.each { puts "_1: #{_1}, _2: #{_2}" }
# _1: 0, _2: 1
# _1: 2, _2: 3
# => [[0, 1], [2, 3]]
array.map { |even, odd| [even, odd].sum { _1 } }
# => [1, 5]
array.map { [_1, _2].sum { _1 } }
SaleLineItem.all
.map { [mult_it!(_1), add_it!(_1)] }
.map { _1 + _2 }
SaleLineItem.all
.map { |s| [mult_it!(s), add_it!(s)] }
.map { |m, a| m + a }
SaleLineItem.all
.map { |sli| [mult_it!(sli), add_it!(sli)] }
.map { |msli, asli| msli + asli }
@linqueta
linqueta / extensive.rb
Last active January 19, 2020 23:37
NP1
SaleLineItem.all
.map { |sale_line_item| [mult_it!(sale_line_item), add_it!(sale_line_item)] }
.map { |multiplied_sale_line_item, added_sale_line_item| multiplied_sale_line_item + added_sale_line_item }