Skip to content

Instantly share code, notes, and snippets.

@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 / github.html
Created November 30, 2016 13:07
Access github API in browser using personal access token
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Taxfix Question Editor</title>
<link href="https://fonts.googleapis.com/css?family=Roboto" rel="stylesheet">
</head>
<body>
<div id='root'>
</div>
<!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

@andrewn
andrewn / atom-esformatter-install.js
Last active January 10, 2016 12:47
Simple script to install your projects esformatter plugins in the atom-esformatter package
var fs = require('fs');
var path = require('path');
var spawn = require('child_process').spawn;
var esformatterPath = process.argv[2];
var homeDir = (process.platform === 'win32') ? process.env.HOMEPATH : process.env.HOME;
var atomPackagePath = path.join(homeDir, '.atom', 'packages', 'esformatter');
var config;
var plugins;
var cmd;
@andrewn
andrewn / hello-button.js
Created January 3, 2016 17:08
Testing jonnny-five button class with internal pull up resistor
var five = require('johnny-five'),
RaspiIO = require('raspi-io');
var board;
board = new five.Board({
io: new RaspiIO(),
repl: true
});