Using Python's built-in defaultdict we can easily define a tree data structure:
def tree(): return defaultdict(tree)
That's it!
Using Python's built-in defaultdict we can easily define a tree data structure:
def tree(): return defaultdict(tree)
That's it!
#!/usr/bin/env python2 | |
"""A very simple Apache access log parser in Python | |
usage help = http://i.imgur.com/XBiX2kX.png | |
when required arguments are missing = http://i.imgur.com/P5L0GZV.png | |
when incorrect file path is passed = http://i.imgur.com/sJDc0om.png | |
successful sample output = http://i.imgur.com/iH89mwI.png |
lsusb -v 2> /dev/null | grep -e "Apple Inc" -A 2 |
#!/usr/bin/env python3 | |
""" | |
Generate a random IPv6 address for a specified subnet | |
""" | |
from random import seed, getrandbits | |
from ipaddress import IPv6Network, IPv6Address | |
subnet = '2001:db8:100::/64' |
### | |
# Proxmox or other server kernel params cheap tune and secure. | |
# Try it if you have heavy load on server - network or memory / disk. | |
# No harm assumed but keep your eyes open. | |
# | |
# @updated: 2020-02-06 - more params used, adjust some params values, more comments on params | |
# | |
### NETWORK ### |
You'll probably be working with a single smartcard, so you'll want only one primary key ( |
# Generate a new pgp key: (better to use gpg2 instead of gpg in all below commands) | |
gpg --gen-key | |
# maybe you need some random work in your OS to generate a key. so run this command: `find ./* /home/username -type d | xargs grep some_random_string > /dev/null` | |
# check current keys: | |
gpg --list-secret-keys --keyid-format LONG | |
# See your gpg public key: | |
gpg --armor --export YOUR_KEY_ID | |
# YOUR_KEY_ID is the hash in front of `sec` in previous command. (for example sec 4096R/234FAA343232333 => key id is: 234FAA343232333) |
#!/bin/bash | |
# Quick script to disable an internal webcam if an external one is attached, or | |
# enable the internal one if the external one's not attached. | |
# by Shimon Rura, 25 Jan 2018. In the public domain. | |
# To use, run `lsusb` and identify the lines for your internal and external camera devices. | |
# For example, mine are: | |
# internal: |