Skip to content

Instantly share code, notes, and snippets.

-- 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},
#!/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
@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>
@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/
# 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 / 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'
@andialbrecht
andialbrecht / tulipshell.py
Created May 27, 2013 18:26
Helper to run a background tulip loop in an interpreter session.
# -*- coding: utf-8 -*-
"""Set up an interactive interpreter to have a underlying tulip loop.
The setup() function replaces the default loop policy, that starts a loop only
for the main thread, by a policy that has a single global loop available in any
thread.
The loop will be started when calling setup() in a background thread so that
the main thread could still be used by the interactive shell.
application: your-app-id
version: 1
runtime: python27
api_version: 1
threadsafe: true
handlers:
- url: /.*
script: demo.application
@andialbrecht
andialbrecht / customtreemodel.py
Created January 5, 2013 19:46
Simple script demonstrating a custom Gtk.TreeModel for Gtk 3 (known as GenericTreeModel in PyGtk 2).
#!/usr/bin/env python3
# This script demonstrates a custom TreeModel (known as
# GenericTreeModel in PyGtk 2).
#
# Note: This script requires python-gi (pygobject) >= 3.4.
from gi.repository import GObject, Gtk
#!/bin/bash
# A hacky command for a common task:
# - stash away all changes in working branch
# - update master from SVN
# - rebase working branch on master
# - flush all committed changes from working branch to master
# - push them to SVN
# - update working branch again
# - patch in changes