Skip to content

Instantly share code, notes, and snippets.

View GhostofGoes's full-sized avatar

Chris Goes GhostofGoes

View GitHub Profile
import sys
PY2 = sys.version_info[0] == 2
if PY2:
import _winreg as winreg
else:
import winreg
try:
reg = winreg.ConnectRegistry(None, winreg.HKEY_LOCAL_MACHINE)
ps_key = winreg.OpenKey(reg, r'SOFTWARE\Microsoft\PowerShell')
except OSError:
@GhostofGoes
GhostofGoes / .gitignore
Created October 4, 2018 04:29
Basic .gitignore template for Python projects
# Editors
.vscode/
.idea/
# Vagrant
.vagrant/
# Mac/OSX
.DS_Store
@GhostofGoes
GhostofGoes / CONTRIBUTING.md
Created October 5, 2018 23:37
Template for a CONTRIBUTING.md file

Contributing to getmac

Thanks for taking an interest in this awesome little project. We love to bring new members into the community, and can always use the help.

Resources

@GhostofGoes
GhostofGoes / pipenv_completion.ps1
Last active October 18, 2018 03:20
PowerShell completion for Pipenv. Edit: "notepad $profile.CurrentUserAllHosts"
function TabExpansion($line, $lastWord) {
$lastBlock = [regex]::Split($line, '[|;]')[-1].TrimStart()
$aliases = @("pipenv") + @(Get-Alias | where { $_.Definition -eq "pipenv" } | select -Exp Name)
$aliasPattern = "($($aliases -join '|'))"
if($lastBlock -match "^$aliasPattern ") {
$Env:_PIPENV_COMPLETE = "complete-powershell"
$Env:COMMANDLINE = "$lastBlock"
(pipenv) | ? {$_.trim() -ne "" }
Remove-Item Env:_PIPENV_COMPLETE
Remove-Item Env:COMMANDLINE
@GhostofGoes
GhostofGoes / profile.ps1
Last active November 18, 2018 21:01
PowerShell Profile: "notepad $profile.CurrentUserAllHosts"
# Provides same functionality as the Unix "which" command
function which($commandName)
{
(Get-Command $commandName).Definition
}
# Shortens a filesystem path to singe-characters [used by prompt()].
function shorten-path([string] $path) {
$loc = $path.Replace($HOME, '~')
@GhostofGoes
GhostofGoes / .pylintrc
Last active October 2, 2022 08:07
PyLint configuration for Google Python Code Style Guide. Slightly modified version of this: https://raw.githubusercontent.com/google/seq2seq/master/pylintrc
[MASTER]
# Specify a configuration file.
#rcfile=
# Python code to execute, usually for sys.path manipulation such as
# pygtk.require().
#init-hook=
# Add files or directories to the blacklist. They should be base names, not
@GhostofGoes
GhostofGoes / .gitignore
Created November 24, 2018 17:08
Global GitIgnore
# Pre-commit config (https://pre-commit.com/)
.pre-commit-config.yaml
# Editors/IDEs/etc
.idea
.vscode
.vagrant
.classpath
.project
@GhostofGoes
GhostofGoes / mac_addrs.py
Last active May 5, 2025 21:58
Get MAC addresses using a variety of Python packages.
# **************************************
# ** Get MAC address of a remote host **
def arpreq_ip(ip):
# type: (str) -> Optional[str]
import arpreq
return arpreq.arpreq('192.168.1.1')
def scapy_ip(ip):
# type: (str) -> str
"""Requires root permissions on POSIX platforms.
@GhostofGoes
GhostofGoes / virtualenvs.md
Created January 25, 2019 05:02
Create Python virtual environments on Windows and Linux with Virtualenv

Linux/OSX (Bash)

python -m pip install --user -U virtualenv
mkdir -p ~/.virtualenvs/
python -m virtualenv ~/.virtualenvs/getmac
source ~/.virtualenvs/getmac/bin/activate

Windows (PowerShell)

@GhostofGoes
GhostofGoes / ap.py
Created February 1, 2019 04:41
Simple export for Anime-Planet
import logging
import re
import browsercookie
import requests
from bs4 import BeautifulSoup
from requests.cookies import RequestsCookieJar
class AnimePlanet: