#12345 { /* Doesn't work! */ }
[id="12345"] { /* Does work! */ }
#\31 2345 { /* Works as well. */ }
Taken from this CSS-Tricks article.
In some cases, iOS devices will not display video thumbnails. To fix this, add #t=0.001
to src
, for example:
<video src="video.mp4#t=0.001"></video>
Thanks to Stanko Tadić.
<link rel="stylesheet" href="light.css" media="(prefers-color-scheme: light)">
<link rel="stylesheet" href="dark.css" media="(prefers-color-scheme: dark)">
This is not supported by IE and other lesser known browsers.
const start = 0;
const end = 5;
for (i = start; i < end; i++) {
setTimeout(() => {
console.log(i); // -> 5, 5, 5, 5, 5
});
};
function forSync(i) {
setTimeout(() => {
console.log(i); // -> 0, 1, 2, 3, 4
if (i + 1 < end) forSync(i + 1);
});
};
forSync(start);
This allows for asynchronous functions by placing the callback within that function.
Instead of:
await x.map(async y => y);
Do:
await Promise.all(x.map(async y => y));
const path = require("path");
const fs = require("fs");
process.env.PATH.split(path.delimiter).some(x => fs.existsSync(path.join(x, "node")));
const http = require("http");
http.createServer((req, res) => {
res.writeHead(204);
res.end();
}).listen(80);
Or, as a minified version:
require("http").createServer((q,s)=>s.writeHead(204).end()).listen(80)
input.split(":").reduce((p, c) => p * 60 + Number(c));
// 1 -> 1
// 1:00 -> 60
// 1:00:00 -> 3600
$(".collapsed[data-target='" + window.location.hash + "']")?.click();
Did I mention that optional chaining absolutely rocks?
const module = require("./module");
module("Hello!").then(console.log); // -> Hello!
module.exports = (input) => {
return new Promise((resolve, reject) => resolve(input));
};
exports
won’t work, only module.exports
will!
$("#foo")[0];
$("#foo").get(0);
Use either, see the jQuery FAQ.
<!-- beforebegin -->
<parent>
<!-- afterbegin -->
<child></child>
<!-- beforeend -->
</parent>
<!-- afterend -->
Copied from the MDN documentation.
var array = [1, 2, 3, 4, 5];
var [head, ...tail] = array;
console.log(array); // -> [1, 2, 3, 4, 5]
console.log(head); // -> 1
console.log(tail); // -> [2, 3, 4, 5]
var a = 1;
var b = 2;
[a, b] = [b, a];
console.log(a); // -> 2
console.log(b); // -> 1
You can also specify more (or less) than two variables.
document.body.contentEditable = "true";
document.designMode = "on";
Changes, of course, won’t be saved, but it may still prove helpful in some situations.
navigator.clipboard.writeText("Text").then(function() {
// Success!
}, function() {
// Error!
});
This is not supported in IE, and Firefox hides it behind a flag in some cases.
COMPOSER_CACHE_DIR=/dev/null composer
See the Composer documentation for details.
$foo = "bar";
$foo = "baz";
echo $bar; // -> baz
Here, $foo
resolves to $bar
!
WinSCP → Options → Preferences → Applications → PuTTY/Terminal client path:
"zoc.exe" /CONNECT:!U:!P@!@:!# "/RUN:%USERPROFILE%\Documents\ZOC8 Files\REXX\cd.zrx" "/RUNARG:!/"
%USERPROFILE%\Documents\ZOC8 Files\REXX\cd.zrx:
CALL ZocSend "cd '"ARG(1)"'^M"
cat input > output
cp input output
dd if=input of=output
tee < input > output
To convert a video with X FPS to a video with Y FPS, divide X by Y, and use the result like so:
ffmpeg -itsscale X/Y -i input.mp4 -c copy output.mp4
This only accounts for video frames; the audio will not speed up or slow down.
CREATE DATABASE database;
CREATE USER user WITH ENCRYPTED PASSWORD password;
GRANT ALL PRIVILEGES ON DATABASE database TO user;
First, press CTRL+Z on the running command. Then:
bg
disown
loginctl enable-linger
aria2c input -o output
bitsadmin /transfer "" input output
curl input -o output
http input > output
httrack -g input -N output
powershell iwr input -outf output
pwsh -c iwr input -outf output
rclone copyurl input output
wget input -O output
wget2 input -O output
Uses either aria2, BITSAdmin, curl, HTTPie, HTTrack, Windows PowerShell, PowerShell, rclone, Wget or Wget2.
First, run the following:
flatpak install flathub org.freedesktop.Platform.ffmpeg-full
When asked for a version to install, choose the latest version (at the time of writing, this is 21.08) and make a mental note of it.
Then add the following lines to /var/lib/flatpak/app/org.mozilla.firefox/current/active/metadata, replacing 21.08 with the version you installed:
[Org.freedesktop.Platform.ffmpeg-full extension]
directory = lib/ffmpeg
add-ld-path = .
no-autodownload = true
version = 21.08
Adapted from bug 1628203. I have found that the relevant metadata section is already present in some cases, in which you don’t have to add it manually.
Remove-Item -Recurse $env:LOCALAPPDATA\Packages\CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc # Ubuntu
Remove-Item -Recurse $env:LOCALAPPDATA\Packages\TheDebianProject.DebianGNULinux_76v4gfsz19hv4 # Debian
The respective repositories may currently ship an outdated version of Puddletag that uses a deprecated pyparsing function. To make it use the new one:
sudo sed -i "s/operatorPrecedence/infixNotation/g" /usr/lib/python3/dist-packages/puddlestuff/audio_filter.py
Thanks to Bloom on the Debian User Forums.
curl https://get.docker.com | sh
sudo apt install uidmap
dockerd-rootless-setuptool.sh install
echo export DOCKER_HOST=unix:///run/user/1000/docker.sock >> ~/.bashrc
source ~/.bashrc
Right-click on any .URL file, select “Open With”, “Other Application” and enter the following in the “Enter a custom command…” field:
sh -c "cat %F | grep URL= | cut -d '=' -f2- | xargs -n 1 xdg-open"
CreateRetweet
.data.create_retweet.retweet_results.result.rest_id
.twurl -d "tweet_mode=extended&id=rest_id" /1.1/account/pin_tweet.json
, replacing the rest_id
placeholder.(foo) {
log
}
example.com {
import foo
}
See the Caddy documentation for details.
flatpak run --share=network --command=bash com.example -c "DISPLAY=$DISPLAY example"
First, start an X11 server on the host machine, for example:
vcxsrv.exe -ac -multiwindow
Then, update the DISPLAY variable with the appropriate IP address:
export DISPLAY=$(cat /etc/resolv.conf | grep nameserver | awk '{print $2}'):0
xwinwrap -fdt -g 1920x1080 -ni -- mpv -wid WID --loop LEFT.MP4 &
xwinwrap -fdt -g 1920x1080+1920 -ni -- mpv -wid WID --loop RIGHT.MP4 &
This example is optimized for my two-minitor setup and uses xwinwrap as well as mpv.