Heads up: "localhost" may be IPv6 on new linuxes
I've encountered a Ubuntu 16.04 today, where localhost
resolved to ::1
instead of 127.0.0.1
.
This will not usually make a difference, but could be relevant for firewall policies.
Related cards:
Heads up: counting may be slow in PostgreSQL
The linked article points out that COUNT
queries might be unexpectedly slow in PostgreSQL.
If you just need to know "are there any records" use any?
. This uses SELECT 1 AS one FROM ... LIMIT 1
under the hood.
If you just need to know "...
Heads up: RSpec's diffs may not tell the truth
RSpec provides a nice diff when certain matchers fail.
Here is an example where this diff is helpful while comparing two hashes:
{a:1}.should match(a:1, b:2)
Failure/Error: {a:1}.should match(a:1, b:2)
expected {:a=>1} to match {:a=>1, :b...
Working on the Linux command line: How to efficiently navigate up
With cd ..
you can navigate one directory up from the one you are at now. If you use that a lot, consider some handy aliases.
Add the following lines to your ~/.bashrc
:
alias ..="cd .."
alias ...="cd ../.."
alias ....="cd ../../.."
alias ...
Heads up: Angular may break links to the current URL (e.g. when using ngInclude)
Angular's location provider stalls links to the current URL, i.e. window.location. As soon as the $location service is activated in an Angular app, it will intercept links. The click event handler is registered in $LocationProvider.$get()
.
The...
Thinkpad: Disable Bluetooth on start-up
Add the following to /etc/rc.local:
(sleep 3 && echo disable > /proc/acpi/ibm/bluetooth)&
Bluetooth icon will be active for a few seconds, then turn gray.
How to find out what is running on a port on a remote machine
By convention, common protocols use a defined port, like 80 for HTTP or 443 for HTTPS.
You can use nmap
to find out what service is running behind a given port, and most often see some details about it. This can be helpful if servers don't offe...
Events triggered by jQuery cannot be observed by native event listeners
jQuery has a function $.fn.trigger()
. You can use it to dispatch an event on a jQuery object:
let $element = $('.foo')
$element.trigger('change')
A caveat is that such an event will be received by jQuery event listeners, but ...
will_paginate on complex scopes may be slow (workaround)
will_paginate
triggers a database query to determine the total number of entries (i.e. to let you display the number of search results). When you paginate complex scope (e.g. that has many include
s),...
Using multiple MySQL versions on the same linux machine using docker
We had a card that described how to install multiple mysql versions using mysql-sandbox
. Nowadays with the wide adoption of docker it might be easier to u...
Heads up: Ruby implicitly converts a hash to keyword arguments
When a method has keyword arguments, Ruby offers implicit conversion of a Hash
argument into keyword arguments. This conversion is perfo...