Skip to content

Instantly share code, notes, and snippets.

@cmabastar
cmabastar / app.py
Created Jul 23, 2020
CloudFlare access decorator for flask auth
View app.py
@bp.route("/", methods=["GET", "POST"])
@cf_verify_token
def admin():
pass
@cmabastar
cmabastar / client.conf
Created Jul 22, 2020 — forked from apearson/client.conf
Wireguard on FreeBSD with pf
View client.conf
[Interface]
PrivateKey = ***********************
Address = 192.168.10.2/32, fc::2/128
DNS = 1.1.1.1, 2606:4700:4700::1111
[Peer]
PublicKey = ***********************
AllowedIPs = 0.0.0.0/0, ::/0
Endpoint = endpoint.domain.tld:51820
@cmabastar
cmabastar / alembic_migration.py
Created Jun 7, 2020
Sqalchemy + Alembic + Postgres Unlogged Table Example
View alembic_migration.py
op.create_table(
"unlogged_table",
sa.Column("id", sa.BigInteger(), nullable=False),
sa.PrimaryKeyConstraint("id", name=op.f("pk_unlogged_table")),
prefixes=["UNLOGGED"],
)
@cmabastar
cmabastar / Procfile
Created May 31, 2019
Running honcho or procfile for db migrate in flask
View Procfile
scheduler: flask db upgrade && flask rq scheduler -v
worker_a: flask rq worker -v
worker_b: flask rq worker -v
worker_c: flask rq worker -v
@cmabastar
cmabastar / Dockerfile
Created May 31, 2019
Docker graceful shutdown for honcho and flask
View Dockerfile
FROM python:latest
RUN mkdir -p /app
WORKDIR /app
RUN python -m venv venv
ENV VIRTUAL_ENV /venv
ENV PATH /venv/bin:$PATH
ADD requirements.txt /app/requirements.txt
View docker-compose.diff
diff --git a/backend/docker-compose.yml b/backend/docker-compose.yml
index c45ae579..c47fcf14 100644
--- a/backend/docker-compose.yml
+++ b/backend/docker-compose.yml
@@ -46,6 +46,9 @@ services:
- new_db
- redis
# - corenlp
+ networks:
+ - default
@cmabastar
cmabastar / rc.conf
Created Sep 29, 2016
lenovo x230 freebsd settings
View rc.conf
#
# See /etc/defaults/rc.conf to add more option.
# Do not configure /etc/defaults/rc.conf.
# Configure only this file.
#
# Power saver.
powerd_enable="YES"
performance_cx_lowest="C3"
@cmabastar
cmabastar / t2.micro via local
Last active Jul 12, 2016
Redis Benchmark on Freebsd 10.3
View t2.micro via local
redis-benchmark -q -n 100000
PING_INLINE: 34891.84 requests per second
PING_BULK: 35223.67 requests per second
SET: 38124.29 requests per second
GET: 41841.00 requests per second
INCR: 41911.15 requests per second
LPUSH: 42140.75 requests per second
LPOP: 38850.04 requests per second
SADD: 37119.52 requests per second
SPOP: 41271.15 requests per second
@cmabastar
cmabastar / haproxy.conf
Created Jun 17, 2016
Haproxy for flask-socketio
View haproxy.conf
global
daemon
defaults
mode http
log global
option httplog
option http-server-close
option dontlognull
option redispatch
@cmabastar
cmabastar / .pgsqlrc
Created Oct 28, 2015
cool psql settings
View .pgsqlrc
\set COMP_KEYWORD_CASE upper
\x auto
\pset null ¤
You can’t perform that action at this time.