Match a line with multiple regex using Python

 https://stackoverflow.com/questions/8888567/match-a-line-with-multiple-regex-using-python

You can use the built in functions any (or all if all regexes have to match) and a Generator expression to cycle through all the regex objects.

any (regex.match(line) for regex in [regex1, regex2, regex3])

(or any(re.match(regex_str, line) for regex in [regex_str1, regex_str2, regex_str2]) if the regexes are not pre-compiled regex objects, of course)

However, that will be inefficient compared to combining your regexes in a single expression. If this code is time- or CPU-critical, you should try instead to compose a single regular expression that encompasses all your needs, using the special | regex operator to separate the original expressions.

A simple way to combine all the regexes is to use the string join method:

re.match("|".join([regex_str1, regex_str2, regex_str2]), line)

A warning about combining the regexes in this way: It can result in wrong expressions if the original ones already do make use of the | operator.

PYTHON: Is there a simple way to delete a list element by value?

 python - Is there a simple way to delete a list element by value? - Stack Overflow


To remove an element's first occurrence in a list, simply use list.remove

:
>>> a = ['a', 'b', 'c', 'd']
>>> a.remove('b')
>>> print(a)
['a', 'c', 'd']

Mind that it does not remove all occurrences of your element. Use a list comprehension for that.

>>> a = [10, 20, 30, 40, 20, 30, 40, 20, 70, 20]
>>> a = [x for x in a if x != 20]
>>> print(a)
[10, 30, 40, 30, 40, 70]

Exploring Docker container's file system

 linux - Exploring Docker container's file system - Stack Overflow


docker ps


A) Use docker exec (easiest)

Docker version 1.3 or newer supports the command exec that behave similar to nsenter. This command can run new process in already running container (container must have PID 1 process running already). You can run /bin/bash to explore container state:

docker exec -t -i mycontainer_id /bin/bash

see Docker command line documentation

Cold Turkey Blocker

 https://superuser.com/questions/1366153/how-to-get-rid-of-cold-turkey-website-blocker-get-around-the-block Very old question, but still wan...