Skip to content

Instantly share code, notes, and snippets.

View davisford's full-sized avatar

Davis Ford davisford

View GitHub Profile
@davisford
davisford / hygro-petal.pde
Created August 8, 2011 16:25
Daisy Hygro Petal
// CmdMessenger library (included in local libraries folder)
// Origin: https://github.com/dreamcat4/cmdmessenger
#include "CmdMessenger.h"
// Streaming4 library (included in local libraries folder)
// Origin: http://arduiniana.org/libraries/streaming/
#include "Streaming.h"
// Mustnt conflict / collide with our message payload data.
char field_separator = ',';
@davisford
davisford / Hygro1.pde
Created August 8, 2011 17:04
Hygro Petal => Just main loop and timeout
// ------------------ M A I N ( ) --------------------------------------------
// Timeout handling
long timeoutInterval = 2000; // 2 seconds
long previousMillis = 0;
int counter = 0;
void timeout()
{
// add code in here you want to
// execute every timeoutInterval seconds
@davisford
davisford / Hygro2.pde
Created August 8, 2011 17:21
Hygro Petal => Add In CmdMessenger
// CmdMessenger library (included in local libraries folder)
// Origin: https://github.com/dreamcat4/cmdmessenger
#include "CmdMessenger.h"
// Streaming4 library (included in local libraries folder)
// Origin: http://arduiniana.org/libraries/streaming/
#include "Streaming.h"
// Mustnt conflict / collide with our message payload data. Fine if we use base64 library ^^ above
char field_separator = ',';
@davisford
davisford / hygro3.pde
Created August 8, 2011 17:35
Hygro Petal => Useful Sensor Code
// __________________ FUNCTION DECLARATIONS _________________________________
void led_on();
void led_off();
void readDataOnce();
char * readSensors();
messengerCallbackFunction messengerCallbacks[] =
{
led_on, // 004
led_off, // 005
@davisford
davisford / Led.mxml
Created August 8, 2011 22:21
Simple UI to toggle LED state
<?xml version="1.0" encoding="utf-8"?>
<s:Module xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
xmlns:swiz="http://swiz.swizframework.org"
backgroundColor="#bdcdf4"
width="100%" height="100%" >
<fx:Script>
<![CDATA[
@davisford
davisford / EventHandler.as
Created August 8, 2011 22:34
EventHandler for receiving messages
[EventHandler(event="BluetoothTxRxEvent.RX", properties="data")]
public function receive(data:String):void {
// parse the message and do something with it
}
@davisford
davisford / txrx.mxml
Created August 8, 2011 22:59
Transmit and Receive
<?xml version="1.0" encoding="utf-8"?>
<s:Module xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
xmlns:swiz="http://swiz.swizframework.org"
backgroundColor="#bdcdf4"
width="100%" height="100%" >
<fx:Script>
<![CDATA[
@davisford
davisford / editor.css
Created February 2, 2012 19:59
HTML/css/js editor using backbone.js, jquery-ui, and jsPlumb; jsPlumb endpoints are not behaving as expected here. They are transparent, and they do not drag along with their source or target.
body {
background-color:white; font-size:90%;
/*background-image:url(../images/dynamicAnchorBg.jpg); */
background-image:url(http://colourlovers.com.s3.amazonaws.com/images/patterns/222/222733.png?1221244242);
font-family:Helvetica;
height: 100%;
}
#editorCanvas {
position: absolute;
// in models/user.js
var mongoose = require('mongoose');
var Schema = mongoose.Schema
, ObjectId = mongoose.SchemaTypes.ObjectId
// example model
var UserSchema = new Schema({
email: { type: String, unique: true, index: true }
});
@davisford
davisford / foo.js
Created June 17, 2012 14:43
JavaScript scope - demo showing JS private, privileged, etc. scope
var FooWrapper = (function() {
// private module scope, shared among all Foo instances
var _private1 = "private1";
var _private3 = "private3";
var Foo = function(arg1, arg2, arg3) {
// private instance var, only visible to privileged methods