Skip to content

Instantly share code, notes, and snippets.

@pysysops
pysysops / tcp-connect.lua
Created April 12, 2017 12:22
Open resty endpoint to proxy / test tcp connectivity with 5 second micro cache
local _M = {}
-- Initialize a cache on the module level with up to 1000 entries
local lrucache = require("resty.lrucache")
local c, err = lrucache.new(1000)
if not c then
return error("failed to create the cache: " .. (err or "unknown"))
end
function _M.go()
@pysysops
pysysops / show_alerts.py
Last active September 25, 2017 09:50
Python script to get current alerts from Sensu API and display at login
#!/usr/bin/env python
import sys
import urllib
import urllib2
import socket
import json
import argparse
import time
from urlparse import urlparse
@pysysops
pysysops / show_alerts.sh
Last active September 25, 2017 09:50
Script to add to /etc/profile.d to show alerts only when logging in via SSH
#!/usr/bin/env bash
# This script calls a python script to output
# current alerts on the current system when SSH'd
# in.
if [ "$SSH_TTY" ]
then
python /etc/profile.d/show_alerts.py
fi
@pysysops
pysysops / ssg-centos7-ds.xml
Last active May 26, 2017 10:49
CentOS 7 SCAP Security Guide
This file has been truncated, but you can view the full file.
<ns0:data-stream-collection xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:html="http://www.w3.org/1999/xhtml" xmlns:ns0="http://scap.nist.gov/schema/scap/source/1.2" xmlns:ns1="http://www.w3.org/1999/xlink" xmlns:ns10="http://checklists.nist.gov/xccdf/1.2" xmlns:ns12="http://www.w3.org/2000/svg" xmlns:ns14="http://cpe.mitre.org/dictionary/2.0" xmlns:ns2="urn:oasis:names:tc:entity:xmlns:xml:catalog" xmlns:ns3="http://oval.mitre.org/XMLSchema/oval-definitions-5" xmlns:ns5="http://oval.mitre.org/XMLSchema/oval-common-5" xmlns:ns6="http://oval.mitre.org/XMLSchema/oval-definitions-5#independent" xmlns:ns7="http://oval.mitre.org/XMLSchema/oval-definitions-5#unix" xmlns:ns8="http://oval.mitre.org/XMLSchema/oval-definitions-5#linux" xmlns:ns9="http://scap.nist.gov/schema/ocil/2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="scap_org.open-scap_collection_from_xccdf_ssg-rhel7-xccdf-1.2.xml" schematron-version="1.2">
<ns0:data-stream id="scap_org.open-scap_datastream_from_xccdf_ssg-rhel7-xccdf-1.2.xm

Keybase proof

I hereby claim:

  • I am pysysops on github.
  • I am pysysops (https://keybase.io/pysysops) on keybase.
  • I have a public key whose fingerprint is 90F7 C804 1422 7534 8086 1ACE DFEB 9ADD 84E1 DD5E

To claim this, I am signing this object:

@pysysops
pysysops / git-pull-all
Last active June 27, 2017 09:19
Pull all remote git repos locally
#!/bin/bash
for b in $(git branch -r | grep -v HEAD | cut -f 2 -d'/')
do
git checkout $b && git pull origin $b $@
done
@pysysops
pysysops / saltlint.py
Created October 13, 2018 20:03
Python script to lint salt / YAML files.
#!/usr/bin/env python
"""
Simple Salty Jinja2 linter
"""
import re
import sys
import os.path
from functools import reduce
from jinja2 import BaseLoader, TemplateNotFound, Environment, exceptions
import yaml
@pysysops
pysysops / roman2number.sh
Last active June 25, 2023 18:32
Convert roman numerals to a number in BASH
#!/bin/bash
set -eu -o pipefail
roman_numerals=$(echo $1 | tr a-z A-Z)
# Test that it is valid
[[ "${roman_numerals//[IVXLCDM]/}" == "" ]] || \
{ echo Roman numerals ${roman_numerals} contains invalid characters ; \
exit 1 ;}
@pysysops
pysysops / number2roman.sh
Created November 27, 2018 19:02
Convert numbers to Roman numerals
#!/bin/bash
set -eu -o pipefail
number=$1
# Test that it is valid
[[ "${number//[0-9]/}" == "" ]] || \
{ echo Number ${number} contains invalid characters ; \
exit 1 ;}
@pysysops
pysysops / AWSAssumeRole
Last active June 25, 2019 18:12
installing aws-assume-role (https://github.com/scalefactory/aws-assume-role) and functions to ease interaction.
gem install aws_assume_role
echo 'awsassume () { eval `aws-assume-role environment set -p $@`; }' >> ~/.bashrc
echo 'awsconsole () { eval `aws-assume-role console -p $@`; }' >> ~/.bashrc