BigDecimal#inspect for people who aren't cyborgs
I wonder if the guy that wrote BigDecimal#inspect has a tragic backstory that explains why he hates humanity.
- Tim Pope Show archive.org snapshot
I finally gave up and made BigDecimal#inspect
return BigDecimal#to_s
:
p BigDecimal.new('2.3') #=> "2.3"
Use the attached initializer.
Related cards:
If you aren’t embarrassed by v1.0 you didn’t release it early enough « Successful Software
I cringe every time I hear about someone who has spent years writing their ‘killer app’, but still hasn’t released it. My preferred approach is to get a solid, but minimally featured, v1.0 out there and then iterate like crazy based on real custom...
8 steps for fixing other people's code
Guide how to make fixes in other people's GitHub repositories. It's basically "Open Source Development 101".
Way back in mid-2007, when Rails 1.2 was the new hotness and GitHub was still a year away from crawling out of the primordial internet ...
Introduction to Google Tag Manager (for web developers who know Google Analytics)
As a web developer, you know Google Analytics (GA). Probably you've dropped the GA snippet into more than one website, maybe you've even used its Javascript API to implement tracking at the event level.
Google Tag Manager (GTM) is a related tool,...
Why you can't use timezone codes like "PST" or "BST" for Time objects
Rails' ActiveSupport::TimeWithZone
objects have both a timezone code and offset, e.g. Thu, 28 Mar 2019 16:00:00 CET +01:00
. Ruby's stdlib TZInfo
also has time zones, but with different identifiers.
Unfortunately, not all timezone codes can b...
Couldn't create database for ...
When you run rake db:create
and get this error message
`Couldn't create database for {"encoding"=>"utf8", "username"=>"root", "adapter"=>"mysql", "database"=>"project_development", "password"=>"topsecret"}, charset: utf8, collation: utf8_unicod...
Different behavior for BigDecimal#floor in Ruby 1.8 and Ruby 1.9
Ruby 1.8 (supplied by Rails' ActiveSupport)
>> BigDecimal.new("0.1").floor.class
=> BigDecimal
Ruby 1.9 (supplied by Ruby 1.9 itself)
>> BigDecimal.new("0.1").floor.class
=> Fixnum
In fact, Float#floor
has changed from [...
Whenever: Don't forget leading zeros for hours!
Whenever is a Ruby gem that provides a nicer syntax for writing and deploying cron jobs.
Leading zeros are important for whenever if you use the 24-hours format!
This schedule.rb
:
every 1.day, at: '3:00', roles: [:primary_cron] do
r...
I Can't Wait for NoSQL to Die - Ted Dziuba
They don't teach you this in college, but the fundamental theorem of the software industry is the idea that everything needs to be rewritten all the time. As a corollary, web startup engineers believe that there is no problem but scalability, an...
Don't ever use the float type for database columns
Like in any language, a FLOAT
will eventually corrupt data due to rounding errors.
Please use DECIMAL
, which has [well-defined behavior for rounding and range overflows](https://makandracards.com/makandra/1177-how-decimal-columns-deal-with-nu...
Fix for: "can't convert nil to String" when running "gem update --system"
When attempting to update RubyGems, depending on updates your previously performed, you might run into an error
ERROR: While executing gem ... (TypeError)
can't convert nil into String
Fix this by running
gem uninstall rubygems-upd...