Skip to content

Instantly share code, notes, and snippets.

View androiddrew's full-sized avatar
🎯
Focusing

Drew androiddrew

🎯
Focusing
  • AndroidDrew
  • Michigan
View GitHub Profile
@androiddrew
androiddrew / util.py
Last active November 6, 2017 22:07
Flask PulleyMethodView
# -*- coding: utf-8 -*-
"""
pulley.util
~~~~~~~~~~~
:copyright: (c) 2016 by Andrew Bednar.
"""
from flask.views import MethodView
from flask import request
@androiddrew
androiddrew / app.py
Created January 30, 2018 19:48
An example using apistar-mail and apistar_dramatiq for async mail sending
from apistar import Include, Route
from apistar.frameworks.wsgi import WSGIApp as App
from apistar.http import QueryParams
from apistar_mail import mail_component, Mail, Message
from apistar_dramatiq import actor
settings = {
'MAIL': {
'MAIL_SERVER': 'smtp.example.com',
'MAIL_USERNAME': 'me@example.com',
@androiddrew
androiddrew / apistar_util.py
Last active August 14, 2019 17:16
Apistar 0.4 Extended JSON Response, SQLAlchemy Component, and SQLAlchemy Hook
import datetime as dt
import decimal
import typing
from apistar import types
from apistar.http import JSONResponse, Response
from apistar.server.components import Component
from sqlalchemy.engine import Engine
from sqlalchemy.orm import sessionmaker, Session, scoped_session
@androiddrew
androiddrew / apistar_forms.py
Created May 19, 2018 17:29
Re-implementing the Multi-part Form Parser in APIStar >= 0.4
import io
import typing
from apistar import Component, http
from apistar.server.wsgi import WSGIEnviron
from werkzeug.datastructures import ImmutableMultiDict
from werkzeug.formparser import FormDataParser
from werkzeug.http import parse_options_header
from werkzeug.wsgi import get_input_stream
RequestStream = typing.NewType('RequestStream', io.BufferedIOBase)
#include <QGuiApplication>
#include <QQmlApplicationEngine>
int main(int argc, char *argv[]) {
QGuiApplication app(argc, argv);
QQmlApplicationEngine engine;
engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
return app.exec();
$orange: #f99e1a; //rgb(249,158,26)
$gray: #43484c; //rgb(67,72,76)
$navy-blue: #405275; //rgb(64,82,117)
$light-blue: #218ffe; //rgb(33,143,254)
$black: #000000; //rgb(0,0,0)
@androiddrew
androiddrew / .pre-commit-config.yaml
Created March 8, 2019 16:44
A basic pre-commit config file for python
defualt_stages: [commit, push]
fail_fast: true
repos:
- repo: https://github.com/ambv/black
rev: stable
hooks:
- id: black
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.1.0
hooks:
@androiddrew
androiddrew / passwords.sh
Created April 10, 2019 17:35
3 Ways to generate random passwords on Linux
# The recommendation is to always use a 14 character password. No clue why so small.
# Strings are in base 64 so you can type them out on a standard keyboard
#### OpenSSL ####
openssl rand 14 -base64
#### pwgen ####
# pwgen has a lot of options. check man pwgen.
# Creates a single password
@androiddrew
androiddrew / bootstrap.sh
Created April 28, 2019 14:25
A bootstrap script for a pip-tools based Python project.
#!/usr/bin/env bash
# setting -e to exit immediately on a command failure.
# setting -o pipefail sets the exit code of a pipeline to that of the rightmost command to exit with a non-zero status, or to zero if all commands of the pipeline exit successfully.
set -eo pipefail
# Most likely you will only need to change the path variables per your project structure.
DEV_REQ_PATH=./
REQ_PATH=./services/cms/
# Allow copy paste with "y"
bind P paste-buffer
bind-key -T copy-mode-vi v send-keys -X begin-selection
bind-key -T copy-mode-vi y send-keys -X copy-selection
bind-key -T copy-mode-vi r send-keys -X rectangle-toggle
# Enable mouse mode (tmux 2.1 and above)
set -g mouse on
# reload config file (change file location to your the tmux.conf you want to use)
bind r source-file ~/.tmux.conf