Get color in the Capistrano output
Note: capistrano_colors
was merged into Capistrano starting from v2.13.5. However, this requires Ruby 1.9+.
If you cannot upgrade Capistrano to 2.13.5+ (e.g. because you're still running on Ruby 1.8), simply put capistrano_colors
into your Gemfile and require 'capistrano_colors'
in your config/deploy.rb
file.
Related cards:
Whenever requires you to set the application attribute in the Capistrano config
Whenever requires you to set the application
attribute in your Capistrano configuration. Otherwise your cronjobs are created multiple ti...
Using the Oklch color space to generate an accessible color palette
The linked content describes:
- The different color space of Oklch and RGB/HSL (HDR colors)
- The advantage of Oklch when you change a base color and your derived colors will keep the same assertions on contrast level
Warning
This feature ...
How to get a backtrace if rspec (or any other ruby process) hangs with no output
If rspec hangs with no output and you dont get a backtrace neither with --backtrace
nor by just killing it with crtl-c,
you can put the following in your spec/spec_helper.rb
:
puts "rspec pid: #{Process.pid}"
trap 'USR1' do
thread...
CSS: Using the current text color for other color properties
There is a kinda secret, yet well supported CSS feature called currentColor
. It's like a special CSS variable that has been supported in almost all browsers for almost all time (see linked Caniuse).
Usage
The currentColor
value can be us...
Sass: Use black or white foreground color depending on the lightness of the background
This article shows how to create a Sass mixin for a colored button. The button's foreground color is dynamically chosen between either black or white, depending on the given background color.
It's a nice intro into @if
and @else
conditionals ...
How to make Capistrano not truncate server output
By default, Capistrano truncates server responses and places an ellipsis at the end of lines that are longer than your terminal. Error messages are never truncated.
While this can be helpful to make deployment output appear less noisy, it also hi...
How to get the hostname of the current machine in Rails or a Ruby script
Use Socket.gethostname
. So for a machine whose hostname is "happycat", it will look like this:
>> Socket.gethostname
=> "happycat"
That should work right away for your Rails application. For plain Ruby, you first need to do:
requi...
Output the descriptions of RSpec examples while they are running
In order to
- track down warnings and to see failing specs immediately
- or to get an overview of the core functionalities,
you can use RSpec's "nested" format. It looks like this:
Tool
validations
should require model to be ...
How to use the Capistrano 2 shell to execute commands on servers
Capistrano 2 brings the shell
command which allows you to run commands on your deployment targets.
There is also invoke
to run a command directly from your terminal.
Both commands allow running Capistrano tasks or shell commands, and scope to...