Skip to content

Instantly share code, notes, and snippets.

@andialbrecht
andialbrecht / closure-gjslint.el
Created May 16, 2011 09:58
Emacs mode for running gjslint from Closure library
;;; closure-gjslint.el --- Closure Lint mode
;; Copyright (C) 2011 Andi Albrecht
;; Author: Andi Albrecht <albrecht.andi@gmail.com>
;; Keywords:
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
@andialbrecht
andialbrecht / git-branch-io
Created May 31, 2011 08:06
git command to summarize incoming and outgoing changes on local branches
#!/usr/bin/env python2
# git-branch-io -- show incoming and outgoing commits
#
# Place this file somewhere in your PATH.
#
# Usage: git branch-io [branch]
#
# If branch is not given the current branch will be used. The script
# prints out how many commits should go in either direction to bring
@andialbrecht
andialbrecht / python-flake8.el
Created September 26, 2011 08:09
Thin wrapper around python-pylint to run flake8
;;; python-flake8.el --- Thin wrapper around python-pylint to run flake8
;; Copyright (C) 2011 Andi Albrecht
;; Author: Andi Albrecht <albrecht.andi@gmail.com>
;; Keywords: languages
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
try:
from collections import OrderedDict
except ImportError:
OrderedDict = None
from UserDict import UserDict
if OrderedDict is not None:
class Cache(OrderedDict):
def flush(self):
#!/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
#!/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
application: your-app-id
version: 1
runtime: python27
api_version: 1
threadsafe: true
handlers:
- url: /.*
script: demo.application
@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.
@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()
#