Skip to content

Instantly share code, notes, and snippets.

View ismaelc's full-sized avatar

Chris Ismael ismaelc

View GitHub Profile
@ismaelc
ismaelc / ExpensePro.c
Created September 2, 2014 22:48
Pebble Concur Mojio demo (C file)
// Copyright (c) 2014 Gabi Zuniga
// 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.
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
#include <pebble.h>
// standard defines
//
#define WIDTH 144
@ismaelc
ismaelc / ExpensePro-AppMessage.c
Created September 3, 2014 02:17
ExpensePro-AppMessage
app_message_register_inbox_received(fetch_msg);
app_message_register_inbox_dropped(in_dropped_handler);
app_message_register_outbox_failed(out_failed_handler);
app_message_open(256,50); // in/out
@ismaelc
ismaelc / pebble-js-app.js
Last active August 29, 2015 14:06
Pebble Concur Mojio demo (Javascript)
// Copyright (c) 2014 Gabi Zuniga
// 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.
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
// Configuration: Hardcoded for Hackathon
// TODO: The updated Mojio endpoint should be https://api.moj.io:443/v1/Trips?s
@ismaelc
ismaelc / pebble-js-app-ready.js
Last active August 29, 2015 14:06
Pebble-Js-App-Ready
// Initialization
Pebble.addEventListener('ready', function(e) {
config = [
{"cb-enable":"true","title":"Expense Pro","sampling-rate":"1"}
];
sendEntry(0, "-");
fetchLastMojoTrip();
});
// Messages from the Pebble App
@ismaelc
ismaelc / pebble-js-app-postToConcur.js
Created September 3, 2014 03:22
pebble-js-app-postToConcur
function postToConcur() {
console.log("Posting to Concur");
var lastTrip = localStorage.getItem('lastTrip');
if (lastTrip != null) {
console.log("lastTrip "+lastTrip);
lastTrip = JSON.parse(lastTrip);
concurBody.Journey.StartLocation = lastTrip.StartAddress.Address1;
concurBody.Journey.EndLocation = lastTrip.EndAddress.Address1;
concurBody.TransactionDate = lastTrip.EndTime;
concurBody.Journey.OdometerStart = lastTrip.StartMilage;
@ismaelc
ismaelc / pebble-js-app-selectbutton.js
Created September 3, 2014 03:31
pebble-js-app-selectbutton
// Messages from the Pebble App
Pebble.addEventListener('appmessage', function(e) {
if (e.payload.command != null) {
switch (e.payload.command) {
case 0: // FETCH
fetchLastMojoTrip();
break;
case 1: // Up/Next button pressed
break;
@ismaelc
ismaelc / index.js
Created October 24, 2014 18:15
Sample snippet for using Twilio MMS to send expense to Concur part 1. Full source for at https://github.com/ismaelc/TwilioConcurMMS
// After setting up Twilio to call our node.js app
// ('/receiveMMS') when an SMS/MMS is received,
// the snippet below will get the Twilio-hosted
// MMS image URL and the message body, which
// represent the image receipt and expense amt
app.post('/receiveMMS', function (req, res) {
fromTwilio.mediaUrl = req.body.MediaUrl0;
@ismaelc
ismaelc / index.js
Last active August 29, 2015 14:08
Sample snippet of using Twilio MMS to send expense to Concur part 2. Full source code at - https://github.com/ismaelc/TwilioConcurMMS
// *Post image to Concur using Concur module* (Coming soon!)
// The snippet below takes the Twilio-hosted MMS image URL
// and passes it to be uploaded to Concur
function(callback) {
options = {
oauthToken:concurToken,
imageURL: fromTwilio.mediaUrl
};
@ismaelc
ismaelc / index.js
Created October 24, 2014 18:42
Sample snippet using Twilio MMS to send expense to Concur part 3. Full source code at https://github.com/ismaelc/TwilioConcurMMS
// *Create expense entry and link image to it*
function(imageId, callback) {
// Check if text message was included in MMS
if (isNaN(fromTwilio.msgBody)) callback(null, "Receipt uploaded, expense entry skipped!");
var now = new Date();
var year = now.getFullYear();
var month = now.getMonth();
@ismaelc
ismaelc / index.js
Created October 24, 2014 18:57
Sample snippet using Twilio MMS to send expense to Concur part 4. Full source code at https://github.com/ismaelc/TwilioConcurMMS
// *Builds the TwiML (XML) request that this app sends back to Twilio, to be relayed back as SMS to user*
// Sample usage: sendTwiml(res, "Receipt uploaded, expense entry created!")
function sendTwiml(res, message) {
var twiml = '<?xml version="1.0" encoding="UTF-8" ?><Response><Sms>' + message + '</Sms></Response>';
res.send(twiml, {
'Content-Type': 'text/xml'
}, 200);
}