- use
meta
module:- meta: end_play
lightdm --test-mode
sudo vim /etc/systemd/system/<serviceName>.conf
sudo systemctl daemon-reload
sudo systemctl <serviceName> enable
sudo systemctl <serviceName> start
feh --conversion-timeout 1 -g 640x480 -d -S filename .
git clone https://aur.archlinux.org/yay.git
cd yay
makepkg -si
- edit
/etc/systemd/logind.conf
, reboot
openssl rand -base64 <size>
swapon -s
orcat /proc/swaps
general, compact XOR (source):
A XOR B = NOT (NOT A == NOT B)
xargs -d '\n' <input>
sort -k <column number> <input>
setxkbmap <layout> <variant>
-
set system timezone:
timedatectl set-timezone Europe/Berlin
-
list timezones:
timedatectl list-timezones
general, mnemonic for little and big endian (source):
-
big endian: the large part of the number is first (big first)
- similar to common usage: 123 = 1 * 10^2 + 2 * 10^1 + 3 * 10^0
-
little endian: the small part of the number is first (little first)
- exponents order follows digit iteration order, so 123 is 321 in LE: 321 = 3 * 10^0 + 2 * 10^1 + 3 * 10^2
-n
flag defines time interval:watch -n 2 nmcli
autojump on arch needs a symlink from the .bash to .shnope, solved on .bashrc
.class1 .class2
: means inside.class1.class2
: means needs to have both.class1, .class2
: means has one or the other
<i>
elements (at least, those that have FontAwesome classes) need to havepointer-events: none;
in their CSS in order to allow clicks to pass through to other elements behind them
- Use watchIgnorePlugin, NEEDS ABSOLUTE PATHS TO WORK (could not get it to work otherwise).
- needs special option to return full paths
- needs to have symlinks flagged as such in order to follow them
debug
,winston
,log4js
(order of popularity 2k18)
commander.js
:
const program = require('commander');
program.option('-d, --debug', 'extra debugging'); //etc
program.parse(process.argv);
findmnt -M
,-J
flag outputs json forjq
- single brakets need spaces between next characters
-f
: exists file-z
: string with zero length-n
: string with non-zero length-d
: exists dir
[ ! -f filename ]
, for instance
while true; do foo; sleep 2; done;
-
in browsers, any global variable called
name
declared in the global scope is INVARIABLY treated as if it is a string (credit to @joaosamouco and @joaopintomfc):var name = () => 1; console.log(typeof name) // "string"
JavaScript, check if value is numeric (SO answer):
const isNumeric = n => !isNaN(parseFloat(n)) && isFinite(n);
(kinda oldschool, but works)
-
isNaN
attempts to convert the value to a number and then checks whether the result equalsNaN
; -
Number.isNaN
checks whether the input is exactlyNaN
(without conversion);
Number.isNaN(void 0) === false
isNaN(void 0) === true
-
isFinite
attempts to convert the value to a number and then checks whether it is finite; -
Number.isFinite
performs the check without conversion;
-
when using Enzyme
mount
, async calls in or triggered by lifecycle methods (such ascomponentDidMount
) will not be waited for, even if remote calls are stubbed/mocked usingjest.fn().mockResolvedValue
or the like. (does not mean that they will not be resolved, but they may end up resolving at a later time than expected) -
to make sure that pending promises are executed after calling 'mount', use
setImmediate
:
test('Foo does a network request on componentDidMount', async () => {
const component = mount(<Foo />);
// if you do not use this line, the assertion below may (and probably will) fail
await new Promise(res => setImmediate(res));
expect(fetch).toHaveBeenCalled();
})
git diff --no-prefix -U1000 HEAD^ HEAD
git diff HEAD~n HEAD
git submodule update --init --recursive
git --no-pager log > log.txt
git, exclude files matching a certain pattern from diff (stackoverflow):
git diff --cached -- . ':!spec'
git remote get-url <origin name>
- if
--depth
is set, pulling from remote does nothing.
set pager=1
ls
set root=(hd?,?)
linux <stuff> root=/dev/sdX
initrd <stuff>
boot
--efi-directory
option takes the folder that CONTAINS the efi directory, not the efi directory path itself
node.js, path.normalize
vs path.resolve
(SO answer):
"Ironically, this means that path.resolve() produces a relative path in absolute terms (you could execute it anywhere, and it would produce the same result), whereas path.normalize() produces an absolute path in relative terms (you must execute it in the path relative to which you want to calculate the absolute result)."
-
Meaning,
path.resolve(__dirname, <relativePath>)
results in an absolute filepath, since__dirname
is always absolute. -
To get an absolute filepath from
resolve
, we would then pass it tonormalize
:path.normalize(path.resolve('home/foo', 'bar'))
results in${process.cwd}/home/foo/bar
(err, req, res, next) => {/*something*/}
res.set(<header name>, <header value>)
- required in all methods, but when in OPTIONS middleware, return 200 and send
immediately instead of calling
next
.
app.use('*', <middleware>);
-
use
ajv.addKeyword(<keyword>, <descriptor>)
-
if you define a
type
in the descriptor that is passed toaddKeyword
, then the validator only tries to apply that validator to a value of that type (!!!!)
-
links:
[]()
(square then round) -
checkboxes:
- [ ] Foo bar
-
more help: https://www.markdownguide.org/basic-syntax
- uuid:
{{$guid()}}
- defining custom keywords:
// in the pre-request script section:
pm.globals.set('randomNumber', Math.floor(Math.random() * 5));
// in the request body:
{{randomNumber}}
I know, I know, I should know this, but I always get which is which wrong...
-
PUT is a full-entity replacement of an existing entity. Idempotent.
-
PATCH is a partial update of an existing entity. NOT idempotent.
vboxmanage internalcommands createrawvmdk -filename $HOME/win10.vmdk -rawdisk /dev/sdb
sed '/^$/d'
(delete mode on sed withd
)
eval $(ssh-agent) && ssh-add
- use
VisualHostKey yes
in/etc/ssh/sshd_config
-
ssh <server user>@<server host> -L <address in local host>:<address in remote server> -N
-
the
-N
flag makes it so that a shell is not opened
xrandr --output <output name> --mode <resolution> --rate <refresh rate>
- change postgres config to allow any host access (if accessing from docker)
- add user/db/pwd as necessary
- change pg_hba to allow access as that user to the db