Skip to content

Instantly share code, notes, and snippets.

service: fb-notification-service # Name of the service
useDotenv: true # We want to get the env variables from our .env
provider:
name: aws # provider we want to use
runtime: python3.8 # runtime we want to use // python3.9 does not work currently
memorySize: 128 # memory size, 128 is the lowest, scales performance
region: eu-central-1
stage: ${opt:stage, 'production'} # is used in the name
from monitoring import api, crypto, webpage
from notifications import send_sms, send_email, send_to_slack
def run():
# monitoring - uncomment the one you want to use
msg = api.check_exchange_rate()
# msg = crypto.check_available_mim()
# msg = webpage.find_add_to_cart_button()
import requests
import os
from dotenv import load_dotenv
from datetime import datetime
load_dotenv()
def send_sms(msg: str) -> None:
URL = os.getenv("SLACK_WEBHOOK")
import os
from twilio.rest import Client
from dotenv import load_dotenv
load_dotenv()
def send_sms(msg: str, recipient: str = None) -> None:
client = Client(os.getenv("TWILIO_SID"), os.getenv("TWILIO_AUTH"))
client.messages.create(
import os
import smtplib, ssl
from dotenv import load_dotenv
load_dotenv() # take environment variables from .env.
PORT = 465
def send_email(msg: str, recipient: str = None) -> None:
email = os.getenv("EMAIL")
import json
from typing import Optional
import requests
URL = "https://api.avax.network/ext/bc/C/rpc"
# Payload retrieved from monitoring network calls when running `balanceOf` on this contract:
# https://snowtrace.io/address/0xf4f46382c2be1603dc817551ff9a7b333ed1d18f#readContract
# address 1 is the address of the MIM Token (0x130966628846bfd36ff31a822705796e8cb8c18d)
from typing import Optional
from bs4 import BeautifulSoup
import requests
URL = "https://www.everdrop.de/products/handburste-aus-fsc-zertifiziertem-buchenholz-und-pflanzlichen-borsten"
# URL = "https://www.everdrop.de/products/everdrop-glastiegel" (this one is available at time of writing)
def find_add_to_cart_button(url: str = None) -> Optional[str]:
@FBosler
FBosler / exchange_rate_checker.py
Created December 4, 2021 16:57
minimal working example to pull exchange rates from free (ECB) endpoint
from typing import Optional
from numbers import Number
from xml.dom.minidom import parseString
import requests
SETTINGS = {
"currency": "THB",
"threshold": 35,
"message": "The current exchange rate for EUR/{currency} is {value}",
}
@FBosler
FBosler / solution.py
Last active October 16, 2022 14:10
foobar_dodge_the_lasers
from decimal import Decimal, localcontext
def solution(s):
n = Decimal(s)
with localcontext() as ctx:
ctx.prec = 102
r = Decimal(2).sqrt()
s = Decimal(2) + Decimal(2).sqrt()
def solve(n):
@FBosler
FBosler / recursive_solution.ipynb
Last active July 9, 2021 16:41
foobar_dodge_the_lasers
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.