This file contains 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
#!/usr/bin/env -S bash -c "docker run -p 8080:8080 -it --rm \$(docker build --progress plain -f \$0 . 2>&1 | tee /dev/stderr | grep -oP 'sha256:[0-9a-f]*')" | |
# syntax = docker/dockerfile:1.4.0 | |
FROM node:20 | |
WORKDIR /root | |
RUN npm install sqlite3 |
This file contains 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 os | |
from fastapi import FastAPI | |
from sentry_sdk.integrations.asgi import SentryAsgiMiddleware | |
import sentry_sdk | |
sentry_sdk.init( | |
dsn='your Sentry dns', # CHANGE HERE | |
environment=os.getenv('ENV', 'dev'), # You should read it from environment variable |
This file contains 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 os, uuid | |
from io import BytesIO | |
from datetime import datetime | |
from urllib.parse import urlparse | |
from azure.storage.blob import BlobServiceClient | |
import pandas as pd | |
def azure_upload_df(container=None, dataframe=None, filename=None): | |
""" | |
Upload DataFrame to Azure Blob Storage for given container |
This file contains 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
Create a folder at the root of your app or project called ```.ebextensions``` | |
Inside the folder ```.ebextensions``` create a file called ```01_ffmpeg.config``` | |
Inside this file paste in the below contents: | |
``` | |
commands: | |
command1: | |
command: ls | |
command2: | |
command: "cd /usr/local/bin" |
This file contains 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
"""Task locking with redis in celery is hard, and good examples are tough to come by. This is the approach that's | |
worked for me, based on great work that other folks have posted: | |
* https://breadcrumbscollector.tech/what-is-celery-beat-and-how-to-use-it-part-2-patterns-and-caveats/ | |
* http://loose-bits.com/2010/10/distributed-task-locking-in-celery.html | |
* https://redis.io/topics/distlock | |
This isn't polished,but hopefully it's useful. To verify it in our local test env we register the following test task in | |
our definitions file: | |
*** definitions.py *** |
This file contains 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
AWSTemplateFormatVersion: '2010-09-09' | |
Transform: AWS::Serverless-2016-10-31 | |
Description: > | |
Sample SAM Template using Application Auto Scaling + Provisioned Concurrency | |
Globals: | |
Function: | |
Timeout: 30 |
This file contains 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 postgres:12 | |
# Create plpython3u when the db starts. | |
RUN echo 'CREATE EXTENSION IF NOT EXISTS plpython3u;' > /docker-entrypoint-initdb.d/py3.sql | |
# Installing last python and plpython3 for current version | |
RUN apt update && apt install python3 python3-pip postgresql-plpython3-${PG_MAJOR} -y | |
This file contains 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 sshtunnel import SSHTunnelForwarder | |
from pymongo import MongoClient | |
ssh_tunnel_host = 'our-ec2-hostname.compute-1.amazonaws.com' | |
ssh_tunnel_port = 22 | |
ssh_tunnel_user = 'ubuntu' | |
ssh_tunnel_pkey = 'ec2-hostname.pem' | |
db_user = 'database-user' | |
db_pass = 'database-pass' |
This file contains 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
name: CI | |
on: [push] | |
jobs: | |
test: | |
runs-on: ubuntu-latest | |
services: |
NewerOlder