This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import hashlib | |
import uuid | |
import hmac | |
from datetime import datetime, timedelta | |
my_api_key = os.urandom(64) | |
def verify(api_key, token, timestamp, signature): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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"]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<VirtualHost *:80> | |
# listen for non-www, redirect to non-www | |
ServerName domainname.com | |
Redirect permanent / http://www.domainname.com | |
</VirtualHost> | |
<VirtualHost *:80> | |
ServerName www.domainname.com | |
ServerAdmin alias@domainame.com | |
DocumentRoot /var/www/html/sitename |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import fastf1 as ff1 | |
from fastf1 import plotting | |
from fastf1 import utils | |
from matplotlib import pyplot as plt | |
from matplotlib.pyplot import figure | |
import numpy as np | |
import pandas as pd | |
# enable the cache | |
ff1.Cache.enable_cache('cache') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def recursive_dict_get(d, *keys, default_none=False): | |
"""Recursive dict get. Can take an arbitrary number of keys and returns an empty | |
dict if any key does not exist. https://stackoverflow.com/a/28225747""" | |
ret = reduce(lambda c, k: c.get(k, {}), keys, d) | |
if default_none and ret == {}: | |
return None | |
else: | |
return ret |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from signalr_aio import Connection | |
from base64 import b64decode | |
from zlib import decompress, MAX_WBITS | |
import json | |
# decode the payload | |
def process_message(message): | |
deflated_msg = decompress(b64decode(message), -MAX_WBITS) | |
return json.loads(deflated_msg.decode()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% extends "layout.html" %} | |
{% block title %} | |
Reddit Reader | Public Timeline | |
{% endblock %} | |
{% block body %} | |
<h2><i class="fa fa-reddit-square"></i> Recent Reddits | |
<a style="margin-left:5px;" href="#menu-toggle" class="btn btn-default" id="menu-toggle"><i class="fa fa-toggle-left"></i> Toggle Menu</a> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import asyncio | |
class EchoClientProtocol(asyncio.Protocol): | |
def __init__(self, message, loop): | |
self.message = message.encode() | |
def connection_made(self, transport): | |
self.transport = transport | |
self.write_data() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// coding: utf-8 | |
// example 1 | |
// string length | |
// given the following string, 'this example string', write the string length to the console | |
var string = 'this example string'; | |
console.log(string.length); |
NewerOlder