How to Record and Replay Terminal Sessions in Linux
That is, just use script
command…
How to Record and Replay Terminal Sessions in Linux
That is, just use script
command…
stress and stress-ng are essential tools for assessing and testing the performance of Linux systems under various conditions.
Source: How to Stress Test Your Linux CPU for High Load
PSSH is a small Python-based program, which allows you to execute commands on multiple Linux remote servers in parallel at the same time using the single shell.
FreeBSD Handbook is a primer for any Unix related operative system. A must read to turn a noob into a pro
Ever wonder about that mysterious Content-Type tag? You know, the one you’re supposed to put in HTML and you never quite know what it should be? Did you ever get an email from your friends in…
The Absolute Minimum Every Software Developer Absolutely, Positively Must Know About Unicode and Character Sets (No Excuses!)
Oldies but goldies. This article is 20 years old, but still very relevant
Continue readingRecently I’ve been logged into a laptop remotely a lot. Logging out from “main” session makes my Gnome on Debian 12 go to suspend after a while. To avoid it you just have to tell:
sudo dbus-launch gsettings set org.gnome.settings-daemon.plugins.power sleep-inactive-ac-type 'nothing'
Thanks to WinEunuuchs2Unix for the answer I took from Prevent sleep/suspend when not logged in to a specific account; the only change is that GDM on Debian runs as root.
See also https://wiki.debian.org/Suspend#Disable_suspend_and_hibernation:
For systems which should never attempt any type of suspension, these targets can be disabled at the systemd level with the following:
sudo systemctl mask sleep.target suspend.target hibernate.target hybrid-sleep.targetTo re-enable hibernate and suspend use the following command:
sudo systemctl unmask sleep.target suspend.target hibernate.target hybrid-sleep.targetA modern alternative approach for disabling suspend and hibernation is to create /etc/systemd/sleep.conf.d/nosuspend.conf as
[Sleep] AllowSuspend=no AllowHibernation=no AllowSuspendThenHibernate=no AllowHybridSleep=noThe above technique works on Debian 10 Buster and newer. See systemd-sleep.conf(5) for details.
If you just want to prevent suspending when the lid is closed you can set the following options in /etc/systemd/logind.conf:
[Login] HandleLidSwitch=ignore HandleLidSwitchDocked=ignoreThen run systemctl restart systemd-logind.service or reboot.
Search and replace in multiple files using vim – (source Stack Overflow)
It is as simple as
Use:
:set aw
:argdo %s/happy999/happy111/g
The first line sets auto-write mode, so when you switch between files, vim
will write the file if it has changed.
The second line does your global search and replace.
Note that it doesn’t use wq!
since that exits. If you don’t want to use auto-write, then you could use:
:argdo %s/happy999/happy111/g | w
This avoids terminating vim
at the end of editing the first file.
javascript – Can (a== 1 && a ==2 && a==3) ever evaluate to true? – Stack Overflow
Yes, it can. IMHO it is one of the several undesirable consequences of loosely typed languages. In fact, according to an almost anonymous user:
If you take advantage of how
==
works, you could simply create an object with a customtoString
(orvalueOf
) function that changes what it returns each time it is used such that it satisfies all three conditions.const a = { i: 1, toString: function () { return a.i++; } } if(a == 1 && a == 2 && a == 3) { console.log('Hello World!'); }
The reason this works is due to the use of the loose equality operator. When using loose equality, if one of the operands is of a different type than the other, the engine will attempt to convert one to the other. In the case of an object on the left and a number on the right, it will attempt to convert the object to a number by first calling
valueOf
if it is callable, and failing that, it will calltoString
. I usedtoString
in this case simply because it’s what came to mind,valueOf
would make more sense. If I instead returned a string fromtoString
, the engine would have then attempted to convert the string to a number giving us the same end result, though with a slightly longer path.
Worst, it is also possible using the === operator!
var i = 0; with({ get a() { return ++i; } }) { if (a == 1 && a == 2 && a == 3) console.log("wohoo"); }
This uses a getter inside of a
with
statement to leta
evaluate to three different values.… this still does not mean this should be used in real code…
Even worse, this trick will also work with the use of
===
.var i = 0; with({ get a() { return ++i; } }) { if (a !== a) console.log("yep, this is printed."); }
Versioning data in Postgres? Testing a git like approach – Specfy is fashinating but I think that most of the time these two proposed alternatives fit most of the needs:
version
(or modify date) and SELECT the maximum version. It’s simple and doesn’t require maintaining multiple schema or resources. However it has massive drawback in term of performance, and query simplicity. The table will inevitably grow, and SELECT needs to have an order by which can make joining/grouping/aggregating harder or slower.id
to be inserted multiple times. And you obviously need one table per versionned table.