Skip to content

Instantly share code, notes, and snippets.

View jangia's full-sized avatar

Jan Giacomelli jangia

View GitHub Profile
import boto3
from boto3.dynamodb.conditions import Key
from pydantic import BaseModel, ValidationError
from pydantic import EmailStr
from flask import Flask, jsonify, request, Response
app = Flask(__name__)
@jangia
jangia / App.svelte
Last active November 10, 2020 18:41
<script>
import Auth from '@aws-amplify/auth';
import { onMount } from 'svelte';
import axios from 'axios';
Auth.configure(
{
Auth: {
region: 'region',
userPoolId: 'pool_id',
userPoolWebClientId: 'client_id'
import datetime
from fastapi import FastAPI
from pydantic.main import BaseModel
app = FastAPI()
class CreateTodo(BaseModel):
name: str
service: my-service
provider:
name: aws
region: ${opt:region, 'eu-west-1'}
stage: ${opt:stage, 'development'}
plugins:
- serverless-s3-sync
with open('example.txt') as file:
lines = file.readlines()
for line in lines:
if line.lower().startswith('t'):
print(line)
@jangia
jangia / user.py
Created December 28, 2020 21:52
SRP violated
import datetime
class User:
def __init__(self, username, banned_until):
self.username = username
self.banned_until = banned_until
def save(self):
print('I am saving to PostgreSQL')
def my_function():
print('Hi')
print(my_function)
# <function my_function at 0x7efea5c36050>
def send_email_ses(email_message):
print(f'Send email using AWS SES: {email_message}')
class Stick:
def __init__(self, color, length, weight):
self.color = color
self.length = length
self.weight = weight
stick = Stick('yellow', 1, 0.324)
@jangia
jangia / models.py
Last active March 18, 2024 17:22
Testing behavior, not implementation details – Testing implementation Details
# implementation_details/models.py
from dataclasses import dataclass
from enum import Enum
class TaskStatus(str, Enum):
OPEN = "OPEN"
CLOSED = "CLOSED"
@jangia
jangia / models.py
Created March 18, 2024 17:24
Testing behavior, not implementation details – Testing Behavior
# behavior/models.py
from dataclasses import dataclass
from enum import Enum
class TaskStatus(str, Enum):
OPEN = "OPEN"
CLOSED = "CLOSED"