Skip to content

Instantly share code, notes, and snippets.

View bennuttall's full-sized avatar

Ben Nuttall bennuttall

View GitHub Profile
@bennuttall
bennuttall / babbage.py
Last active August 29, 2015 14:07
Tweeting Babbage
from twython import Twython
from picamera import PiCamera
from time import sleep
from datetime import datetime
import RPi.GPIO as GPIO
import random
from auth import (
consumer_key,
consumer_secret,
access_token,
@bennuttall
bennuttall / astro.py
Created December 10, 2014 17:22
astro.py
from space import Mission
from time import sleep
with Mission() as mission:
mission.launch()
while mission.explore():
mission.discover()
mission.learn()
mission.phone_home()
@bennuttall
bennuttall / astro-cam.py
Last active August 29, 2015 14:22
astro-cam.py
from picamera import PiCamera
from picamera.array import PiRGBArray
from astro_pi import AstroPi
ap = AstroPi()
while True:
with PiCamera() as camera:
camera.resolution = (64, 64)
with PiRGBArray(camera, size=(8, 8)) as stream:
import random
sockets = [1, 2, 3, 4]
random.shuffle(sockets] # sockets is now e.g [4, 2, 1, 3]
sockets_1 = sockets[:1] # sockets_1 is now [4]
random.shuffle(sockets] # sockets is now e.g [2, 4, 3, 1]
sockets_2 = sockets[:2] # sockets_2 is now [2, 4]
@bennuttall
bennuttall / gpio.py
Last active September 24, 2015 20:55
# instead of...
import RPi.GPIO as GPIO
from time import sleep
GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)
led = 2
GPIO.setup(led, GPIO.OUT)
from gpiozero import PiTraffic
traffic = PiTraffic()
traffic.red.on()
# Original
# 16 lines
from gpiozero import RyanteckRobot, Button
from signal import pause
robot = RyanteckRobot()
left = Button(26)
right = Button(16)
@bennuttall
bennuttall / robot.py
Last active October 18, 2015 18:15
GPIO Zero Robot Antenna
from gpiozero import LED
from time import sleep
red = LED(2)
blue = LED(3)
while True:
red.on()
sleep(1)
red.off()
@bennuttall
bennuttall / glove.py
Created November 11, 2015 14:50
Glove
from gpiozero import LED, Button
from time import sleep
from signal import pause
red = LED(21)
green = LED(24)
switch = Button(14, pull_up=False)
while True:
switch.wait_for_active()
@bennuttall
bennuttall / gravityforms-broken.php
Last active November 12, 2015 19:30
Gravity Forms bug
<?php $search_criteria = array(
"status" => "active",
"field_filters" => array(
"mode" => "all",
array(
"key" => "2",
"value" => date('Y-m-d'),
"operator" => ">",
),
array(