Arduino restart

My Arduino is working without problems for a few years now. But now it's time to try a few new ideas and plant a few new ones.

The Makefile from my 2011-Blogpost doesn't work with the newest Arduino-Package. But there is a better one: https://github.com/sudar/Arduino-Makefile And the best is that Debian/Ubuntu has a package for it arduino-mk.

void setup() {
  // initialize the digital pin as an output.
  // Pin 9 has an LED connected on most Arduino boards:
  pinMode(9, OUTPUT);
}

void loop() {
  digitalWrite(9, HIGH);   // set the LED on
  delay(1000);              // wait for a second
  digitalWrite(9, LOW);    // set the LED off
  delay(1000);              // wait for a second
}

Code to get the Arduino Uno blink

BOARD_TAG    = uno
ARDUINO_LIBS =

include /usr/share/arduino/Arduino.mk

I tried the same with a leonardo which seems a bit more error-prone. Resets needs to be pressed and a disconnect from usb before programming helps.

Redirects in Django urls including parameters

A change of url schemata forced me to redirect some urls in my Django app. I wanted to use reverse, RedirectView and url parameters.

The View:

from django.views.generic import RedirectView
from django.core.urlresolvers import reverse_lazy

class RedirectViewCustom(RedirectView):
  """view to redirect including all named parameters to a specific lazy url name"""

  def get_redirect_url(self, **kwargs):
    params = self.kwargs
    name = self.kwargs.get('redirectname')
    if name:
      del params['redirectname']
      return reverse_lazy(name, kwargs=params)
    else:
      raise ValueError, "redirectname not set in RedirectViewCustom call."

In urls.py:

url(r'^old-name/(?P<slug>[a-zA-Z]+)/(?P<param>[a-zA-Z0-9-\-]+)/$',
  RedirectViewCustom.as_view(),
  kwargs={'redirectname':'some-name'}),

Tested with Django 1.4.

Fetching mail from custom imap and forward to Gmail

I need to get emails from an imap server with a custom port and forward these emails to Gmail. The imap server has a test certificate which should work smoothly.

My .fetchmailrc

poll mail.MAILSERVER.com with proto IMAP port 9999 auth password
     user 'USER' there with password 'PASSWORD' options keep
     sslfingerprint "12:34:56:78:90:ab:cd:ef:12:34:56:78:90:ab:cd:ef"
     smtpname "EMAILADDRESS@gmail.com"

To get the ssl fingerprint run fetchmail with -c -v.