Skip to content

Instantly share code, notes, and snippets.

@andrewn
andrewn / README.md
Created January 26, 2018 11:35
Do something when Pi's being being ping'd
@andrewn
andrewn / electronics.md
Last active December 11, 2017 17:44
Electronics kit

Basics

For a basic no-UI Radiodan you probably want:

  • microSD cards
  • some way of writing the microSD cards
  • Raspberry Pi 3
  • Micro USB (data + power)
  • PhatDAC or a good USB sound card
  • Powered speaker
@andrewn
andrewn / bonjour-ssh-hosts.rb
Created February 19, 2017 14:40
Output hosts advertising ssh via Bonjour/MDNS
#!/usr/bin/env ruby
def host_name(line='')
matches = /_ssh._tcp.\s*(.*)$/.match(line)
matches[1] unless matches.nil? || matches[1].nil?# || !/ /.match(matches[1]).nil?
end
TIMEOUT_SEC = 1
read_results = Thread.new do
andrew at andrewn-mbp in ~/Projects/resinos/johnny-five-example on alpine▲
$ rdt push --source .
(node:22168) DeprecationWarning: Using Buffer without `new` will soon stop working. Use `new Buffer()`, or preferably `Buffer.from()`, `Buffer.allocUnsafe()` or `Buffer.alloc()` instead.
Reporting discovered devices
? select a device resin.local (192.168.178.45)
* Building..
- Stopping and Removing any previous 'resin-johnny-five-example' container
- Building new 'resin-johnny-five-example' image
Step 1 : FROM resin/raspberrypi2-alpine-node:5-edge
---> d174973cdbb3
$ rdt push --source .
(node:16932) DeprecationWarning: Using Buffer without `new` will soon stop working. Use `new Buffer()`, or preferably `Buffer.from()`, `Buffer.allocUnsafe()` or `Buffer.alloc()` instead.
Reporting discovered devices
? select a device resin.local (192.168.178.45)
* Building..
- Stopping and Removing any previous 'resin-johnny-five-example' container
- Building new 'resin-johnny-five-example' image
Step 1 : FROM resin/raspberrypi2-alpine-node:5-edge
---> d174973cdbb3
Step 2 : RUN apk add --no-cache wiringpi
$ rdt push --source .
(node:5153) DeprecationWarning: Using Buffer without `new` will soon stop working. Use `new Buffer()`, or preferably `Buffer.from()`, `Buffer.allocUnsafe()` or `Buffer.alloc()` instead.
Reporting discovered devices
? select a device resin.local (192.168.178.45)
* Building..
- Stopping and Removing any previous 'resin-johnny-five-example' container
- Building new 'resin-johnny-five-example' image
Step 1 : FROM resin/raspberrypi2-alpine-node:edge
edge: Pulling from resin/raspberrypi2-alpine-node
237ca8699e5e: Pull complete
Reporting discovered devices
? select a device resin.local (192.168.178.45)
? Select a container /happy-sad-buttons (46b6bcd3a9f) - Restarting (1) Less than a second ago
# gpio
/bin/sh: 1: gpio: not found
# Connection to 192.168.178.45 closed.
andrew at andrewn-mbp in ~/Projects/personal/happy-sad-buttons/embedded on master*
$ rdt push --source .
(node:70517) DeprecationWarning: Using Buffer without `new` will soon stop working. Use `new Buffer()`, or preferably `Buffer.from()`, `Buffer.allocUnsafe()` or `Buffer.alloc()` instead.
Reporting discovered devices
@andrewn
andrewn / gist:e6adddf523595116f7b4
Created November 12, 2014 20:42
Node version of popen?
var spawn = require('child_process').spawn;
var sh = spawn('sh');
sh.stdout.on('data', function (data) {
console.log('sh: \n', data.toString());
});
sh.stderr.on('data', function (data) {
console.error('error: \n', data.toString());
<!DOCTYPE html>
<html>
<head>
<style type="text/css">
#strokes {
stroke: red;
}
#fills {
fill: red;
}
@andrewn
andrewn / gist:d43aab5a5550560bf401
Last active February 21, 2016 22:27
Compiled connman with patches
  1. sudo pico /etc/apt/sources.list.d/source.list

Paste in deb-src http://archive.raspbian.org/raspbian/ jessie main contrib non-free rpi

  1. sudo apt-get update

  2. apt-get source connman

  3. cd connman-1.21