Skip to content

Instantly share code, notes, and snippets.

View rtu-dataframe's full-sized avatar

Simone rtu-dataframe

View GitHub Profile
@rtu-dataframe
rtu-dataframe / managers.py
Created February 5, 2024 16:56 — forked from OdinsPlasmaRifle/managers.py
Haversine formula in Django using Postgres SQL
from django.db import models, connection
"""
Haversine formula in Django using Postgres SQL
Queries a model for all rows that are within a certain radius (given in meters) of a central point.
The 'location_model' placeholder should be raplaced with the name of the table (full name) that includes a latitude and longitude column.
The latitude and longitude columns should be decimal fields.
# An R script to estimate MQ gas sensors correlation curve and compute Ro, min and max Rs/Ro
#
# Copyright (c) Davide Gironi, 2016
#
# Released under GPLv3.
# Please refer to LICENSE file for licensing information.
# How to use this script:
# 1) set limits as datasheet curve ("xlim" and "ylim")
# ex.
@rtu-dataframe
rtu-dataframe / dev_signed_cert.sh
Created April 9, 2019 06:12 — forked from dobesv/dev_signed_cert.sh
Script to create (1) a local certificate authority, (2) a host certificate signed by that authority for the hostname of your choice
#!/usr/bin/env bash
#
# Usage: dev_signed_cert.sh HOSTNAME
#
# Creates a CA cert and then generates an SSL certificate signed by that CA for the
# given hostname.
#
# After running this, add the generated dev_cert_ca.cert.pem to the trusted root
# authorities in your browser / client system.
#
@rtu-dataframe
rtu-dataframe / retry.py
Created February 18, 2019 16:56 — forked from willcalderbank/retry.py
Python retry decorator
def retry(times, exceptions):
"""
Retry Decorator
Retries the wrapped function/method `times` times if the exceptions listed
in ``exceptions`` are thrown
:param times: The number of times to repeat the wrapped function/method
:type times: Int
:param Exceptions: Lists of exceptions that trigger a retry attempt