jq is useful to slice, filter, map and transform structured json data.
brew install jq
# GROK Custom Patterns (add to patterns directory and reference in GROK filter for iptables events): | |
# GROK Patterns for iptables Logging Format | |
# | |
# Created 6 Aug 2016 by Brian Turek <brian.turek@gmail.com> | |
# Most of this was taken from another source but now I cannot find it for credit | |
# | |
# Usage: Use the IPTABLES pattern | |
NETFILTERMAC %{MAC:dest_mac}:%{MAC:src_mac}:%{ETHTYPE:ethtype} | |
ETHTYPE (?:(?:[A-Fa-f0-9]{2}):(?:[A-Fa-f0-9]{2})) |
#!/bin/bash | |
set -euo pipefail | |
if (( EUID != 0 )); then | |
echo "This script must be executed as root, eg, 'sudo $0'" | |
exit | |
fi | |
DEVICE=$(tr -d '\0' </proc/device-tree/model) |
#!/bin/bash | |
### | |
### This is the script I use to setup time machine to work with my LinkSys attched NAS (USB 3.0 Hard Drive) | |
### | |
#### Configurable Parameters ######### | |
SIZE=300g | |
NAME="Z.org Time Machine Backup" |
from requests.adapters import BaseAdapter | |
from requests.models import Response | |
from requests.cookies import extract_cookies_to_jar | |
from requests.utils import get_encoding_from_headers | |
from requests.structures import CaseInsensitiveDict | |
from urllib3.contrib.appengine import AppEngineManager | |
# Transforming Code into Beautiful, Idiomatic Python | |
# Raymond Hettinger | |
# Looping over a range of numbers | |
for i in [0, 1, 2, 3, 4, 5]: | |
print i**2 | |
# better: | |
for i in range(6): | |
print i**2 |
#!/usr/bin/env python | |
import argparse | |
import yaml | |
def increment_version(version, inc_major=None, inc_minor=None, sep='-'): | |
version_string = str(version) | |
if '-' in version_string: | |
major, minor = version_string.split('-') |
# Put it in your .bashrc or .bash_profile and do cdp <python module name> | |
# to get in the directory where the module is defined. This work: | |
# USAGE: | |
# ~ $ cdp os | |
# /usr/lib/python2.7 $ | |
# ~ $ cdp os.path | |
# /usr/lib/python2.7 $ | |
# It also works if a virtual environment is active. |
#!/usr/bin/env python | |
""" | |
Usage: | |
using ~/.slackmerc file: | |
$ slackme some info # with `default` profile | |
$ slackme --profile alert some info # using `alert` profile | |
put profile in filename: |
#!/bin/bash | |
url=$(echo %clipboard | sed 's/www.dropbox.com/dl.dropboxusercontent.com/g' | tr -d '\n') | |
echo "$url" |