cheat-sheet articles are about code
snippets that I need every once in a while, and which I constantly forget
about.
The following query lists all tables within a MySQL instance along with their
row counts and sizes in MiB:
SELECT
table_schema as `database`,
table_name as `table`,
table_rows as `rows`,
ROUND(((data_length + index_length) / 1024 / 1024), 2) `size_mib`
FROM information_schema.tables
ORDER BY (data_length + index_length) DESC;
If you happen to have two remotes for your git repository—e.g. one at GitHub
and one on a private server—you might want to git push
your changes to both
remotes at once.
To achieve this, you can leverage Git’s ability to have multiple push URLs for
a remote. Create a new remote, e.g. named all
, and set both remotes’ URLs
as push URLs:
git remote add all <remote_url1>
git remote set-url all --add --push <remote_url1>
git remote set-url all --add --push <remote_url2>
Pushing the master branch to both remotes is now as easy as running:
Note: of course you could just set both remote URLs as push URLs for origin
.
However, by creating a new remote for this purpose, you can still push to any
remote separately if you want.
The following Sass function converts pixels to rem:
@function px-rem($size, $base: 16px) {
@if (unitless($size)) {
$size: $size * 1px;
}
@if (unitless($base)) {
$base: $base * 1px;
}
@return 1rem * ($size / $base);
}
The $size
argument can be provided either with or without a px
unit, for
example:
font-size: px-rem(18px); /* 1.125rem */
line-height: px-rem(24); /* 1.5rem */
You can provide a second argument to px-rem()
if your base font size is not
16 pixels.