Skip to content

Instantly share code, notes, and snippets.

Daniel McKay dan-mckay

Block or report user

Report or block dan-mckay

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
@dan-mckay
dan-mckay / gist:802ff9b250a9e2b5d957
Created Jun 26, 2014
iOS 7 status bar fix in JS
View gist:802ff9b250a9e2b5d957
if(navigator.userAgent.match(/iPhone; CPU iPhone OS 7_0/)) {
document.write('<style type="text/css">body{-webkit-transform: translate3d(0,20px,0)}</style>');
}
@dan-mckay
dan-mckay / AnalogInOutSerialThreeLED
Created Nov 1, 2012
Takes a potentiometer reading and controls dimness of 3 LEDs
View AnalogInOutSerialThreeLED
// These constants won't change. They're used to give names
// to the pins used:
const int analogInPin = A0; // Analog input pin that the potentiometer is attached to
const int greenOutPin = 9; // Analog output pin that the green LED is attached to
const int yellowOutPin = 10; // Analog output pin that the ylw LED is attached to
const int redOutPin = 11; // Analog output pin that the red LED is attached to
int sensorValue = 0; // value read from the pot
int outputValue = 0; // value output to the PWM (analog out)
View linux-adduser.md

Add User Linux

Add user called newuser, when logged in as root:

$ adduser newuser

To grant root privileges, open this file with default editor (nano):

/usr/sbin/visudo

Add the user’s name and the same permissions as root under the the user privilege specification

@dan-mckay
dan-mckay / gist:5391312
Created Apr 15, 2013
"Hello World" for johnny-five Node.js Module
View gist:5391312
var five = require("johnny-five"),
board = new five.Board();
board.on("ready", function() {
// Create an Led on pin 9 and strobe it on/off
// Optionally set the speed; defaults to 100ms
(new five.Led(9)).strobe();
});
@dan-mckay
dan-mckay / LedREPL
Created Apr 15, 2013
This is a simple script to demonstrate the REPL provided by johnny-five for interaction with an LED connected to an Arduino.
View LedREPL
var five = require("johnny-five"),
board, led;
board = new five.Board();
board.on("ready", function() {
// Create a standard `led` hardware instance
led = new five.Led(9);
@dan-mckay
dan-mckay / server.js
Created Apr 16, 2013
This is a Node.js server script using johnny-five and socket.io that updates a web page with values taken from an Arduino with a LDR and potentiometer connected.
View server.js
var app = require('http').createServer(handler),
io = require('socket.io').listen(app),
fs = require('fs'),
five = require('johnny-five'),
board,
photoresistor;
app.listen(8000);
// function for serving the static HTML page
@dan-mckay
dan-mckay / index.html
Created Apr 16, 2013
This is the client web page for the Arduino socket.io application.
View index.html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>photoresistor</title>
<style media="screen">
html, body{
min-height: 100%;
}
@dan-mckay
dan-mckay / servocosm.js
Created Apr 16, 2013
This code queries the Cosm API for a reading from a remote sensor. This reading is used to manipulate a servo motor that is connected to an Arduino on the host machine. It is a Node.js application that uses the johnny-five module.
View servocosm.js
var http = require('http'),
five = require('johnny-five'),
feedID = 35602, //30041, //87256
apiKey = '1Og9wAmRBoWExjjN4LdksinNYIaSAKxVYVo0RHlHcHcvUT0g',
value,
oldValue,
board,
servo;
// Build get request for cosm api
@dan-mckay
dan-mckay / DepthImage.pde
Created Apr 16, 2013
A sample script in Processing from simple-openni that visualises depth map data from a Kinect
View DepthImage.pde
import SimpleOpenNI.*;
SimpleOpenNI context;
void setup()
{
context = new SimpleOpenNI(this);
// mirror is by default enabled
@dan-mckay
dan-mckay / gesture.pde
Created Apr 16, 2013
Processing code for gesture based system
View gesture.pde
import SimpleOpenNI.*;
import ddf.minim.*;
SimpleOpenNI kinect;
Minim minim;
AudioSnippet player1;
AudioSnippet player2;
AudioSnippet player3;
AudioSnippet player4;
You can’t perform that action at this time.