Skip to content

Instantly share code, notes, and snippets.

View Joseworks's full-sized avatar

Jose C Fernandez Joseworks

View GitHub Profile
@Joseworks
Joseworks / README.md
Created February 12, 2024 14:53 — forked from jherax/README.md
Git Alias and Rebase

Git Alias and Git Rebase

WHEN TO DO REBASE

After each commit in our branch, in order to be up-to-date with the integration branch.

This is a tool to find association paths between different models in a rails app.

Example output - the paths from Job to Invoice:

[3] pry(main)> G.from(Job).to(Invoice)
Job.active_fleet_managed_invoice_from_swoop -- Invoice

Job.invoice >- Invoice

Job.owning_company >- Company.fleet_managed_clients -- FleetCompany.end_user_invoices -< Invoice
@Joseworks
Joseworks / .gitattributes
Created October 5, 2023 16:19 — forked from phil-blain/.gitattributes
Git pickaxe : show only relevant hunks (filter displayed hunks using the given search string)
*.md diff=markdown
@Joseworks
Joseworks / rspec-be-within-matcher.rb
Created September 13, 2023 20:27 — forked from equivalent/rspec-be-within-matcher.rb
Several examples how to use Ruby RSpec 3 `be_within` matcher for delta compare
require 'rspec'
require 'time'
require 'active_support/time'
class Foo
def float_range_example
33 * 5 * Math::PI
end
def time_range
@Joseworks
Joseworks / gist:29fe3336955174e0fc97249d3cf4202c
Created February 25, 2021 14:27 — forked from JFernandezWM/gist:d2e0e31afe8f9681612f05c578d94e01
Update to factory bot shell scripts for Mac that actually work...
find . -type f -name '*.rb' -exec sed -i '' s/FactoryGirl/FactoryBot/ {} +
find . -type f -name '*.rb' -exec sed -i '' s/factory_girl/factory_bot/ {} +
This:
from https://github.com/thoughtbot/factory_bot_rails/issues/247
grep -rl 'FactoryGirl' ./ | xargs sed -i '' 's/FactoryGirl/FactoryBot/g'
@Joseworks
Joseworks / ruby_on_rails_deployment.md
Created February 25, 2021 14:27 — forked from zentetsukenz/ruby_on_rails_deployment.md
Deploy Ruby on Rails application with Docker Compose and Capistrano with ease

Docker

Files and Folders.

|
|\_ app
|...
|\_ docker
| |
@Joseworks
Joseworks / GitCommitEmoji.md
Created February 25, 2021 14:26 — forked from parmentf/GitCommitEmoji.md
Git Commit message Emoji
@Joseworks
Joseworks / time_vs_datatime.md
Created February 25, 2021 14:25 — forked from pixeltrix/time_vs_datatime.md
When should you use DateTime and when should you use Time?

When should you use DateTime and when should you use Time?

It's a common misconception that [William Shakespeare][1] and [Miguel de Cervantes][2] died on the same day in history - so much so that UNESCO named April 23 as [World Book Day because of this fact][3]. However because England hadn't yet adopted [Gregorian Calendar Reform][4] (and wouldn't until [1752][5]) their deaths are actually 10 days apart. Since Ruby's Time class implements a [proleptic Gregorian calendar][6] and has no concept of calendar reform then there's no way to express this. This is where DateTime steps in:

>> shakespeare = DateTime.iso8601('1616-04-23', Date::ENGLAND)
=> Tue, 23 Apr 1616 00:00:00 +0000
>> cervantes = DateTime.iso8601('1616-04-23', Date::ITALY)
=> Sat, 23 Apr 1616 00:00:00 +0000
@Joseworks
Joseworks / notes.md
Created February 25, 2021 14:25 — forked from joakimk/notes.md
Building custom ruby images to use the latest versions (e.g. to get security fixes earlier)

Building custom ruby-alpine

Check the alpine version of the previous image.

alpine3.9 master$ docker run -it ruby:2.5.4-alpine sh
/ # cat /etc/alpine-release 
3.9.2
/ # ruby -v
ruby 2.5.4p155 (2019-03-13 revision 67245) [x86_64-linux-musl]
@Joseworks
Joseworks / fakeout.rb
Created February 25, 2021 14:25 — forked from matthutchinson/fakeout.rb
fake.rake - a takeout approach and rake task that generates some random fake data for a rails app (using ffaker)
# place this in lib/fakeout.rb
require 'ffaker'
module Fakeout
class Builder
FAKEABLE = %w(User Product)
attr_accessor :report