Skip to content

Instantly share code, notes, and snippets.

View ryanlong1004's full-sized avatar
💭
Around here somewhere...

Ryan Long ryanlong1004

💭
Around here somewhere...
View GitHub Profile
@ryanlong1004
ryanlong1004 / readme_bb.md
Created October 19, 2023 17:27
README_BB.md

For Big Brother, unfortunately we do not. Not the greatest tool. So for the OI monitoring content, I wrote a few Python scripts that grepped logs, did some comparison of strings, etc. Then I called those from a BASH script. The BASH script I had three strings, YELLOWLINES, GREENLINES, and REDLINES. So with the OI checking arrival time of products, I compared the ldmd.log file content to the nwwsoi.log file content grepping the individual product strings. Then the output of the app said how many products over 15 minutes and the average time to process. I have in the BASH, if the average time to process is > 20 seconds, go red, >10 go yellow, otherwise green.

Then at the bottom of the BASH SCRIPT, I have ################################################################################################################################

Final Message Section

################################################################################################################################

Calculate color

BB_MESSAGE=

@ryanlong1004
ryanlong1004 / README.md
Created March 16, 2023 17:22
Download website with wget

wget -r -np -k https://www.google.com

Other useful options:

-nd (no directories): download all files to the current directory
-e robots=off: ignore restrictions in robots.txt file and don't download robots.txt files
-A png,jpg: accept only files with the extensions png or jpg
-m (mirror): -r --timestamping --level inf --no-remove-listing
-nc, --no-clobber: Skip download if files exist
@ryanlong1004
ryanlong1004 / tweeter.py
Created January 17, 2023 18:18
Send tweets with Python and Tweepy.
""" Twitter convenience
"""
import collections
import logging
import os
import tweepy
ROOT_DIR = os.path.dirname(os.path.abspath(__file__))
ls -R | grep ":$" | sed -e 's/:$//' -e 's/[^-][^\/]*\//--/g' -e 's/^/ /' -e 's/-/|/'
@ryanlong1004
ryanlong1004 / view.py
Created June 21, 2022 19:34
CLI View
"""
view.py
CLI View layer
author: Ryan Long <ryan.long@noaa.gov>
"""
import argparse
import pathlib
@ryanlong1004
ryanlong1004 / timing.py
Created March 29, 2022 18:54
Easy python timing
import logging
import timeit
import time
def main():
start_time = timeit.default_timer()
# timed work here
time.sleep(1)
@ryanlong1004
ryanlong1004 / main.py
Created March 29, 2022 01:14
python logging basic
import logging
logging.basicConfig(
level=logging.DEBUG,
format="%(asctime)s %(name)-12s %(levelname)-8s %(message)s",
handlers=[logging.FileHandler("archive_results.log"), logging.StreamHandler()],
)
def main():
pass
@ryanlong1004
ryanlong1004 / git.py
Created March 29, 2022 00:52
Base Git Abstraction for Python
"""
git.py
Git CLI interaction layer
author: Ryan Long <ryan.long@noaa.gov>
"""
import logging
@ryanlong1004
ryanlong1004 / dbase.py
Created March 26, 2022 22:52
Quick Sqlite3 Implementation in Python
"""
gateway.py
Database interaction layer
author: Ryan Long <ryan.long@noaa.gov>
"""
import pathlib
import sqlite3
@ryanlong1004
ryanlong1004 / logs.py
Created January 28, 2022 23:35
Python CLI Logging Option
import logging
def handle_logging(args):
levels = {
"critical": logging.CRITICAL,
"error": logging.ERROR,
"warn": logging.WARNING,
"warning": logging.WARNING,
"info": logging.INFO,
"debug": logging.DEBUG,