Skip to content

Instantly share code, notes, and snippets.

View raytiley's full-sized avatar

Ray Tiley raytiley

View GitHub Profile
@raytiley
raytiley / kegboard_config.json
Created December 11, 2012 01:11
Kegboard Configs
{
"uno": {
"displayName": "Arduino Uno",
"pins": [
{"pinNumber": 1, "supportedTypes": ["flow", "onewire-temp", "onewire-presence", "relay", "id-12-rfid", "buzzer" ]},
{"pinNumber": 2, "supportedTypes": ["flow", "onewire-temp", "onewire-presence", "relay", "id-12-rfid", "buzzer" ]},
{"pinNumber": 3, "supportedTypes": ["onewire-temp", "onewire-presence", "relay", "id-12-rfid", "buzzer" ]},
{"pinNumber": 4, "supportedTypes": ["onewire-temp", "onewire-presence", "relay", "id-12-rfid", "buzzer" ]}
],
"image": "http://kegbot.org/arduino/images/uno.jpg"
@raytiley
raytiley / schedule-search.php
Created October 12, 2012 02:34
Show search with schedule display - GROSS
<?php
$ss = isset($_GET['ss']) ? $_GET['ss'] : "peace"; //use a default search term for testing
$client = new SoapClient("http://tctvsbs.tctv.net/CablecastWS/CablecastWS.asmx?wsdl", array('cache_wsdl' => 0));
$channels = array(
array("name" => "Channel 3", "id" => 1),
array("name" => "Channel 22", "id" => 4),
array("name" => "Channel 26", "id" => 5),
@raytiley
raytiley / show-runs.php
Created July 18, 2012 13:03
Messed around with customer's file
<?php
date_default_timezone_set('America/New_York');
$client = new SoapClient('http://frontdoor.ctn5.org/CablecastWS/CablecastWS.asmx?WSDL', array('cache_wsdl' => 0));
$searchLength = strtotime(date("Y-m-d")."T".date("H:i:s")) + (60*60*24*35);
$channelID = 1;
$showID = 1;
$schedule = $client->GetScheduleInformation(array(
'ChannelID' => $channelID,
'FromDate' => date("Y-m-d")."T00:00:00",
@raytiley
raytiley / ClosureExample.js
Created April 22, 2012 23:57
Design Phase 4 - Closure Example
var module = function(){
var privateVar = “I’m out of scope since function executes and returns”;
//getPrivateVar is a property of the returned function.
this.getPrivateVar = function() {
return privateVar;
}
}(); // () causes anonymous function to automatically execute
module.getPrivateVar === “I’m out of scope since function executes and returns”; //true
@raytiley
raytiley / ReportResolver.js
Created April 22, 2012 22:44
Design Phase 4 - Report Resolver Module
//Include required modules and setup some variables
var reportsRepo = require('ReportsRepository'),
routingServ = require('RoutingService'),
TIMEOUT = 1000 * 60 * 5; // 5 minutes
setTimeout(function(){
//Lookup all unresolved reports that should be resolved due to current time
reportsRepo.getUnresolvedTimeReports(function(err, data){
//Itterate through each report
for(report in data) {
@raytiley
raytiley / RoutingService
Created April 22, 2012 22:04
Design Phase 4 - Routing Service Module
exports.getRoute = function(startLat, startLon, endLat, endLon, routeType, costTable, callback(err, data)) {
//Return GeoJson route from pgRouting
//Execute callback
}
exports.updateCost = function(lat, lon, costTable, costDelta) {
//Update the cost of closest edge in costTable by costDelta
//Execute callback
}
@raytiley
raytiley / ReportsRepository.js
Created April 22, 2012 21:44
Design Phase 4 - Report Validator Module
exports.createReport = function(report, callback(err, data)) {
//Persist the report object to database
//Update cost tables if needed
//Execute callback
}
exports.updateReport = function(report, callback(err, data)) {
//Update report object in database
//Update cost tables if needed
//Execute callback
@raytiley
raytiley / GeoCodingService.js
Created April 22, 2012 21:24
Design Phase 4 - GeoCoding Module
//Anything not exported would be private and not accessible from the loaded module.
var privateVariable = 'I would be hidden';
//Public Method
//Async geocodes array of search strings and calls callback with array of response when finished
exports.geocode = function(searchArray, callback(responseArray)) {
// Asynchronously geocode search array then execute callback
}
@raytiley
raytiley / ReportValidator.js
Created April 22, 2012 21:13
Design Phase 4 - Report Validator Module
//Anything not exported would be private and not accessible from the loaded module.
var privateVariable = 'I would be hidden';
//Public Method
//Returns JSON object of invalid properties and error descriptions
exports.validateReport = function(report) {
var errors = undefined;
//Return an object of propertyName : errorMessages for all invalid fields
@raytiley
raytiley / routesController.js
Created April 22, 2012 21:04
Design Phase 4 - Routes Controller Example
// api/routes?start=300 main st boston&end=550 elm st boston&cost_table=popularity&route_type=cycle
app.get('api/routes', function(req,res){
//Parse Request for parameters
var start = req.params.start,
end = req.params.end,
costTable = req.params.cost_table,
routeType = req.params.route_type;
//Geocode Start and End
geoCoder.geocode([start,end], function(geoCodedResponse){