Skip to content

Instantly share code, notes, and snippets.

View craigderington's full-sized avatar
🚀
Automate Everything

Craig Derington craigderington

🚀
Automate Everything
View GitHub Profile
# alacritty
env:
TERM: xterm-256color
window:
dimensions:
columns: 120
lines: 48
padding:
x: 10
# ~/.config/starship.toml
add_newline = false
[line_break]
disabled = true
[username]
format = "[$user]($style)"
style_user = "bold bright blue"
show_always = true
# convert all downloaded media to mp3
# rename all converted files to remove {webm,mkv,mp4} from filenames
# echo file conversion list
# then delete everything but the newly converted mp3
echo "starting up, get list of files, please be patient..."
ls | echo "Found $(wc -l) media files for conversion in the present working directory." | xargs
echo "starting mp3 conversion with ffmpeg and libmp3lame."
for i in *.{webm,mkv,mp4}; do
ffmpeg -i "$i" -acodec libmp3lame "$(basename "${i/.{webm,mkv,mp4}")".mp3
@craigderington
craigderington / restapi_load_from_csv.py
Last active October 29, 2019 21:00
Read in a CSV file and POST the data to an API Endpoint
#!/usr/bin/python
import argparse
import csv
import json
import os
import requests
import sys
from requests.auth import HTTPBasicAuth
from urllib.parse import urlparse
@craigderington
craigderington / app.py
Created September 12, 2019 21:40
Python + Flask + Redis - Page Hit Counter
#!/usr/bin/python
from flask import Flask
from redis import Redis
app = Flask(__name__)
redis = Redis(host="172.17.0.2", port=6379)
@app.route("/", methods=["GET"])
@craigderington
craigderington / Dockerfile
Last active June 24, 2021 00:56
Build image for Flask Redis Counter
FROM python:3.6-alpine
LABEL maintainer="Craig Derington <craigderington17@gmail.com>"
RUN apk update && apk upgrade
RUN apk add screen curl
COPY . /app
WORKDIR /app
RUN pip install -r requirements.txt
EXPOSE 8000
CMD ["python", "app.py"]
@craigderington
craigderington / strings_compare.py
Created July 12, 2019 17:34
Python while True loop updating Incoming Message UUID when Certain Conditions Exist
import os
import time
import uuid
import random
from datetime import datetime, timedelta
def get_message():
return uuid.uuid4()
@craigderington
craigderington / hash_file.py
Created May 6, 2019 17:52
Create a Hash of a File
import os
import hashlib
def sha256sum(filename):
"""
Create a file hash
:param: str (file path)
:return: str (md5 hash)
"""
h = hashlib.sha256()
import asyncio
loop = asyncio.get_event_loop()
async def hello():
await asyncio.sleep(3)
print('Hello!')
if __name__ == '__main__':
loop.run_until_complete(hello())
@craigderington
craigderington / decorators_example.py
Created March 14, 2019 19:40
Python Decorator Example
#! usr/bin/python3.6
# coding: utf-8
import time
from functools import wraps
def my_logger(func):
import logging
logging.basicConfig(filename='{}.log'.format(str(func.__name__)), level=logging.DEBUG)