Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / 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

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 / 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
@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 / 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 / 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()
#!/usr/bin/env python
import sys
import urllib
import urllib2
import json
import argparse
import ssl
import time
from urlparse import urlparse
@pysysops
pysysops / Weblogic Configs
Last active April 21, 2017 19:49
Weblogic related gotchas / useful config options
1. On Linux / WLS 12c there is a problem with the TCP unicast work manager blocking, it causes nodes in a cluster to failover. Add:
-Dweblogic.unicast.HttpPing=true
To server start args. It's a known / documented issue: https://docs.oracle.com/cd/E24329_01/doc.1211/e26593/issues.htm#WLSRN182
2. Memory leaks. If you use RMI which you probably do and suffer from Memory leaks, forget tuning the app code (it's Java,
it'll always have memory leaks) Take a heap dump adn run it through jmap or create diffs from 2. If you see this class pop
up in retained heap or memory leak suspects: weblogic.rjvm.ConnectionManage Add: