Skip to content

Instantly share code, notes, and snippets.

@kylef
kylef / sabnzbd.py
Created January 11, 2010 15:04
SABnzbd python api
import urllib, json
class SABnzbd(object):
"""
Usage:
>>> from sabnzbd import SABnzbd
>>> s = SABnzbd('sakar.local', 8080, '4488f2881b90d7753bef8fb9e1bc56b3')
>>> s.pause() # Pauses the downloads
>>> s.shutdown() # Shut's down SABnzbd+
"""
@jeromer
jeromer / compassbearing.py
Last active February 21, 2024 13:31
compass bearing between two points in Python
# LICENSE: public domain
def calculate_initial_compass_bearing(pointA, pointB):
"""
Calculates the bearing between two points.
The formulae used is the following:
θ = atan2(sin(Δlong).cos(lat2),
cos(lat1).sin(lat2) − sin(lat1).cos(lat2).cos(Δlong))
@darkseed
darkseed / python_wand_example.py
Created September 2, 2012 17:41
python Wand library example
#!/usr/bin/env python
# encoding: utf-8
from wand.image import Image
with Image(filename='inputimagefile.tiff') as img:
print img.format
with img.convert('jpeg') as converted:
converted.save(filename='outputimage.jpg')
converted.resize(72,72)
converted.save(filename='outputimage_thumbnail.jpg')
@boppreh
boppreh / balloontip.py
Created November 2, 2012 11:35 — forked from wontoncc/balloontip.py
Balloon tip module, Python, using win32gui. Display a notification in the tray bar and quits after 10 seconds.
# -- coding: utf-8 --
from win32api import *
from win32gui import *
import win32con
import sys, os
import struct
import time
class WindowsBalloonTip:
@embolalia
embolalia / gist:5660363
Last active December 17, 2015 19:29
A quick script that makes my raspi light up for different ping times. It's a terrible hack, and was not written with the intent of making it public. Please don't hurt me.
#!/usr/bin/env python
import RPi.GPIO as gpio
from time import sleep
import re
import sys
gpio.setmode(gpio.BCM)
red = 23
yel = 24
#!/usr/bin/python
#Kwh per weekday
import time
import logging
import calendar
from datetime import datetime
import redis
@jaxbot
jaxbot / gist:5748513
Created June 10, 2013 12:58
Block nginx from serving .git directories
location ~ /\.git {
deny all;
}
# or, all . directories/files in general (including .htaccess, etc)
location ~ /\. {
deny all;
}
@matbor
matbor / 00readme.md
Last active April 23, 2017 18:03
Onewire Temperatures to mqtt broker server.Have modified the onewire example program so that no mater how many sensors u have plugged in it will always publish each reading to my MQTT broker server. It will use the onewire sensor ROM ID as part of the topic, ie. /house/arduino/[DEVICE ID/temperature/current and the message payload will be the Ce…
@matbor
matbor / mqttitudeTOmysql.py
Last active September 3, 2022 13:32
Simple Python script (v2.7x) that subscribes to a MQTT broker topic and inserts the data into a mysql database for later querying. This is designed to be used with the http://mqttitude.org/
#!/usr/bin/env python
# September 2013
# by Matthew Bordignon, @bordignon on Twitter
#
# Simple Python script (v2.7x) that subscribes to a MQTT broker topic and inserts the topic into a mysql database
# This is designed for the http://mqttitude.org/ project backend
#
import MySQLdb
import mosquitto
@matbor
matbor / getlocations.php
Created September 13, 2013 04:39
Mysql -> Google Maps for mqttitude (using my mysql script). You need to add your google api key below to make it work.
<?php
$conn = mysql_connect("thebeast.localdomain", "root", "") or die(mysql_error());
mysql_select_db("mqtt") or die(mysql_error());
?>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<title>Google Maps</title>
<style type="text/css">