You can find great stock photos on pexels.com.
All pictures are free for personal and commercial use without attribution, and may be modified.
A check if two date or time ranges A and B overlap needs to cover a lot of cases:
One trick to cover all these cases with a single expression is to see if the start date of each range is looking at the end date of the other range in the same direction.
The code below shows how to implement this in Ruby on Rails. The example is a class
Interval, which has two attributes
#end_date. These dates are considere…
We have released a new library Gemika to help test a gem against multiple versions of Ruby, gem dependencies and database types.
Here's what Gemika can give your test's development setup (all features are opt-in):
Added details about the two distinct argument patterns of
# Works system 'bundle exec rails server' system 'bundle', 'exec', 'rails', 'server' # Fails system 'bundle exec', 'rails server' system 'bundle', 'exec rails server'
Good article about what "gamma correction" means for color processing, and what "sRGB" actually means.
You probably do not need to know this for web development, but it's an interesting read.
With the the ruby Tempfile class you can create temporary files. Those files only stick around as long as you have a reference to those. If no more variable points to them, the GC may finalize the object at some point and the file will be removed from the filesystem. If you would try to access your tempfile then using its path (which you stored previously), you would get an error because the file no longer exists.
Unlink your tempfiles when you're done with them
A gem is activated if it is either in the current bundle (
Gemfile.lock), or if you have manually activated it using
To detect if e.g.
activerecord has been activated:
if Gem.loaded_specs.has_key?('activerecord') # ActiveRecord was activated end
To detect if e.g.
To get your
F12 key back for other shortcuts:
killall tilda sudo apt-get remove tilda
This error can be caused by the mysql2 gem under mysterious circumstances. You need to remove it with
gem uninstall mysql2 and then reinstall it (or just run
gem pristine mysql2 will not be enough.
Same requests are recorded only once in vcr. Replaying a test fails, if you trigger the same request multiple times. The error message is somehow confusing, as your cassette contains the request:
An HTTP request has been made that VCR does not know how to handle
If you want to allow to match a request multiple times, you need to configure this explicit with allow_playback_repeats: true. Some example configurations:
# specific ca…
Rails 5 migration classes look like this now:
class CreateUsers < ActiveRecord::Migration[5.0]
[5.0] at the end.
They do this to evolve the ActiveRecord::Migration API without breaking your historical migrations in
tl;dr: Most often you want to use \A and \z. Take care of using ^ and $!
^ Start of line
$ End of line
\A Start of string
\z End of string
!!("image/jpeg" =~ /\Aimage\/(jpeg|png)\z/) => true
!!("image/png" =~ /\Aimage\/(jpeg|png)\z/) => true
This is a reminder that you can easily upgrade your Rails 3+ project to RSpec 3.3+.
You can configure RSpec 3.3+ to raise an error when stubbing a non-existing method (disabled by default). This might reveal some bugs in your tests for little to no cost.
You can enable this behavior by adding the following to your
RSpec.configure do |config| config.mock_with :rspec do |mocks| mocks.verify_partial_doubles = true end end
Say you have an RGBA color that you need as a non-transparent color because of reasons.
Basically, this is possible. Just understand that you will convert your RGBA color for exactly one base background color as you are giving up transparency.
Most likely, your background is white, so you'll use
#fff as that base for examples below.
When your know the RGBA color's base RGB color (e.g. your brand color that you RGBA'd for some hover effect), you can simply use the
mix function instead of
I've encountered a Ubuntu 16.04 today, where
localhost resolved to
::1 instead of
This will not usually make a difference, but could be relevant for firewall policies.