Skip to content

Instantly share code, notes, and snippets.

View carc1n0gen's full-sized avatar

Carson Evans carc1n0gen

View GitHub Profile
@carc1n0gen
carc1n0gen / Flask Makefile
Last active February 9, 2024 18:37
Makefile for a flask python web app
all: setup dev
setup:
test -d .venv || python -m venv .venv
. .venv/bin/activate; pip install -r requirements.txt
dev:
. .venv/bin/activate; flask --app app.create_app run --debug
### Keybase proof
I hereby claim:
* I am carc1n0gen on github.
* I am carsonthecanuck (https://keybase.io/carsonthecanuck) on keybase.
* I have a public key ASAOtLzpKuIVdO0kPyJwMP133KCZlYH1-4xLbX_ViL0F2go
To claim this, I am signing this object:
@carc1n0gen
carc1n0gen / dino.cow
Created May 31, 2022 13:53
Custom Cowfiles
##
## Dino
##
$the_cow = <<EOC
\\
\\
\\ ____
\\ /o___)
/ /-/
________/ /-/
@carc1n0gen
carc1n0gen / sarcasmify.py
Created April 29, 2022 19:24
Cli command to create sarcasm/mocking formatted texrt
#!/usr/bin/env python3
import sys
def sarcasmify(text):
new_text = ''
flip = True
for i in range(len(text)):
char = text[i]
if flip:
@carc1n0gen
carc1n0gen / sarcasmify_wsgi.py
Last active April 29, 2022 18:20
Plain WSGI API for converting text in to sarcasm/mocking format
from urllib.parse import parse_qs
def sarcasmify(text):
new_text = ''
flip = True
for i in range(len(text)):
char = text[i]
if flip:
new_text += char.lower()
else:
@carc1n0gen
carc1n0gen / flask-blueprint-subdomains.py
Last active February 19, 2021 15:30
Flask Blueprint Subdomains
from flask import Flask, Blueprint, url_for
app = Flask(__name__)
app.config['SERVER_NAME'] = 'app.local:5000'
bp1 = Blueprint('bp1', __name__, subdomain='app1')
bp2 = Blueprint('bp2', __name__, subdomain='app2')
@carc1n0gen
carc1n0gen / flask-domain-matching.py
Last active February 22, 2021 09:05
Flask Host Matching
from flask import Flask, url_for
app = Flask(__name__, host_matching=True, static_host='app1.local:5000')
@app.route('/', host='app1.local:5000')
def home1():
return url_for('home1')
@carc1n0gen
carc1n0gen / mail.py
Last active April 11, 2021 16:41
Custom Mailer
import smtplib
from email.message import EmailMessage
from flask import g, current_app
class Mailer():
def __init__(self, smtp_host=None, smtp_port=None, username=None,
password=None):
self._smtp_host = smtp_host
self._smtp_port = smtp_port
import smtpd
import asyncore
class FakeSMTPServer(smtpd.SMTPServer):
messages = []
def __init__(*args, **kwargs):
print('Fake smtp server running on port 2525')
smtpd.SMTPServer.__init__(*args, **kwargs)
GateNotDefined = type('GateNotDefined', (Exception,), {})
class Gatekeeper:
def __init__(self, gates={}, before=None):
self.gates = gates
self.before = before
def define(self, name, fn):
self.gates[name] = fn