Skip to content

Instantly share code, notes, and snippets.

View caffeinatedMike's full-sized avatar

Michael Hill caffeinatedMike

View GitHub Profile
@e-kondr01
e-kondr01 / README.md
Last active February 18, 2024 18:16
Pytest + FastAPI + Async SQLAlchemy

Run API tests with Pytest, FastAPI and Async SQLAlchemy. Changes made in test functions are not persisted to DB, even if await session.commit() is called. This allows tests to be independent, able to run in parallel or in a shuffled order without affecting the result.

This snippet does not include creation of DB tables, as I use Alembic for migration management and advise you to do the same (even in tests).

@m4rk4
m4rk4 / espn-fcast
Created October 30, 2020 01:53
espn-fcast
var socket;
var fcastUrl;
fetch('https://fastcast.semfs.engsvc.go.com/public/websockethost')
.then(
function(response) {
if (response.status !== 200) {
console.log('Looks like there was a problem. Status Code: ' + response.status);
return;
}
@finnmglas
finnmglas / bootstrap-shields-badges.html
Last active August 28, 2023 15:08
Bootstrap badges like on shields.io
<!-- Create badges / shields like on shields.io
-- but with bootstrap.
--
-- Fully adjustable, use this for whatever you want ^^
--
-- Finn M Glas, 2020-07-06
-->
<!-- Regular badges (value-only) -->
@vulcan25
vulcan25 / README.md
Last active November 29, 2022 14:11
Flask + sqlalchemy declarative base example

TODO: write readme

@jefftriplett
jefftriplett / python-django-postgres-ci.yml
Last active March 27, 2024 04:27
This is a good starting point for getting Python, Django, Postgres running as a service, pytest, black, and pip caching rolling with GitHub Actions.
name: CI
on: [push]
jobs:
test:
runs-on: ubuntu-latest
services:
@rms1000watt
rms1000watt / jinja2-omit-comma-from-item.txt.j2
Created October 18, 2019 21:10
Jinja2 omit comma from last item in list
# Courtesy of: https://stackoverflow.com/a/11974399
{%- for item in items %}
[
"{{item}}"{{ "," if not loop.last }}
]
{%- endfor %}
@M0r13n
M0r13n / render.html
Last active October 6, 2023 06:32
A sample Wtforms field for creating a list of tags with custom separators, e.g. "," or " ".
<form action="" method="POST" role="form" class="form">
{{ form.hidden_tag() }}
<!--Other fields-->
{{ wtf.form_field(form.tags, placeholder='audio, hardware, chip') }}
<button class="btn btn-success" type="submit">submit</button>
</form>
@Sklavit
Sklavit / mock.methods.py
Last active November 8, 2023 09:53
Mock examples
# @ https://cheat.readthedocs.io/en/latest/python/mock.html
obj.call_count # number of times it was called
obj.called == obj.call_count > 0
obj.call_args_list # a list of (args,kwargs), one for each call
obj.call_args # obj.call_args_list[-1] (args,kwargs from last call)
obj.return_value # set to what it should return
obj.side_effect # set to an exception class or instance that should be raised when its called
obj.assert_called() # doesn't work with autospec=True? just assert obj.called
obj.assert_called_with(*args, **kwargs) # last call was with (*args, **kwargs)
from trello import TrelloClient
import requests
API_KEY = ""
API_SECRET = ""
TOKEN = ""
BOARD_NO = 0
LIST_NO = 10
@frenck
frenck / hassio_ubuntu_install_commands.sh
Last active February 1, 2023 05:38
Simple install command for installing Hass.io on a Generic Ubuntu/Debian machine
Unbuntu is no longer support by the Home Assistant project.
The installation commands previous listed here, are not up 2 date, not recommended, not supported and, therefore, removed.