Skip to content

Instantly share code, notes, and snippets.

View prathe's full-sized avatar

Philippe Rathé prathe

  • Remote, North America
View GitHub Profile
2.hours.ago # => Fri, 02 Mar 2012 20:04:47 JST +09:00
1.day.from_now # => Fri, 03 Mar 2012 22:04:47 JST +09:00
Date.today.to_time_in_current_zone # => Fri, 02 Mar 2012 22:04:47 JST +09:00
Date.current # => Fri, 02 Mar
Time.zone.parse("2012-03-02 16:05:37") # => Fri, 02 Mar 2012 16:05:37 JST +09:00
Time.zone.now # => Fri, 02 Mar 2012 22:04:47 JST +09:00
Time.current # Same thing but shorter. (Thank you Lukas Sarnacki pointing this out.)
Time.zone.today # If you really can't have a Time or DateTime for some reason
Time.zone.now.utc.iso8601 # When supliyng an API (you can actually skip .zone here, but I find it better to always use it, than miss it when it's needed)
Time.strptime(time_string, '%Y-%m-%dT%H:%M:%S%z').in_time_zone(Time.zone) # If you can't use Time#parse
@prathe
prathe / gitdo.zsh
Last active August 31, 2023 20:27
Git Rspec/Rubocop commands
bundle exec rubocop -c .rubocop_exclusion.yml --fail_level convention --display-only-fail-level-offenses
# Rubocop only files I modified/added, but not the one I deleted
git diff develop... --diff-filter=d --name-only | egrep "\\.rb$" |xargs bundle exec rubocop
git diff develop... --diff-filter=d --name-only | egrep "\\.rb$" |egrep -v db/schema.rb | xargs bundle exec rubocop
git diff develop... --diff-filter=d --name-only | egrep "\\.rb$" |egrep -v db/schema.rb | xargs bundle exec rubocop --fail_level convention --display-only-fail-level-offenses
git diff develop... --diff-filter=d --name-only | egrep "\\.rb$" |egrep -v db/schema.rb | xargs bundle exec rubocop -c .rubocop_exclusion.yml --fail_level convention --display-only-fail-level-offenses
git diff develop... --diff-filter=d --name-only | egrep "\\.rb$" |egrep -v db/schema.rb | xargs bundle exec rubocop -A -c .rubocop_exclusion.yml --fail_level convention
git diff --name-
# -A the staged