Skip to content

Instantly share code, notes, and snippets.

View thatguydan's full-sized avatar

Daniel Friedman thatguydan

View GitHub Profile

Keybase proof

I hereby claim:

  • I am thatguydan on github.
  • I am danfriedman (https://keybase.io/danfriedman) on keybase.
  • I have a public key ASBQMd7gbEFnWrORRuf3P1vXwz-RkCdvKg9Q_9vMU9MDtAo

To claim this, I am signing this object:

@thatguydan
thatguydan / gist:4998419
Last active December 14, 2015 00:19
On{X} NFC Rule
var ip = 'api.ninja.is'; // Can also be the IP address of the machine running the client code
var ACCESS_TOKEN='API_ACCESS_TOKEN'; // Obtained from https://a.ninja.is/hacking
var port = 443; // Should be 8000 if talking locally
var NODE = "F9C342600F237BBE"; // In your client code terminal
var G = '01';
var V = 0;
var D = 1007;
//Register for NFC event to handle discovered tag.
device.nfc.on("found", handleNfcTag);
var util = require('util')
, stream = require('stream')
, os = require('os')
, helpers = require('./lib/helpers')
, Hue = require('hue.js')
, Light = require('./lib/Light');
util.inherits(hue,stream);
module.exports = hue;
var util = require('util')
, stream = require('stream')
, os = require('os')
, helpers = require('./lib/helpers')
, Hue = require('hue.js');
util.inherits(hue,stream);
module.exports = hue;
function hue(opts,app) {
@thatguydan
thatguydan / device.js
Created November 7, 2012 00:14
Draft module interface
// Copyright Joyent, Inc. and other Node contributors.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to permit
// persons to whom the Software is furnished to do so, subject to the
// following conditions:
//
@thatguydan
thatguydan / humidity_example.js
Created October 9, 2012 04:40
Pulling out humidity data example
ninja.devices('humidity',function(err,devices) {
// Returns all your humidity devices as guid => metadata
// So we iterate over each humidity device
for (var guid in devices) {
ninja.device(guid).data(function(err,data) {
// …data for that humidity sensor
});
}
});
/*
1) Model everything
- User
- Block
- Device
- Credential
- Rule
- Token
@thatguydan
thatguydan / model.js
Created August 14, 2012 11:19
nodejs control flow management
var EventEmitter = require('events').EventEmitter;
function User() {
var self = this;
this.create = function(email,password) {
self.once('_insertIntoDbEvent',function(err) {
/*
{
"rule": {
"shortName": "Nerf Gun Shooter",
"preconditions": [
{
"handler": "ninjaChange", // When we receive the trip-wire string from the RF module
"params": {
"guid": "RFID_DEVICE_GUID",
"to": "10101000101000001010101"
}