Skip to content

Instantly share code, notes, and snippets.

View bjpirt's full-sized avatar

Ben Pirt bjpirt

View GitHub Profile
var KS = require('./kickstarter-data/');
var MeArmPi = require('../mearm-js/lib/MeArmPi.js').MeArmPi,
arm = new MeArmPi();
var backers = 0;
arm.moveBaseTo(20);
function drawBack(current, dest, cb){
if(current < dest){
@bjpirt
bjpirt / mearm.py
Created February 10, 2017 17:49
Controlling the MeArm Pi from Minecraft
import os
import math
import pigpio
#import RPi.GPIO as GPIO
pi = pigpio.pi()
class Servo:
def __init__(self, config):
self.pin = config['pin']
@bjpirt
bjpirt / face.py
Last active February 10, 2017 17:43
A quick demo of doing face tracking on the MeArm Pi so that you can make the arm follow you
from picamera.array import PiRGBArray
from picamera import PiCamera
import time
import cv2
from mearm import MeArm
width = 640
arm = MeArm()
arm.base.moveTo(0)
@bjpirt
bjpirt / cheerlights-node-red.json
Created December 25, 2015 19:28
An Arduino sketch that takes a colour and cycles through the spectrum to transition to it and an accompanying node-red flow to hook it up to twitter
[{"id":"800baf19.7ff45","type":"serial-port","z":"2d82a309.d27d5c","serialport":"/dev/ttyUSB1","serialbaud":"115200","databits":"8","parity":"none","stopbits":"1","newline":"\\n","bin":"false","out":"char","addchar":true},{"id":"4121fbbc.bede04","type":"twitter in","z":"2d82a309.d27d5c","twitter":"","tags":"cheerlights","user":"false","name":"cheerlights","topic":"tweets","x":150,"y":162.00001525878906,"wires":[["eb35c13.f14ca4"]]},{"id":"eb35c13.f14ca4","type":"function","z":"2d82a309.d27d5c","name":"parse @Cheerlight colours","func":"msg.payload = msg.payload.toLowerCase();\n\nvar result = msg.payload.match(\n/red|green|blue|cyan|white|warmwhite|purple|magenta|yellow|orange|black|pink|oldlace/g);\n\nmsg = [];\nfor (var colour in result) {\n msg.push({payload:result[colour]+\"\\n\"});\n}\n\nconsole.log(msg);\n\nreturn [msg];\n\nif(context.global.enabled){\n return [msg];\n}else{\n return [];\n}","outputs":1,"noerr":0,"x":387.00001525878906,"y":194,"wires":[["b591b09d.4a6e5"]]},{"id":"b591b09d.4a6e5","
### Keybase proof
I hereby claim:
* I am bjpirt on github.
* I am bjpirt (https://keybase.io/bjpirt) on keybase.
* I have a public key whose fingerprint is D8A0 CC19 C743 9E5C 55BA 20E9 938E E78B D67A 7EFA
To claim this, I am signing this object:
@bjpirt
bjpirt / package.json
Created April 30, 2014 12:29
A quick proxy script to bridge between Scratch and Mirobot.
{
"author": "Ben Pirt",
"name": "mirobot-scratch-proxy",
"description": "A simple Scratch to Mirobot proxy",
"version": "0.0.1",
"dependencies": {
"ws": "0.4.31"
}
}
@bjpirt
bjpirt / export_timesheet.scpt
Created October 13, 2013 09:25
An applescript to export the events for a specific calendar for the month you choose in order to use Calendar.app as a timesheet.
on monthsAgo(m) -- returns a date formatted for the select box
set m to -m
set newDate to current date
-- Convert the month-offset parameter to years and months
set {y, m} to {m div 12, m mod 12}
-- If the month offset is negative (-1 to -11), make it positive from a year previously
if m < 0 then set {y, m} to {y - 1, m + 12}
-- Add the year offset into the new date's year
set newDate's year to (newDate's year) + y
-- Add the odd months (at 32 days per month) and set the day
#!/usr/bin/env node
var Backbone = require('backbone-postgresql');
// Configure our connection to PostgreSQL
Backbone.pg_connector.config = {db: 'pg://postgres:m0nday27@localhost/bb_pg_demo'}
// Define some models
var Category = Backbone.Model.extend({
urlRoot: 'category'
@bjpirt
bjpirt / selenium_server.js
Created May 25, 2012 08:59
A module to make sure selenium is already started
var http = require('http'),
spawn = require('child_process').spawn,
selenium;
var selenium_server = {
host: 'localhost',
port: 4444,
path: '/wd/hub/static/resource/hub.html',
method: 'GET'
};
@bjpirt
bjpirt / bucket.rb
Created May 2, 2012 16:19
Quick bucketing of PG logs
#!/usr/bin/env ruby
outputs = {}
STDIN.each_line do |line|
data = line.gsub(';', '').split(' ')
outputs[data[1].to_i] = [] unless outputs[data[1].to_i]
outputs[data[1].to_i] << data[0].to_f
end
outputs.keys.sort.each do |k|