Skip to content

Instantly share code, notes, and snippets.

View learnitall's full-sized avatar

Ryan Drew learnitall

  • Isovalent - Now Part of Cisco
  • Colorado
  • 22:30 (UTC -06:00)
View GitHub Profile
@learnitall
learnitall / update.py
Created February 28, 2024 19:06
Update mc plugins defined in default.nix
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import logging
import re
import shlex
import subprocess
import requests
from bs4 import BeautifulSoup
@learnitall
learnitall / import-windscribe.fish
Created January 29, 2024 15:48
import-windscribe.fish
#!/usr/bin/env fish
# Import .ovpn from Windscribe using NetworkManager
set -l target $argv[1]
set -l creds $argv[2]
echo Importing $target using $creds
set -l con_name (basename -s .ovpn $target)
set -l username (cat $creds | head -n 1)
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
status.py: Display status of resources in the terminal.
Requires rich and mctools. Developed on Python 3.10.
"""
from datetime import datetime
import time
from string import digits, printable
@learnitall
learnitall / k8s-openapi.sh
Created January 29, 2023 23:00
Generate K8s OpenAPI v3 Spec Using from a K8s API Server
#!/usr/bin/env bash
# ---
# k8s-openapi.sh
#
# Generate openapi v3 spec from a k8s apiserver and launch a swagger UI
# instance to check it out.
#
# Assumes that k8s api server has been proxied on localhost:8001
# (ie be sure to run `kubectl proxy` prior to execution).
#
@learnitall
learnitall / Dockerfile
Created July 22, 2021 23:17
snafu base image
ARG python=3.6.13
FROM registry.access.redhat.com/ubi8:latest AS snafu-python-build
ARG python
RUN dnf install -y --nodocs \
bzip2 \
bzip2-devel \
clang \
gcc \
git \
@learnitall
learnitall / .make_me_gui_bashrc
Created November 27, 2020 07:42
Annoying bashrc snippet that makes using the terminal horrendous. Place this file right at the tail end of a users' bashrc to give them 15 minutes of puzzling entertainment. Please contribute if you have ideas.
# https://unix.stackexchange.com/questions/250713/modify-all-bash-commands-through-a-program-before-executing-them
# $BASH_COMMAND contains the command bash is executing
# return 0 to allow $BASH_COMMAND to be evaled after function return
# return 1 to tell bash not to eval $BASH_COMMAND after function return
# requires figlet, cowsay and sl to be installed
shopt -s extdebug
preexec_invoke_exec () {
# do nothing if completing
[ -n "$COMP_LINE" ] && return
# do nothing if executing a command to issue a prompt
@learnitall
learnitall / upgrade_centos_8.yml
Created July 23, 2020 21:24
Upgrade Fresh Minimal Install of CentOS 7 to CentOS 8
---
# Upgrade CentOS 7 Hosts to CentOS 8
# Installs kernel from ElRepo for compatibility with deprecated hardware
#
# Instructions sourced from:
# https://www.centlinux.com/2020/01/how-to-upgrade-centos-7-to-8-server.html
# https://www.tecmint.com/upgrade-centos-7-to-centos-8/
#
# * We don't do rpmconf -a because this is on a clean, freshly installed 7
# * We do a package-cleanup at the end with dnf autoremove
@learnitall
learnitall / Un-censor Studydotcom.txt
Created March 16, 2016 01:48
Neat little trick to gain access to full lessons on study.com without a paid membership
Uncensoring study.com lessons is actually pretty simple- it only requires devling into the developer-tools in Google Chrome
NOTE: This trick only unblocks the lesson transcripts, I haven't explored getting access to the full lesson video yet.
Here are the steps:
1. Go to a lesson of choice on study.com and open the developer-tools in Chrome (example URL:
http://study.com/academy/lesson/root-cap-function-definition-quiz.html)
2. Use the page inspector tool and select the "Lesson Transcript" text. Confirm that in the Elements tab of the dev tools,
the line "<span>Lesson Transcript</span>" is highlighted (should be under a div that has the id "transcriptHeader")
3. Hit the dropdown triangles of "<div class="transcriptContainer articleContent" data-cname="main_content>" and
<div id="mainArticle" class="transcript" data-cname="lesson_transcript"> (the latter should appear after the contents of
@learnitall
learnitall / pre and postconditions in python.py
Created March 13, 2016 20:25
Applying pre and post conditions into python using decorators
# Pre and Post conditions in Java are done through comments a programmer puts
# around methods, or by raising errors directly in a function. However,
# if a group of functions need the same pre and post conditions, copying and pasting code
# can get tedious. In Python this problem can be avoided through the use of
# decorators. A template is laid out below:
def checkConditions(func):
def wrapped(*args, **kwargs):
if not (precondition_bool_expression):