Skip to content

Instantly share code, notes, and snippets.

View ntoll's full-sized avatar
🎵
This statement is false...

Nicholas Tollervey ntoll

🎵
This statement is false...
View GitHub Profile
@ntoll
ntoll / daisy.py
Created April 11, 2017 12:49
MicroPython code for singing "Daisy, Daisy" on a micro:Bit
# Add your Python code here. E.g.
import speech
line1 = [
'#26DEYYYYYYYYY',
'#31ZIYIYIYIYIYIYIY',
'#39DEYYYYYYYYY',
'#52ZIYIYIYIYIYIYIY',
'#46GIXV',
'#42MIYIY',
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

Keybase proof

I hereby claim:

  • I am ntoll on github.
  • I am ntoll (https://keybase.io/ntoll) on keybase.
  • I have a public key whose fingerprint is C203 9C79 80AE 8442 1031 8C75 FD2A 04F6 9841 B6FA

To claim this, I am signing this object:

from django.conf.urls import url, include
from django.contrib.auth.models import User
from rest_framework import routers, serializers, viewsets
from musicians.models import Musician, Album
from rest_framework import permissions
from drf_yasg.views import get_schema_view
from drf_yasg import openapi
# Serializers define the API representation.
class UserSerializer(serializers.HyperlinkedModelSerializer):
from django.conf.urls import url, include
from django.contrib.auth.models import User
from rest_framework import routers, serializers, viewsets
from musicians.models import Musician, Album
from rest_framework import permissions
from drf_yasg.views import get_schema_view
from drf_yasg import openapi
# Serializers define the API representation.
class UserSerializer(serializers.HyperlinkedModelSerializer):
from django.db import models
class Musician(models.Model):
first_name = models.CharField(max_length=50)
last_name = models.CharField(max_length=50)
instrument = models.CharField(max_length=100)
class Album(models.Model):
REST_FRAMEWORK = {
"DEFAULT_PERMISSION_CLASSES": [
"rest_framework.permissions.DjangoModelPermissionsOrAnonReadOnly"
],
}
from django.conf.urls import url, include
from django.contrib.auth.models import User
from rest_framework import routers, serializers, viewsets
# Serializers define the API representation.
class UserSerializer(serializers.HyperlinkedModelSerializer):
class Meta:
model = User
fields = ["url", "username", "email", "is_staff", ]
@ntoll
ntoll / crapamagotchi.py
Created August 8, 2017 14:38
A really crap Tamagotchi for micro:bit
# Make the display sparkle. Click button A to show an image for
# a moment before the sparkles start again. Click button B to
# scroll a friendly message before the sparkles return.
# By Nicholas H.Tollervey and released to the Public Domain.
# How would you improve this code?
from microbit import *
import random
# A full list of images can be found here: http://bit.ly/1WY221q
images = [Image.HAPPY, Image.SAD, Image.GHOST, Image.SKULL,
[WARNING] [ffpyplayer ] SDL_OpenAudio (2 channels, 44100 Hz): No such audio device
[WARNING] [ffpyplayer ] SDL_OpenAudio (1 channels, 44100 Hz): No such audio device
[ERROR ] [ffpyplayer ] No more channel combinations to try, audio open failed
[CRITICAL] [ffpyplayer ] Failed to open file '/home/ntoll/src/pyoa/meow1.wav' or configure filtergraph