Skip to content

Instantly share code, notes, and snippets.

@stabacco
stabacco / flask_sqlalchemy_debug_queries.py
Last active March 24, 2022 22:32
sqlalchemy debug queries
@app.after_request
def after_request(response: flask.Response):
from flask_sqlalchemy import get_debug_queries
app.config['SQLALCHEMY_RECORD_QUERIES'] = app.config['DEBUG']
app.logger.debug("%s", response.__dict__)
count = 0
for query in get_debug_queries():
if query.duration >= 0:
count +=1
@stabacco
stabacco / esptools.sh
Last active July 29, 2021 11:31
ESP32 installation
# Install esptool
pip install esptool
# Flash the ESP32 module, it will erase everything on it.
python -m esptool --port COM5 erase_flash
# Install the micropython firmware
python -m esptool --port COM5 write_flash -z 0x1000 C:\Users\tabac\Downloads\esp32-20210623-v1.16.bin
@stabacco
stabacco / firebase-messaging-sw.js
Last active April 23, 2021 01:53
firebase example
importScripts('https://www.gstatic.com/firebasejs/8.3.2/firebase-app.js');
importScripts('https://www.gstatic.com/firebasejs/8.3.2/firebase-messaging.js');
var firebaseConfig = {
apiKey: "whatever",
authDomain: "notifications-test-stefano.1.com",
projectId: "notifications-test-1",
storageBucket: "notifications-test-1.appspot.com",
messagingSenderId: "maybe",
appId: "whoknows",
@stabacco
stabacco / motion.conf
Last active January 1, 2021 10:40
RPI motion
# Rename this distribution example file to motion.conf
#
# This config file was generated by motion 4.0
############################################################
# Daemon
############################################################
# Start in daemon (background) mode and release terminal (default: off)
@stabacco
stabacco / .pre-commit-config.yaml
Created September 24, 2020 12:20
pre-commit.yaml
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.1.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: check-added-large-files
@stabacco
stabacco / visualstudio.ahk
Created September 16, 2020 10:54
Visual Studio AutoKey DELL
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
#IfWinActive ahk_class Chrome_WidgetWin_1 ; Visual studio code
PgUp::
Send, {Left down} ; If PageUp is sent, replace it with a Left button press
return
@stabacco
stabacco / convert_readme.sh
Last active September 9, 2020 00:59
Readme MD to RST with docker
# CD to the README.md diretory
docker run -v `pwd`:`pwd` -w `pwd` pandoc/alpine --from=markdown --to=rst --output=README.rst README.md
@stabacco
stabacco / stake.json
Last active December 14, 2021 20:15
{
"scheduled.stakes.buy":
{
"VGT": { "dailyReturnPercentage": -5.0, "cashAmount": 15000 },
"MSFT": { "dailyReturnPercentage": -5.0, "cashAmount": 2000 },
"ASAN": { "dailyReturnPercentage": -20.0, "cashAmount": 2000 },
"TSLA": { "dailyReturnPercentage": -20.0, "cashAmount": 2000 },
}
}
@stabacco
stabacco / stefano.postfixTemplate
Last active August 30, 2021 23:52
Python Postfix Templates
.jdump : Json Dumps
ANY → import json;json.dumps($expr$)$END$
.pypara: Pytest Mark Parametrize
ANY → @pytest.mark.parametrize("one, two", [(),()])$END$
.log : Logging Init
ANY → import logging\n LOGGER = logging.getLogger(__name__)$END$
.quote : Quotes Around String
{
"LED_LIGHT": true,
"MQTT": true,
"SLEEP_FOR": 2.1,
"EVENT_NAME": "motion_detected"
}