Skip to content

Instantly share code, notes, and snippets.

View mzpqnxow's full-sized avatar
🙈

AG mzpqnxow

🙈
View GitHub Profile
@mzpqnxow
mzpqnxow / xauth-multiuser-sudo-hack
Last active June 21, 2018 18:43
Ugly hack for sharing Xauthority, lost the better way to do this...
The user `primary` is the user with the desktop access
The user `secondary` is a user you sudo/su to who you would like to run X11 apps
`x11-share` is a group that you create. All users who should share the xauth cookies should be in this group
**Note this is a security issue if you do not trust the `x11-share` users!!**
/etc/sudoers:
```
Defaults:deploy env_keep += "XAUTHORITY", !requiretty
Defaults:deploy env_keep += "DISPLAY", !requiretty
```
@mzpqnxow
mzpqnxow / mcafee_epo_ip4.py
Last active October 26, 2018 20:05
"Decoding" an IPv4 address out of the poorly implemented McAfee EPO JSON output from core.executeQuery with output=json
""
McAfee EPO has no IPV4 value, what do I do !?
EPOComputerProperties has IPV6 value but no IPV4 value in certain versions or
configurations. Here is a quick function to "fix" that, since the IPv4 data
is often actually hidden inside a bogus IPV6 value.
McAfee EPO seems to return a phony IPv6 address, and has no IPv4 field when using
their API, specifically in this case, the core.executeQuery endpoint, when using
output=json (and probably csv, or whatever else)
@mzpqnxow
mzpqnxow / sshclient.go
Created August 21, 2018 01:16 — forked from josephspurrier/sshclient.go
Golang SSH Client
package main
import (
"bufio"
"io/ioutil"
"os/signal"
//"syscall"
"fmt"
"log"
"os"
@mzpqnxow
mzpqnxow / download_latest_linux_pycharm.sh
Last active September 12, 2021 00:34
Automatically download and install latest version of PyCharm (Community or Professional) for linux without wasting your time in a browser
#!/bin/bash
#
# This will download the latest Linux version of PyCharm, a tarball that works on Debian, Ubuntu, Fedora, etc, etc...
# You can just paste it into your terminal, put it in a shell script and execute it, our simply source it.
#
# - AG
#
# (Edited multiple times for quotes and other silly things)
#
# Dependencies:
@mzpqnxow
mzpqnxow / addloglevel.py
Last active September 12, 2021 00:34
Comprehensive example of adding a loglevel to Python logging module
"""
Taken from StackOverflow
This is the cleanest, most correct and thorough method I've seen
"""
def addLoggingLevel(levelName, levelNum, methodName=None):
"""
Comprehensively adds a new logging level to the `logging` module and the
currently configured logging class.
@mzpqnxow
mzpqnxow / customlog.py
Last active September 12, 2021 00:33
Customize Python log formatting by log level
"""
A simple example of formatting log messages differently based on their
Python log level. It seems a basic feature for a logging library that
as far as I can tell is missing from stdlib logging
So the usual route is overriding the logging.Formatter class as shown
below. Sovling the problem this way isn't novel or unusual as nearly
all of the stdblib classes are meant to be extended, but it would
be nice if you could just pass a dictionary of log levels and their
@mzpqnxow
mzpqnxow / wackyextension.py
Created September 22, 2018 19:30
A stupid fancy logging.Logger extension that let's the developer have some new 'aesthics` focused functions, including overriding standard ones
class StupidFancyLogger(logging.Logger):
"""Extension of logging.Logger that has stupid fancyprint wrapper funcs
If you want your app to print stupid line prefixes and endings, this an
example of a way to do that. It's pretty simple, it just provides some
new methods in the Logger class, i.e., StupidFancyLogger.indented()
logger = StupidFancyLogger(...)
logger.indented(msg, count=8, log_level=logging.INFO):
"""
#
# Copyright (C) 2010-2012 Vinay Sajip. All rights reserved. Licensed under the new BSD license.
#
import ctypes
import logging
import os
class ColorizingStreamHandler(logging.StreamHandler):
# color names to indices
color_map = {
@mzpqnxow
mzpqnxow / Makefile
Last active January 12, 2024 18:14
target for a Makefile for an `autombump and publish to PyPi/Artifactory` Makefile (via versioneer and git)
#
#
# ...
# The release target will do the following:
# - Bump your current *3 digit* git tag (you *MUST* be using x.y.z format) by git tagging
# `make release bump=major`
# `make release bump=minor`
# `make release`
# - Build/publish your Python package via setuptools, dynamically inserting the bumped
# version (so no need to update or track a version in setup.py)
@mzpqnxow
mzpqnxow / get-vyprvpn-servers.py
Last active March 9, 2023 21:28
Get a list of all VyprVPN server IP addresses, hostnames and countries or a subset based on specified country/countries
#!/usr/bin/env python2
# -*- coding: utf-8 -*-
"""
Retrieve list of all VyprVPN servers, relying on their publicly posted list which
is referenced on their site as an "official" source .. it seems this could change
but it hasn't in a long time
Dependency on BeautifulSoup
(Optional) dependency on the `progress` project @ https://pypi.org/project/progress/