Entries tagged stackoverflow | Hugonweb Annotated Link Bibliography

Linux dd vs cp

https://unix.stackexchange.com/questions/558262/why-use-dd-instead-of-cp-to-create-bootable-disk

Tutorials and instructions usually recommend dd over cp for copying disc images to devices (like USB sticks). It seems that this is mostly superstition.

The main benefit is that dd lets you specify the block size used for copying, but cp automatically selects the block size at least as well as I would.

The other benefit of dd is a progress display. Piping the output of the pv command to the destination disc may be a better option.

Cron vs SystemD timers

https://unix.stackexchange.com/a/688512

A really nice explanation of how to use SystemD timers to replace cron.

Common mistakes to avoid in PHP

https://stackoverflow.com/collectives/php/collections/76822501/common-mistakes-to-avoid-in-php

List of Stack Overflow questions about mistakes to avoid in PHP

Inverting a dictionary of lists in Python

https://stackoverflow.com/questions/35491223/inverting-a-dictionary-with-list-values

I've needed to do this countless times in particle physics data analysis and other areas.

What I've done before:

data = {'a' : ['alpha', "beta"], 'b' : ["alpha"]}
result = {}
for key in data:
    for value in data[key]:
        try:
            result[value].append(key)
        except KeyError:
            result[value] = [key]

and the simpler solutions suggested in the link:

data = {'a' : ['alpha', "beta"], 'b' : ["alpha"]}
result = {}
for key in data:
    for value in data[key]:
        result.setdefault(value,[]).append(key)

or

from collections import defaultdict

data = {'a' : ['alpha', "beta"], 'b' : ["alpha"]}
result = defaultdict(list)
for key in data:
    for value in data[key]:
        result[value].append(key)

dict.setdefault and collections.defaultdict are new to me and useful!

Stack Overflow Definitive Guide to Form-based Website Authentication

https://stackoverflow.com/questions/549/the-definitive-guide-to-form-based-website-authentication

A really nice guide to the best, most secure ways to do website authentication. Lots of nice links