Skip to content

Blog

Feel free to read random thoughts I've taken to writing down.

Discovery

OV-103: Discovery

The Space Shuttle Discovery was a NASA orbiter whose first mission was in 1984. A few interesting statistics about the shuttle.

  • 39 completed flights
  • Over 238,000,000 km traveled
  • 8,783 flight hours
  • 5,830 orbits around Earth completed

Soldering

Image of Discovery PCB

I picked up this soldering kit from the wonderful people over at Adafruit, the kit was designed and built by Phyx. The instructions provided on the product page for Adafruit are very helpful, pay attention to the polarity indicators on the PCB components and be sure you've dialed in your soldering iron to the appropriate temp. For my 63Sn/37Pb leaded no clean solder I used ~725 degrees Fahrenheit via my Hakko FX-888D. I will say that it was particularly disconcerting when I bent the LED leads at 90 degree angle, however there is a flat section of the leads that makes it easier.

Don't forget to review the assembled picture online to get a sense for the appropriate layout of each component. Soldering the large joints at the stand base and where the stand connects to the shuttle took a bit more heat and solder obviously to get a solid joint established.

Testing

I have a multimeter which was handy to verify connectivity between soldered connections. In addition you can simply turn the device on and verify that the LEDs are powered and flickering.

Image of Finished Discovery Model

References

Podcasts

I use the Pocket Casts app to download a few podcasts I listen to, however I also wanted to download and keep all the episodes from some of these podcasts as an archive if you will on my machine. Space is limited on my phone where I do most of my podcast listening but I've got ample space on my primary machine.

Thus I wrote a small python podcast downloader that takes the RSS URL, parses the feed and its entries, identify the actual download link and downloads to a directory of my choosing if the episode isn't already downloaded.

A few packages that I found super useful when writing this are:

  • rich
  • feedparser
  • requests
  • pathlib
  • argparse

argparse and pathlib are part of the standard library but Rich, Feedparser and Requests you'll have to install.

Install dependencies

poetry add feedparser
poetry add rich
poetry add requests
poetry install

Example run

poetry run python .\download_podcast_episodes.py "C:\Podcasts\"

Example output if you enable warnings just to verify you've already got files downloaded.

Output showing files are already downloaded

{{< gist axi0m be404e2aae6cd78b4db7fe1ed7b2d3c5 >}}

Rich

If you find yourself constantly creating command-line interfaces and have not heard of rich, take a few hours next week and play with it!

Historically I've used termcolor and colorama to handle the pretty terminal colors in Python programs I write but now that I've discovered rich I'm not sure I'll ever go back. The project is well-maintained, feature rich and Will the author seems to have put a lot of effort into it.

Install

I prefer to use pipenv but you can use normal pip or poetry too of course.

pip install rich
pipenv install rich

Usage

This is mentioned in detail on the README for Rich but this was the most immediately useful example I took away for my CLI programs.

from rich.console import Console

console = Console()

console.print(f'[+] Building the mechtronics matrix splicer...', style="bold green")

In addition there is a wonderful track() function you can use to wrap around an iterator and have rich progress bars in your console. I have used this in some non-public programs but have yet to add it to anything that's on my GitHub repos or Gists.

Replacing Tabulate

I blogged about using the package tabulate previously when I developed a small API client to interact with AWS EC2 resources using boto3 but after finding the rich package I think I'm goint to explore using its table rendering features instead.

References

Tabulate

Tabulate is a handy Python package on PyPI you can install to make fancy terminal tables.

Install

With pipenv

pipenv install tabulate

With pip and virtualenv

virtualenv tabulate
pip install tabulate --user

Example

Take a list of lists, and use tabulate to create pretty terminal tables. I created a simple file called tabulate_example.py in a dedicated venv.

from tabulate import tabulate

example_list = [["Beverly Hills","California", "United States"],["Minneapolis", "Minnesota", "United States"],["Chicago","Illinois","United States"]]

print(tabulate(example_list, headers=["City","State","Country"], tablefmt="pretty"))

Windows

pipenv run python .\tabulate_example.py

Output

tabulate output

Use Case

I recently found myself having to interact with AWS APIs and was manipulating the data structures in response and wanted to display a fairly large amount of items in my terminal.

About

Hello! 👋

For my day job I work at a Fortune 500 company helping with offensive security and network security monitoring. I am a consummate student of Information Security/Cybersecurity. My current focus areas include Red Team Ops, Infrastructure, and Python. Historically I've worked on large scale enterprise SIEM deployments, full-packet capture systems, forward and reverse proxies, etc.

When I'm not working I spend my time playing RPG games 🧙‍♂️, board games 🎲, and watching Sci-Fi films 👾.