hyphens: auto
, as it is now supported in most Browsers.Modern browsers are able to hyphenate natively with the CSS property hyphens
:
hyphens: auto
There is also hyphens: none
(disable hyphenations even at ­
entities) and hyphens: manual
(hyphenation at ­
only).
Th...
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
runner 'Scheduler.delay.do_things'
end
will lead to this crontab entry (crontab -l
):
0 15 * * * /bin/bash -l -c 'cd /var/www/my-project/releases/20180607182518 && bin/rails runner -e production '\''Scheduler.delay.do_things'\'''
Which would run on 3pm instead of 3am.
Using the l...
In a nutshell: Use git rebase source-commit --onto target-branch
target-branch
means "branch you want to be based on"source-commit
means "commit before your first feature commit"Let's say my-feature-branch
is based on master
and we want it to be based on production
. Consider this history (topmost = latest):
Here, master
has commits that are not yet in production
(number 3 and 4).
J...
First find the reference for the entry you want through looking at the stash:
$ git stash list
stash@{0}: WIP on feature/foo
stash@{1}: WIP on feature/bar
stash@{2}: WIP on fix/baz
Now you can simply use that reference, but curly braces must be escaped:
git stash pop stash@\{1\}
or quoted:
git stash apply "stash@{1}"
Recently I made an upgrade from Bootstrap 3 to Bootstrap 4 in a bigger project. Here are some tips how to plan and perform such an upgrade. The effort will scale with the size of the project and its structure. If your stylesheets already follow strict rules, it may take less time to adapt them to the new version.
There are several gems and libraries that works well with bootstrap or provide at least stylesheets/plugins to easily integrate the bootstrap theme. But very often they only work with specific version or are no long...
Geordi 5.3.0 was released.
tmp/
but delete it once the operation finishes successfully. Example: geordi dump staging -l
will remove the file tmp/staging.dump
after it loaded the dump.It is very hard to write your CSS so that all components can be combined in any layout and still retain collapsing margins.
For these situations, have some utility classes that remove the top or bottom margins, like .no-top-margin
. When two margins don't collapse for some reason, you can apply the utility class to the component with the smaller margin.
In Bootstrap these classes are .mt-0
(remove top margin) or .mb-0
(rem...
Consider the following models and form models:
class Parent < ApplicationRecord
has_many :children, class_name: 'Child', foreign_key: 'parent_id'
end
class Parent::AsForm < ActiveType::Record[Parent]
change_association :children, class_name: 'Child::AsForm', foreign_key: 'parent_id', autosave: true, inverse_of: :parent
accepts_nested_attributes_for :children
validates_associated :children
end
class Child < ApplicationRecord
belongs_to :parent, inverse_of: :children
end
class Child::AsForm < ActiveType::Reco...
When running an older version of docker-compose
you might see the following error:
ERROR: Version in "./docker-compose.yml" is unsupported. You might be seeing this error because you're using the wrong Compose file version. Either specify a supported version (e.g "2.2" or "3.3") and place your service definitions under the `services` key, or omit the `version` key and place your service definitions at the root of the file to use version 1.
For more on the Compose file format versions, see https://docs.docker.com/compose/compose-file/
...
By default, your terminal emulator (Gnome Terminal, Terminator, etc.) sets some kind of window title to reflect the shell type you are running (e.g. /bin/bash
).
This is most often not too helpful, but you can change that from your shell.
To set a specific title, print an escape sequence like this:
echo -en "\033]0;Hello\a"
You can easily include the current path:
echo -en "\033]0;$(pwd)\a"
Or, to replace your home directory's part with a tilde:
echo -en "\033]0;$(pwd | sed -e "s;^$HOME;~;")\a"
Or,...
You can use .ids
on an ActiveRecord 4+ scope to pluck all the ids of the relation
User.where("users.name LIKE 'Foo Bar'").ids
# same as (since Rails 3.2)
User.where("users.name LIKE 'Foo Bar'").pluck(:id)
If you are stuck on Rails 2.3 you can use Edge Rider's collect_ids
:
User.where("users.name LIKE 'Foo Bar'").collect_ids(:id)
process
definitions are only applied to the original filebefore
/after
) are applied to original file and each version by itself#version_name
: version uploaders return the version name, whereas the original uploader instance returns nil
To return non-HTML responses (like XLS spreadsheets), we usually use the
respond_to do |format|
format.xls do
# send spreadsheet
end
end
This is often, but not always the same as checking for params[:format] == :xls
, so don't rely on this when e.g. one format checks for authorization and the other doesn't.
params[:format]
is only set when a user explicitly puts a .xls
at the end of the URL.
The format.xls
block also responds when the user's browser requests the application/excel
MIME type.
If Intern...
Rails 6 includes a WYSIWYG editor, Action Text. It works out of the box quite well, but chances are that you want to add some custom functionality. This card contains some tips how to achieve this.
Basically, follow the guide in the Rails documentation. The automated script may not work with the way webpacker is configured in your project, but it should be easy to fix.
If you don't want the default c...
PostgreSQL has partial indexes. With a partial index you tell Postgres to only index rows matching a given query.
Some uses cases for a partial index:
The linked article shows how to create a partial index with Rails.
There are several tools for DNS debugging which offer you more or less information. Most of the time the more simple ones, like host
oder nslookup
will be sufficient.
host
simple DNS lookup utility.
>host heise.de
heise.de has address 193.99.144.80
heise.de has IPv6 address 2a02:2e0:3fe:1001:302::
heise.de mail is handled by 10 relay.heise.de.
nslookup
query Internet domain name servers. Nslookup has two modes: interactive and non-interactive.
>nslookup heise.de
Server: 146.254.160.30
Address: 146.254.160.3...
I just ran into this deployment error after switching from the asset pipeline to webpack:
01:05 deploy:assets:precompile
01 bundle exec rake assets:precompile
01 Compiling...
01 Compilation failed:
01 yarn run v1.22.5
01 error Command "webpack" not found.
rake stderr: Nothing written
The problem is not related to the "webpack" dependency. You probably just forgot to add a binstub to run "yarn install":
Add these lines to "bin/ya...
A well-written API can be a great asset to the organization that wrote it and to all that use it. Given the importance of good API design, surprisingly little has been written on the subject. In this talk (recorded at Javapolis), Java library designer Joshua Bloch teaches how to design good APIs, with many examples of what good and bad APIs look like.