Skip to content

Instantly share code, notes, and snippets.

View pfuntner's full-sized avatar

John Pfuntner pfuntner

  • Raleigh/NC/USA/Sol 3/MilkyWay/Universe 42.8z0
View GitHub Profile
@pfuntner
pfuntner / wsl-distros.txt
Created May 4, 2024 11:51
WSL Linux distros
$ wsl --list --online
The following is a list of valid distributions that can be installed.
Install using 'wsl.exe --install <Distro>'.
NAME FRIENDLY NAME
Ubuntu Ubuntu
Debian Debian GNU/Linux
kali-linux Kali Linux Rolling
Ubuntu-18.04 Ubuntu 18.04 LTS
Ubuntu-20.04 Ubuntu 20.04 LTS
@pfuntner
pfuntner / wsl-man.txt
Created April 7, 2024 15:00
Windoze WSL man page
Copyright (c) Microsoft Corporation. All rights reserved.
For privacy information about this product please visit https://aka.ms/privacy.
Usage: wsl.exe [Argument] [Options...] [CommandLine]
Arguments for running Linux binaries:
If no command line is provided, wsl.exe launches the default shell.
--exec, -e <CommandLine>
@pfuntner
pfuntner / numbers-as-strings.py
Last active May 16, 2023 12:16
Problem reading an Excel file with Python & pandas: keeping numbers as strings with trailing zeros
#! /usr/bin/env python3
import sys
import argparse
import pandas
parser = argparse.ArgumentParser(description=sys.argv[0])
parser.add_argument('path', help='Path to excel file')
args = parser.parse_args()
@pfuntner
pfuntner / debian-11-ciscat.html
Created October 13, 2022 11:37
Debian 11 CIS-CAT V4.22 report
This file has been truncated, but you can view the full file.
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:cce="http://benchmarks.cisecurity.org/cce/1.0" xmlns:controls="http://cisecurity.org/controls" xmlns:cc6="http://cisecurity.org/20-cc/v6.1" xmlns:c7="http://cisecurity.org/20-cc/v7.0" xmlns:c8="http://cisecurity.org/20-cc/v8.0" xmlns:cc7="http://cisecurity.org/20-cc/v7.0" xmlns:cve="http://benchmarks.cisecurity.org/cve/1.1" xmlns:check="local:check" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:xccdf="http://checklists.nist.gov/xccdf/1.2" xmlns:arf="http://scap.nist.gov/schema/asset-reporting-format/1.1" xmlns:dsc="http://scap.nist.gov/schema/scap/source/1.2" xmlns:ai="http://scap.nist.gov/schema/asset-identification/1.1" xmlns:scap-core="http://scap.nist.gov/schema/scap-core/0.3" xmlns:cis="http://benchmarks.cisecurity.org/evidence/1.0" xmlns:fn="stylesheet-function" xmlns:scap-con="http://scap.nist.gov/schema/scap/constructs/1.2" xmln
@pfuntner
pfuntner / restart_test.yml
Last active April 20, 2021 14:55
Running multiple tasks in an Ansible handler
- block:
- name: message 1
debug: msg=operation1
- name: message 2
debug: msg=operation2
- name: message 3
debug: msg=operation3
@pfuntner
pfuntner / BrunosSatellite
Last active April 29, 2019 13:04
whatami output
It is Sat 2019-04-27 23:34:17.053346 UTC
I am /home/John Pfuntner/bin/whatami: 2019-04-27 08:55:21, github.com:pfuntner/toys, master, 8d78c9, d0fc9c11b3abb42fa0ac7e1119221692
['uname', '-a']: 'CYGWIN_NT-6.3 BrunosSatellite 2.11.2(0.329/5/3) 2018-11-08 14:34 x86_64 Cygwin'
['uname', '-n']: 'BrunosSatellite'
['uname', '-s']: 'CYGWIN_NT-6.3'
['uname', '-v']: '2018-11-08 14:34'
['uname', '-r']: '2.11.2(0.329/5/3)'
['uname', '-m']: 'x86_64'
['uname', '-p']: 'unknown'
@pfuntner
pfuntner / test1.py
Last active April 20, 2019 14:14
Simple Python unit test
#! /usr/bin/env python
import os
import logging
from unittest import TestCase
import random
logging.basicConfig(format='%(asctime)s %(levelname)s %(pathname)s:%(lineno)d %(msg)s')
log = logging.getLogger()
@pfuntner
pfuntner / version-example
Last active January 18, 2019 16:23
Nice git-based version info
#! /usr/bin/env python
import os
import re
import sys
import logging
import argparse
import datetime
import subprocess
@pfuntner
pfuntner / log_example
Last active January 18, 2019 14:23
Example of using Python logging
#! /usr/bin/env python
import logging
import argparse
parser = argparse.ArgumentParser()
group = parser.add_mutually_exclusive_group()
group.add_argument('-v', '--verbose', dest='verbose', action='count', help='Enable debugging - multiple uses prints more messages')
group.add_argument('--loglevel', dest='loglevel', action='store', help='Set log level: DEBUG, INFO, WARNING, ERROR, CRITICAL')
@pfuntner
pfuntner / argparse-example.py
Last active January 22, 2019 17:46
Python argparse example
#! /usr/bin/env python
"""
I've always been a fan of using the getopt module but am sometimes encouraged by folks to use argparse. It does seem to have
some advantages but it's always been a little cryptic to me too. So I came up with a sample for some common options/arguments
I often what to deal with and put in my own tools. It's still a little unnatural to me but it works.
With regard to mutually exclusive options, argparse gives you a way to do it but it does not allow the options to appear on the
same command line - an error is thrown when this happens. When I implement mutually exclusive options with getopt, I typically
only accept the last option and behave as though the other options were not specified at all. I would kind of prefer that behavior