Skip to content

Instantly share code, notes, and snippets.

View maricris-sn's full-sized avatar
😺

Maricris Nonato maricris-sn

😺
View GitHub Profile
@maricris-sn
maricris-sn / dates_to_time.rb
Created February 28, 2019 07:03
Dates To Time
def dates_to_time(date_string, created_at)
if date_string[/[0-9]+/].blank?
# there aren't any numbers in it
return 0
else
# there's at least one number to derive date from
if date_string[/\'(\d){2}/].present?
# uses Month '14 for example
matched_year = date_string[/\'(\d){2}/]
# extrapolate the decade from when this record was created
@maricris-sn
maricris-sn / database_cleaner.rb
Created November 12, 2020 13:26 — forked from jsteiner/database_cleaner.rb
Database Cleaner
RSpec.configure do |config|
config.before(:suite) do
DatabaseCleaner.clean_with(:truncation)
end
config.before(:each) do
DatabaseCleaner.strategy = :transaction
end
config.before(:each, js: true) do
@maricris-sn
maricris-sn / the % notation in ruby.md
Created February 18, 2025 14:18 — forked from jakimowicz/the % notation in ruby.md
%Q, %q, %W, %w, %x, %r, %s, %I, %i

%Q, %q, %W, %w, %x, %r, %s, %i

Perl-inspired notation to quote strings: by using % (percent character) and specifying a delimiting character.

Any single non-alpha-numeric character can be used as the delimiter, %[including these], %?or these?, %~or even these things~.

Strings

% or %Q