View convert.sh
# 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 |
View restapi_load_from_csv.py
#!/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 |
View app.py
#!/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"]) |
View Dockerfile
FROM python:3.6-alpine | |
LABEL maintainer="Craig Derington <craig@craigderington.me>" | |
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"] |
View strings_compare.py
import os | |
import time | |
import uuid | |
import random | |
from datetime import datetime, timedelta | |
def get_message(): | |
return uuid.uuid4() |
View hash_file.py
import os | |
import hashlib | |
def sha256sum(filename): | |
""" | |
Create a file hash | |
:param: str (file path) | |
:return: str (md5 hash) | |
""" | |
h = hashlib.sha256() |
View asyncio-async-await.py
import asyncio | |
loop = asyncio.get_event_loop() | |
async def hello(): | |
await asyncio.sleep(3) | |
print('Hello!') | |
if __name__ == '__main__': | |
loop.run_until_complete(hello()) | |
View decorators_example.py
#! 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) |
View analyze.py
the_list = [1, 3, 7, 9, 12, 3, 9, 12, 9, 10, 14, 23, 12] | |
def analyze_list(l): | |
counts = {} | |
for item in l: | |
if item in counts: | |
counts[item] += counts[item] | |
else: | |
counts[item] = 1 |
View xor.py
# -*- coding: utf-8 -*-byte1 ^ byte2 ^ | |
# xor_final.py | |
# vars | |
checksum = 0 | |
checksum_xor = 0 | |
n = 2 | |
# raw data | |
radio_09010 = '02040d3031000010723320000a100000363303' |
NewerOlder