Skip to content

Instantly share code, notes, and snippets.

View humitos's full-sized avatar
💭
Drinking 🧉. Always.

Manuel Kaufmann humitos

💭
Drinking 🧉. Always.
View GitHub Profile
@humitos
humitos / gadgetbridge_homeassistant.py
Last active February 7, 2025 13:35
Insert data from Gadget Bridge into Home Assistant database
import sqlite3
# Get this from the DB after creating the sensor/helper
METADATA_ID = 500 # input_number.heart_rate
connection_gadget = sqlite3.connect("samba/public/Gadgetbridge")
cursor_gadget = connection_gadget.cursor()
connection_hass = sqlite3.connect("homeassistant/config/home-assistant_v2.db")
cursor_hass = connection_hass.cursor()
@humitos
humitos / migrate_notifications.py
Created January 3, 2024 15:32
Script to migrate old Build/Project errors into new `Notification` objects
# Build objects to create Notification for
#
#
# In [10]: Build.objects.filter(date__year__in=[2023, 2024]).exclude(error="").count()
# Out[10]: 1231365
# Different types of Notification messages we need
#
@humitos
humitos / docutils-18-diff-20.diff
Created August 25, 2023 17:32
Differences between docutils 0.18 and 0.20 on Read the Docs Sphinx Theme
▶ colordiff -u /home/humitos/rtfd/code/sphinx_rtd_theme/.tox/py310-sphinx72/tmp/html/demo/demo.html /home/humitos/rtfd/code/sphinx_rtd_theme/.tox/py310-sphinx72-qa/tmp/html/demo/demo.html
--- /home/humitos/rtfd/code/sphinx_rtd_theme/.tox/py310-sphinx72/tmp/html/demo/demo.html 2023-08-25 19:29:48.401670197 +0200
+++ /home/humitos/rtfd/code/sphinx_rtd_theme/.tox/py310-sphinx72-qa/tmp/html/demo/demo.html 2023-08-25 19:28:19.342350784 +0200
@@ -1,7 +1,7 @@
<!DOCTYPE html>
<html class="writer-html5" lang="en" >
<head>
- <meta charset="utf-8" /><meta name="generator" content="Docutils 0.18.1: http://docutils.sourceforge.net/" />
+ <meta charset="utf-8" /><meta name="viewport" content="width=device-width, initial-scale=1" />
<meta content="reStructuredText, demonstration, demo, parser" name="keywords" />
@humitos
humitos / email_organization_owners_cloudflare.py
Created January 23, 2023 10:08
Script to email owners of organizations that have domains already on Cloudflare.
"""
Script to email owners of organizations
that have domains already on Cloudflare.
We are asking more about their setup.
Email at https://pad.riseup.net.....
"""
from pprint import pprint
@humitos
humitos / sport-tracker-gpx.js
Last active November 19, 2022 09:39
Download a URL workout from Sport Tracker as GPX
// Download file from https://www.sports-tracker.com/
// Example: https://www.sports-tracker.com/workout/jaumenarbona/61b508ae59ba772af9278c87
//
// Based on:
// - https://ivanderevianko.com/2016/04/export-all-workouts-from-sports-tracker
// - https://gist.github.com/KonstantinosSykas/dfe4c5e392e299ab9341d6e16299454f
//
//
// Instructions:
// 1. Open the URL of the workaround you want to export
@humitos
humitos / postgres_queries_and_commands.sql
Last active May 16, 2022 09:05 — forked from rgreenjr/postgres_queries_and_commands.sql
Useful PostgreSQL Queries and Commands
-- running queries
SELECT pid, age(clock_timestamp(), query_start), usename, state, query
FROM pg_stat_activity
WHERE state != 'idle' AND query NOT ILIKE '%pg_stat_activity%'
ORDER BY query_start desc;
-- kill running query
SELECT pg_cancel_backend(procpid);
-- kill idle query
@humitos
humitos / active_project.py
Last active January 31, 2022 16:40
Minimal implementation to check if a project can be considered "active" under a window of certain past months
import datetime
from django.utils import timezone
from readthedocs.analytics.models import PageView
from readthedocsext.spamfighting.utils import spam_score
def is_active_project(
@humitos
humitos / gist:8553640a9ce1272ccd83861ed233d03c
Created November 12, 2017 01:22
Bluetooth error on Archlinux
nov 11 20:21:10 julia kernel: Bluetooth: hci0 link tx timeout
nov 11 20:21:10 julia kernel: Bluetooth: hci0 killing stalled connection fc:a8:9a:b9:45:14
nov 11 20:21:10 julia kernel: Bluetooth: hci0 link tx timeout
nov 11 20:21:10 julia kernel: Bluetooth: hci0 killing stalled connection fc:a8:9a:b9:45:14
nov 11 20:21:12 julia bluetoothd[3336]: Disconnecting failed: already disconnected
nov 11 20:21:16 julia bluetoothd[3336]: Close: Connection timed out (110)
nov 11 20:21:16 julia kernel: Bluetooth: hci0 link tx timeout
nov 11 20:21:16 julia kernel: Bluetooth: hci0 killing stalled connection fc:a8:9a:b9:45:14
nov 11 20:21:18 julia bluetoothd[3336]: Abort: Connection timed out (110)
nov 11 20:21:18 julia kernel: Bluetooth: hci0 link tx timeout
;; Reproduction of
;; https://stackoverflow.com/questions/45907854/browse-url-generic-program-as-a-safe-local-variable-values
(custom-set-variables
'(safe-local-variable-values
(quote
(
(browse-url-generic-program "firefox")
(browse-url-generic-program "google-chrome")
))))
[21:07] humitos: ~> python
Python 2.7.12 (default, Jul 18 2016, 15:02:52)
[GCC 4.8.4] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from __future__ import unicode_literals
>>> 'a'
u'a'
>>> # :)
...
>>> import md5