This file contains hidden or 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
| # SETUP IN utils.py | |
| class NumParse(Enum): | |
| VAL = 1 # Valid number | |
| INV = 2 # Invalid number format | |
| NEG = 3 # Negative value | |
| ZER = 4 # Zero value | |
| EXC = 5 # Exceeds maximum value defined in config | |
| def __eq__(self, other: str): |
This file contains hidden or 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 logging | |
| import timeit | |
| logger = logging.getLogger(__name__) | |
| logging.basicConfig(filename='example.log', encoding='utf-8', level=logging.INFO) | |
| def as_args(): | |
| some_str = "This is some kind of error message reasonably long" |
This file contains hidden or 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 string import ascii_letters | |
| import timeit | |
| import numpy as np | |
| import pandas as pd | |
| letters = [ | |
| "".join(np.random.choice(list(ascii_letters), 10, replace=True)) | |
| for x in range(1000000) |
This file contains hidden or 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
| # File deliberately empty, but gist won't allow it |
This file contains hidden or 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
| # src/ex_machina/database.py | |
| import click | |
| import os | |
| from alembic import command | |
| from alembic.config import Config as AlembicConfig | |
| from alembic.util import AutogenerateDiffsDetected | |
| from sqlalchemy import create_engine, MetaData | |
| from sqlalchemy.orm import scoped_session, sessionmaker |
This file contains hidden or 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 sqlite3 | |
| import pandas as pd | |
| conn = sqlite3.connect(':memory:') | |
| c = conn.cursor() | |
| c.execute(""" | |
| CREATE TABLE food_labour ( | |
| name TEXT, |
This file contains hidden or 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 random | |
| import datetime as dt | |
| import pandas as pd | |
| df = pd.DataFrame({'date': ['2021-01-02', '2021-01-03', '2021-01-04', | |
| '2021-01-01', '2021-01-03', '2021-01-04', | |
| '2021-01-01', '2021-01-02', '2021-01-04', | |
| '2021-01-01', '2021-01-02', '2021-01-03'], | |
| 'plant': [1, 1, 1, |
This file contains hidden or 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
| # The contents of beatroute/src/beatroute/config.py | |
| import __main__ | |
| import json | |
| import os | |
| import sqlite3 | |
| import uuid | |
| from pathlib import Path |
This file contains hidden or 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
| SECRET_KEY = '2a057dd2f0844f5a928578032c5b9955' | |
| DB_URL = 'postgresql+psycopg2://postgres:######@127.0.0.1/so_test' |
This file contains hidden or 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 flask import Flask, render_template_string | |
| from flask_sqlalchemy import SQLAlchemy | |
| app = Flask('__name__') | |
| app.config['SQLALCHEMY_DATABASE_URI'] = 'postgresql+psycopg2://postgres:######@127.0.0.1/so_test' | |
| app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False | |
| app.config['SESSION_TYPE'] = 'sqlalchemy' |
NewerOlder