Skip to content

Instantly share code, notes, and snippets.

@andialbrecht
andialbrecht / fetch_weather.py
Created January 11, 2014 15:52
Weekend fun project. I've copied wlandevices.sh via FTP to my FritzBox, copied the other two scripts to my Raspberry and added a cron that runs fetch_wlanlist.py (sorry for the name) every 5 minutes. The script checks if known devices are close to the wlan router which is located in our living room and greets the (supposed) user with a warm welc…
#!/usr/bin/env python3
import json
import os
from urllib.request import urlopen
URL = 'http://api.openweathermap.org/data/2.5/weather?id=2953398&lang=de'
# Migrate from sentry-comments to build in notes.
#
# See also https://github.com/andialbrecht/sentry-comments/issues/11
# Especially when you're upgrading from Sentry 6.3.
#
# To run this script:
# sentry --config=your.conf.py shell
# >>> import migratecomments.py
# >>> migratecomments.migrate()
#
@andialbrecht
andialbrecht / gist:8669031
Created January 28, 2014 14:54
Test runner traceback
### This happened because Django was imported from my global site-packages (Django 1.6)
python tests_v2/main.py
make: »uploadv2.pyz« ist bereits aktualisiert.
urls_tests.url_map: (ImportError('No module named defaults',), 'Traceback (most recent call last):\n File "tests_v2/main.py", line 85, in TestRunner\n rslt = m()\n File "/home/andi/devel/rietveldv2/tests_v2/support/test.py", line 76, in run\n new = self.test_func(*self.args, **self.kwargs)\n File "/home/andi/devel/rietveldv2/tests_v2/urls_tests.py", line 16, in url_map\n import urls\n File "/home/andi/devel/rietveldv2/urls.py", line 18, in <module>\n from django.conf.urls.defaults import *\nImportError: No module named defaults\n')
uploadv2/general_tests.archive_contents: 'OK'
cas/default_type_tests.default_map: (ImportError('No module named defaults',), 'Traceback (most recent call last):\n File "tests_v2/main.py", line 85, in TestRunner\n rslt = m()\n File "/home/andi/devel/rietveldv2/tests_v2/support/
@andialbrecht
andialbrecht / sqlformat_example.html
Created April 15, 2015 15:44
Minimal SQL Format Example
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>SQLFormat API Example</title>
<!-- Include JQuery library -->
<script src="https://code.jquery.com/jquery-2.1.3.min.js"></script>
</head>
#!/usr/bin/env python3
# Usage: python3 tonart2spotify.py DATE
# ...where DATE is for example '2015-10-30'
import sys
import requests
from bs4 import BeautifulSoup
import spotipy
-- Calculates some kind of hammond tuning
-- See https://electricdruid.net/technical-aspects-of-the-hammond-organ/
local Ratios = {
{85, 104},
{71, 82},
{67, 73},
{105, 108},
{103, 100},