Skip to content

Instantly share code, notes, and snippets.

@cmabastar
cmabastar / app.py
Created June 15, 2022 05:04
Flask Celery 5 Application Factory Pattern
from flask import Flask
from app.extensions import *
CELERY_CONFIG = {
"broker_url": "redis://localhost:6379/1",
"result_backend": "redis://localhost:6379/0",
}
def create_app()
app = Flask('name')
@cmabastar
cmabastar / g2 logs
Created May 26, 2022 02:01
g2 logs
127.0.0.1 - - [2022-05-26 09:51:10] "GET /api/g2/search?num_result=250&qs=vicks&freq_count=5&gpt3_calls=3&debug=false HTTP/1.1" 200 142 6.403518
2[2022-05-26 09:51:24 +0800] [77761] [INFO] message='Request to OpenAI API' method=post path=https://api.openai.com/v1/engines/text-davinci-002/completions
[2022-05-26 09:51:24 +0800] [77761] [INFO] message='Request to OpenAI API' method=post path=https://api.openai.com/v1/engines/text-davinci-002/completions
[2022-05-26 09:51:24 +0800] [77761] [INFO] message='Request to OpenAI API' method=post path=https://api.openai.com/v1/engines/text-davinci-002/completions
[2022-05-26 09:51:26 +0800] [77761] [INFO] message='OpenAI API response' path=https://api.openai.com/v1/engines/text-davinci-002/completions processing_ms=1101 response_code=200
[2022-05-26 09:51:26 +0800] [77761] [INFO] message='OpenAI API response' path=https://api.openai.com/v1/engines/text-davinci-002/completions processing_ms=1395 response_code=200
[2022-05-26 09:51:26 +0800] [77761] [INFO] message='OpenA
We can make this file beautiful and searchable if this error is corrected: No commas found in this CSV file in line 0.
https://www.linkedin.com/in/adrien-p%C3%A9ligry-9b9241137/
https://www.linkedin.com/in/albert-bielinko-4070a729/
https://www.linkedin.com/in/alison-flemming-996bb427/
https://www.linkedin.com/in/aishwarya-iyer-44112a19a/
https://www.linkedin.com/in/anton-kraminkin-b21181b3/
https://www.linkedin.com/in/aharon-friedman-880a1047/
https://www.linkedin.com/in/alex-espinoza-703958159/
https://www.linkedin.com/in/anton-reimertz-091a4630/
https://www.linkedin.com/in/antonio-groza-025366182/
https://www.linkedin.com/in/alvis-anovari-a8619015a/
@cmabastar
cmabastar / nightvision
Created October 28, 2021 01:28
nightvision bug
token_payload={'hl': 'en-US', 'tz': 0, 'req': '{"comparisonItem": [{"keyword": "PocketOption", "geo": "", "time": "2016-10-30 2021-10-25"}, {"keyword": "PocketOption", "geo": "",
"time": "2016-11-06 2021-10-25"}, {"keyword": "PocketOption", "geo": "", "time": "2016-11-13 2021-10-25"}, {"keyword": "PocketOption", "geo": "", "time": "2016-11-20 2021-10-25"
}, {"keyword": "PocketOption", "geo": "", "time": "2016-11-27 2021-10-25"}], "category": 0, "property": ""}'}
[ time formattedTime value formattedValue isPartial
0 1477785600 Oct 30 – Nov 5, 2016 0 0 False
1 1478390400 Nov 6 – 12, 2016 0 0 False
2 1478995200 Nov 13 – 19, 2016 0 0 False
3 1479600000 Nov 20 – 26, 2016 0 0 False
4 1480204800 Nov 27 – Dec 3, 2016 0 0 False
.. ... ... ... ... ...
─[ RECORD 1 ]┬─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
id │ 10279706
seed │ brow soap
is_complete │ t
batch_id │ 54
created_at │ 2021-09-19 15:31:04.093462+00
updated_at │ 2021-09-19 15:31:04.736577+00
prefix_terms │ {" ": ["revolution *", "how to use *", "lash *", "bushy *", "how to make *", "essence *", "pears *", "diy *", "lash * mydło do stylizacji brwi", "makeup revolution *"]}
suffix_terms │ {" ": ["* bar", "* ulta", "* ingredients", "* boots", "* australia", "* watsons", "* mecca", "* sephora", "* superdrug", "* target"]}
─[ RECORD 2 ]┼─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
@cmabastar
cmabastar / WireGuard-site-to-site.md
Created March 19, 2021 02:34
Accessing a subnet that is behind a WireGuard client using a site-to-site setup

WireGuard Site-to-Site

Accessing a subnet that is behind a WireGuard client using a site-to-site setup

Problem Summary

We want to access a local subnet remotely, but it is behind a NAT firewall and we can't setup port forwarding. Outgoing connections work, but all incoming connections get DROPPED by the ISP's routing policy.

Solution Summary

@cmabastar
cmabastar / app.py
Created July 23, 2020 13:37
CloudFlare access decorator for flask auth
@bp.route("/", methods=["GET", "POST"])
@cf_verify_token
def admin():
pass
@cmabastar
cmabastar / client.conf
Created July 22, 2020 08:08
Wireguard on FreeBSD with pf
[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 June 7, 2020 22:57
Sqalchemy + Alembic + Postgres Unlogged Table Example
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 19:38
Running honcho or procfile for db migrate in flask
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