Skip to content

Instantly share code, notes, and snippets.

Neal Todd nealtodd

Block or report user

Report or block nealtodd

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@nealtodd
nealtodd / wiibot.py
Last active Dec 17, 2015
Subclass of WiimoteConnect for controlling a real Pi-driven Lego-based forklift truck.
View wiibot.py
import piface.pfio as pfio
from wiimote import WiimoteConnect
class WiiBot(WiimoteConnect):
"""
Use Wiimote to control robot
Basic usage:
from wiibot import WiiBot
@nealtodd
nealtodd / wiimote.py
Last active Dec 17, 2015
Base class for detecting Wiimote button presses and triggering actions via methods. Written so that a subclass can be used to control a Raspberry Pi based robot.
View wiimote.py
import time
import cwiid
import threading
class WiimoteBase(object):
"""
Base class for sending Wiimote button presses to class
methods. Subclass to implement actions in the methods.
@nealtodd
nealtodd / wiible.py
Last active Dec 17, 2015
Test of connecting Wiimotes to a Raspberry Pi via Bluetooth. Reports button presses from a Wiimote. Couched in a trivial little game for two kids to 'remote control' each other: The sender can use the crosspad to light the leds on the receiver. The receiver walks in the direction indicated on the leds (led1 = turn left, led2 = forwards, led3=bac…
View wiible.py
import time
import cwiid
class Wiible():
buttons = [
"BTN_2",
"BTN_1",
"BTN_B",
@nealtodd
nealtodd / deletable_objects_snippet.py
Last active Nov 20, 2018
Django helper for showing related objects that would be cascade deleted on deletion of an object.
View deletable_objects_snippet.py
from django.conf import settings
from django.db.models.deletion import Collector
from django.db.utils import ConnectionRouter
def deletable_objects(obj):
"""
Return a generator that yields (model, instance) tuples
of instances related to obj (including obj itself).
Essentially, programmatic access to the data Django Admin
@nealtodd
nealtodd / decorator.py
Created Apr 25, 2012
Python profiling decorator
View decorator.py
from cProfile import Profile
import pstats
def profile(sort_args=['cumulative'], print_args=[10]):
profiler = Profile()
def decorator(fn):
def inner(*args, **kwargs):
result = None
You can’t perform that action at this time.