Skip to content

Instantly share code, notes, and snippets.

View Sparrow1029's full-sized avatar
💭
Always learning to code

Alex Ray Sparrow1029

💭
Always learning to code
  • Charter Communications
  • Denver, CO
View GitHub Profile
@Sparrow1029
Sparrow1029 / check_memory.sh
Last active April 6, 2024 14:06
Use /proc/meminfo file to check available memory for system and warn based on given argument thresholds
#!/bin/bash
# Set thresholds from script args
WARN_THRESHOLD=$1
CRIT_THRESHOLD=$2
# Find current memory status from /proc/meminfo
current=$(head -n 3 /proc/meminfo)
memtotal=$(expr $(echo $current | awk '{ print $2 }') / 1024)
memfree=$(expr $(echo $current | awk '{ print $5 }') / 1024)
@Sparrow1029
Sparrow1029 / base64.py
Created July 12, 2019 17:26
Implementation of Base64 encoding in Python3
#!/usr/bin/env python3
"""Script to encode & decode strings to and from Base64"""
import sys
import argparse
CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"
PAD = "="
LINE_WIDTH = 76
@Sparrow1029
Sparrow1029 / bs4Scrape_example.py
Last active July 12, 2019 17:26
Python Code Challenge 19 - scrape web article with requests and BS4
#!/usr/bin/env python3
"""
https://www.practicepython.org/exercise/2014/07/14/19-decode-a-web-page-two.html
----------------------------------------------
Exercise 19 - Decode a webpage part 2
----------------------------------------------
Monica Lewinsky Vanity fair article:
https://www.vanityfair.com/style/society/2014/06/monica-lewinsky-humiliation-culture
"""
@Sparrow1029
Sparrow1029 / RC4_bruteforce.py
Last active May 15, 2019 20:14
Script that uses python 3 multiprocessing module to attempt brute-force of RC4-encrypted strings.
#!/usr/bin/env python3
# This script requires the chardet library for python3
# the RC4 implementation used in this script is attributed to Ryosuke Ito
# it (and installation instructions) can be found at https://github.com/manicmaniac/arc4.git
import sys
from arc4 import ARC4
import chardet
from string import ascii_uppercase, ascii_lowercase, digits
from itertools import product
@Sparrow1029
Sparrow1029 / decode.py
Created March 25, 2019 22:51
Decode base64 until flag is found
#!usr/bin/env python3
from base64 import b64decode
f = open('lol.txt', 'r')
string = str(f.read())
f.close()
print("Decoding...")
while True:
@Sparrow1029
Sparrow1029 / genhash.py
Created March 24, 2019 23:09
Increment a number and hash it using chosen algorithm to find partial collisions
#!/usr/bin/env python3
import hashlib
import whirlpool
import sys
algo = sys.argv[1]
target = sys.argv[2]
def gen_hash(algo, target):
@Sparrow1029
Sparrow1029 / plex.sh
Created July 13, 2018 03:39
Plex Media Server helper script - bash
#!/bin/bash
# This script makes it easier to activate and restart plexmediaserver from
# the command line, as well as enabling/disabling the server at boot.
read -d '' USAGE << EOF
usage: plex start|stop|disable|enable|status
help - print this text and exit.
start|stop - start and stop plexmediaserver service (active|inactive)
enable|disable - toggle plexmediaserver at system start (enabled|disabled)
@Sparrow1029
Sparrow1029 / graphics.py
Created February 13, 2018 06:20
PyBites Code Challenge 10 - hangman game
def hang_graphics():
"""graphs from https://gist.github.com/devdarren/4199441"""
yield """
________
| |
|
|
|
|"""
yield """
@Sparrow1029
Sparrow1029 / .gitignore
Last active December 22, 2017 06:12
Advent of Code 2017 - Day 1
*.pyc
__pycache__/
.DS_Store
__MACOSX__
*.pyo
*.swp
adventbase.py
*input.txt
@Sparrow1029
Sparrow1029 / check_win.py
Created November 12, 2017 21:29
(Practice Python) Check win state in a game of tic-tac-toe using matrices
#!/usr/bin/env python3
#-*- coding: utf-8 -*-
"""
Check matrix list for win in Tic-tac-toe
"""
from itertools import chain
winner_is_1 = [[1, 2, 0],
[2, 1, 0],