Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env python3
##
## Poll xrandr to find brightness of connected monitors, set if above threshold
##
##
## Place this file in /usr/bin/dell_xps_15_brightness, set it to executable, and link it:
## ln -s /usr/bin/dell_xps_15_brightness /lib/systemd/system-sleep
##
@joshland
joshland / LICENSE
Created March 7, 2019 18:42 — forked from noelbundick/LICENSE
Exclude WSL installations from Windows Defender realtime protection
MIT License
Copyright (c) 2018 Noel Bundick
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
#!/usr/bin/env python
import os, string
def _pmap(process):
import subprocess
try:
p = subprocess.Popen(["pmap", process], stdout=subprocess.PIPE)
retval = [ x.decode() for x in p.stdout]
except OSError:
import collections
def humanize_bibytes(n, prefixes=collections.OrderedDict((
(0, 'B'),
(1024, 'KiB'),
(1048576, 'MiB'),
(1073741824, 'GiB'),
(1099511627776, 'TiB'),
(1125899906842624, 'PiB'),
(1152921504606846976, 'EiB'),
(1180591620717411303424, 'ZiB'),
@joshland
joshland / killerConversion.py
Created January 15, 2017 23:09
DoS your computer, using only Python
def convertSize(size):
'''
reduce xxxK, xxxM, xxxG, etc
'''
if size.strip() == "":
size = 0
elif size[-1] == 'K':
size = size*1024
elif size[-1] == 'M':
size = size*1024*1024
@joshland
joshland / fwheader.py
Last active January 15, 2017 03:33
i needed a tool to identify non-wrapping columns from text commands with variable fixed witdth output. (e.g. lsblk)
#!/usr/bin/python
# -*- coding: utf-8 -*-
__author__ = 'Joshua M. Schmidlkofer <joshland@protonmail.com>'
__credits__ = ["Joshua M. Schmidlkofer"]
__status__ = "Development"
__url__ = "https://gist.github.com/joshland/e89347f88d128a971768c2a711dfa5dc"
from collections import OrderedDict
import re
@joshland
joshland / python-fstab.py
Last active January 12, 2017 18:43 — forked from niedbalski/python-fstab.py
python-fstab.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# fstab interpreter
__author__ = 'Jorge Niedbalski R. <jnr@metaklass.org>'
__url__ = 'https://api.jujucharms.com/charmstore/v5/elasticsearch/archive/hooks/charmhelpers/core/fstab.py'
__note__ = 'small mod: change filter/lamba to listcomp, Joshua Schmidlkofer <joshland@protonmail.com>'
__credits__ = ["Jorge Niedbalski R.", "Joshua Schmidlkofer"]
Here is a sample of how I am currently dealing with users.
Big thanks to uggedal! I used his user states as an example: https://github.com/uggedal/states
###
# How to create password hashes
###
python -c "import crypt; print crypt.crypt('password', '\$6\$SALTsalt\$')"
###