Skip to content

Instantly share code, notes, and snippets.

@thehesiod
thehesiod / 1pass_dups.py
Last active September 16, 2024 19:46
1password duplicate remover (alpha, only run in debugger with breakpoints everywhere *g*)
#!/usr/bin/env python3
import json
import subprocess
import sys
from concurrent.futures import ThreadPoolExecutor
import html
import dictdiffer
import iso8601
@kmdm
kmdm / configuration.yaml
Last active July 10, 2024 12:55
Home assistant and Mitsubishi via https://github.com/SwiCago/HeatPump
# Assumes you have a topic structure like: heatpump/<room> and heatpump/<room>/set
# E.g. heatpump/bedroom, heatpump/bedroom/set, heatpump/office, heatpump/office/set
#
# Configure the MQTT HVAC climate platforms (Example for master bedroom, office and nursery. Change to suit.):
climate:
- <<: &mitsu_platform
platform: mqtt
modes:
- "off"
@troyfontaine
troyfontaine / README.md
Last active December 22, 2022 16:04
USG ddclient Upgrade Script

How to use this script?

Why, that's simple! Copy this script to your USG, run chmod +x on it and then, as a user with sudo permission, execute it.

Shamelessly borrowed from Brittanic on the Ubiquiti Unifi forums

How to use it?

Simply run the following command (note, if you are at all security concious-don't run it and instead review the script, then copy it to your USG to execute).

curl https://gist.githubusercontent.com/troyfontaine/7e6f93e32621177fc9a94e823adc52b5/raw/fix_ddns.sh | sudo bash
@gesellix
gesellix / config.json
Last active March 18, 2020 21:44
Oboo setup/config
{
"cards": {
"0": {
"name": "weather",
"id": 0,
"tempUnit": "celsius",
"card": "Weather",
"location": "Europe/Berlin CET-1CEST,M3.5.0,M10.5.0/3",
"distanceUnit": "metric"
}
@dale3h
dale3h / pkg-x
Last active December 4, 2018 21:22
Ensure Alpine packages are installed and then run a command
#!/bin/bash
################################################################
## @usage pkg-x node=nodejs node /my/node-script.js "arg1" "arg2"
## @usage pkg-x expect,telnet=busybox-extras /path/to/telnet.sh "uptime"
## @description Ensure Alpine packages are installed and then run a command
## @license MIT
## @author Dale Higgs <@dale3h>
################################################################
@mariocj89
mariocj89 / python-logging.md
Last active November 6, 2024 20:13
Understanding logging in Python

Logging trees

Introduction

When applications are running in production, they become black boxes that need to be traced and monitored. One of the simplest, yet main, ways to do so is logging. Logging allows us - at the time we develop our software - to instruct the program to emit information while the system is running that will be useful for us and our sysadmins.

@baxeico
baxeico / smtp_server.py
Created May 10, 2017 13:18
A simple Python email gateway
import smtpd
import asyncore
import logging
import email
from email.header import decode_header
import requests
logger = logging.getLogger(__name__)
class CustomSMTPServer(smtpd.SMTPServer):
@mariocj89
mariocj89 / python-datetime.md
Last active April 2, 2023 16:43
Draft for an article in opensource.com related to a talk in PyCon17

Intro

Most of us have faced a point when trying to make things work with the Python datetime module where we resort to guess-and-check until the errors go away. datetime is one of those APIs that seems easy to use but requires the developer to have a deep understanding of what things actually mean, as otherwise it is really easy to introduce unexpected bugs given the actual complexity of date and time related issues.

Time Standards

The first concept we need to grasp when working with time is

@barbietunnie
barbietunnie / udemy-courses-download-using-cookies.md
Last active November 6, 2024 00:25
Downloading Udemy videos with youtube-dl

How to download your Udemy course videos using youtube-dl

$ youtube-dl --list-extractors | grep udemy

Steps

  1. Get link to the course to download. e.g. https://www.udemy.com/course-name/
  2. Login into udemy website, save the cookie from chrome using Chrome (Cookie.txt)[1] export extension. Save it to file udemy-cookies.txt
  3. Get the link of the video that you want to download. usually in format. Use the command provided below where you have to replace the {course_link} and {path_to_cookies_file} with respective paths.
$ youtube-dl {course_link} --cookies {path_to_cookies_file}
@jupdike
jupdike / IntersectTwoCircles.js
Last active October 17, 2024 13:10
Find the intersections (two points) of two circles, if they intersect at all
// based on the math here:
// http://math.stackexchange.com/a/1367732
// x1,y1 is the center of the first circle, with radius r1
// x2,y2 is the center of the second ricle, with radius r2
function intersectTwoCircles(x1,y1,r1, x2,y2,r2) {
var centerdx = x1 - x2;
var centerdy = y1 - y2;
var R = Math.sqrt(centerdx * centerdx + centerdy * centerdy);
if (!(Math.abs(r1 - r2) <= R && R <= r1 + r2)) { // no intersection