Skip to content

Instantly share code, notes, and snippets.

@john-g-g
john-g-g / jq-cheetsheet.md
Created May 25, 2021 17:12 — forked from olih/jq-cheetsheet.md
jq Cheet Sheet

Processing JSON using jq

jq is useful to slice, filter, map and transform structured json data.

Installing jq

On Mac OS

brew install jq

@john-g-g
john-g-g / iptables.grok
Created January 30, 2020 14:16 — forked from Caligatio/iptables.grok
iptables Grok Pattern
# 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}))
@john-g-g
john-g-g / prepare_chrony_server.sh
Created December 21, 2019 21:03
Script to configure raspberry pi hardware/software to act as GPSDO based chrony time server
#!/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)
@john-g-g
john-g-g / make-time-machine-work.sh
Created August 25, 2016 19:45 — forked from aaronzirbes/make-time-machine-work.sh
Script to setup SMB share for time machine backup
#!/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"
@john-g-g
john-g-g / adapter.py
Last active February 9, 2016 21:34
HTTP Transport Adapter for requests library which allows requests to be used on Google App Engine
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
@john-g-g
john-g-g / python.py
Created November 28, 2015 16:58
Transforming Code into Beautiful, Idiomatic Python
# 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
@john-g-g
john-g-g / increment_version.py
Created April 2, 2015 18:55
Increment Google App Engine app version string. If each deploy is a unique version, App Engine deploys are zero risk thanks to version routing.
#!/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('-')
@john-g-g
john-g-g / cdp.sh
Created March 20, 2015 15:35
Change directory to definition of specified python module
# 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.
@john-g-g
john-g-g / slackme
Last active August 29, 2015 14:15 — forked from onjin/slackme
#!/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:
@john-g-g
john-g-g / dropbox-host.sh
Created December 17, 2014 20:49
Convert Dropbox share link to link to actual file
#!/bin/bash
url=$(echo %clipboard | sed 's/www.dropbox.com/dl.dropboxusercontent.com/g' | tr -d '\n')
echo "$url"