Skip to content

Instantly share code, notes, and snippets.

Bo Bayles bbayles

  • Observable Networks (now part of Cisco)
  • St. Louis, MO
Block or report user

Report or block bbayles

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@bbayles
bbayles / README.txt
Last active Jul 21, 2019
Rename SWC Sensor on first boot
View README.txt
Create the two files (sudo nano <filename>):
* /opt/obsrvbl-ona/set_ona_name.sh
* /etc/systemd/system/set_ona_name.service
Make the first script executable:
sudo chmod +x /opt/obsrvbl-ona/set_ona_name.sh
Enable the service:
sudo systemctl enable set_ona_name.service
@bbayles
bbayles / swc_lambda_poll.py
Last active Aug 14, 2019
Poll SWC for new alerts and observations
View swc_lambda_poll.py
"""
swc_lambda_poll.py
Use this AWS Lambda function with a Cloudwatch Logs Event to poll
for and react to Stealthwatch Cloud alerts.
The Cloudwatch Logs Event should trigger every 10 minutes.
"""
from datetime import datetime, timedelta, timezone
from os import environ
from botocore.vendored import requests
View iterchunked.py
from itertools import chain, islice, tee
from more_itertools import consume
_marker = object()
class iterchunked:
def __init__(self, iterable, n):
self._source = iter(iterable)
View dt_range.py
from datetime import datetime, timedelta
from functools import total_ordering
@total_ordering
class dt_range:
def __init__(self, start_dt, end_dt):
if start_dt > end_dt:
raise ValueError('start_dt must be before end_dt')
@bbayles
bbayles / download_observations.py
Created Apr 2, 2019
Download observations from Stealthwatch Cloud and print them as CSV
View download_observations.py
#!/usr/bin/env python3
from argparse import ArgumentParser
from csv import DictWriter
from requests import get
from sys import stdout
LIMIT = 1000
def main(tenant, observation_type, user, key, max_count=10000):
@bbayles
bbayles / multiprocessing_freeze_support.py
Created Mar 14, 2019
Multiprocessing Freeze Support Test
View multiprocessing_freeze_support.py
import sys
print('Arguments were', repr(sys.argv))
from argparse import ArgumentParser
import multiprocessing
from random import randrange
from time import sleep
def talk(x):
sleep(x)
@bbayles
bbayles / sign_modules.py
Last active Jan 22, 2019
Sign kernel modules for secure boot
View sign_modules.py
#!/usr/bin/env python
from __future__ import print_function
import io
import glob
import os
import subprocess
os.chdir(os.path.dirname(__file__))
priv_file = 'MOK.priv'
@bbayles
bbayles / skiptest.py
Created May 15, 2018
Demonstrate test skipping
View skiptest.py
import unittest
class SampleTest(unittest.TestCase):
def test_skipTest(self):
self.skipTest('lowecase')
def test_SkipTest(self):
raise unittest.SkipTest('UpperCase')
@bbayles
bbayles / bpo_21417.py
Last active Jan 22, 2019
Test for bpo21417 patch
View bpo_21417.py
# Tests for bpo-21417
import itertools
import os.path
import tempfile
import zipfile
# Compress a large-ish file, like the dictionary
file_path = '/usr/share/dict/american-english'
# Read its contents for later comparison
@bbayles
bbayles / tempo_change.py
Last active Jan 22, 2019
Speed up audio files with SoX
View tempo_change.py
from glob import iglob
from os import chdir
from os.path import join
from subprocess import check_call
infile_dir = "/path/somewhere"
chdir(infile_dir)
for file_path in sorted(iglob('*.mp3')):
print(file_path)
You can’t perform that action at this time.