Skip to content

Instantly share code, notes, and snippets.

View calderonroberto's full-sized avatar

Roberto Calderon calderonroberto

View GitHub Profile
@calderonroberto
calderonroberto / stsplatform-ruby-example.rb
Created July 29, 2015 01:34
Example using the stsplatform ruby library.
# Require the stsplatform gem. Make sure to install it
# To install from source run: "bundle exec rake install"
# to install from RubyGems run : "gem install stsplatform"
require 'stsplatform'
# A sensor to use for this example. We will use
SENSOR_NAME = 'calderonroberto.demo'
# First, create a client that will handle all the REST calls
c = STSPlatform::Client.new()
#!/bin/python
import random
import stsplatform.client as sts
# You will need your credentials configured here. Read more here:
# http://wotkit.readthedocs.org/en/latest/api_v1/api_authentication.html#keys-and-basic-authentication
KEY_ID = ''
KEY_PASSWORD = ''
#!/bin/python
import stsplatform.client as sts
SENSOR_NAME = 'mike.yvr-arrive'
def main():
conf = {
"url":"http://wotkit.sensetecnic.com/api",
}
@calderonroberto
calderonroberto / chainofresponsibility.py
Created July 8, 2015 06:28
Chain of responsibility in python (Design Patterns - Gamma, Helm, Johnson, Vlissides)
PRINT_TOPIC = 1
PAPER_ORIENTATION = 2
APPLICATION_TOPIC = 3
NO_HELP_TOPIC = -1
class HelpHandler (object):
def __init__(self, successor=0, topic=NO_HELP_TOPIC):
self._successor = successor
self._topic = topic
def HasHelp(self):
@calderonroberto
calderonroberto / app_tests.py
Created June 13, 2015 19:14
Flask Redis Example Tests
import app
import unittest
import json
from random import randint
mocked_value = randint(0,255)
class AppTestCase(unittest.TestCase):
def setUp(self):
self.app = app.app.test_client()
@calderonroberto
calderonroberto / app.py
Last active June 1, 2022 20:06
Flask Redis Example
#!/bin/python
# Dependencies:
# pip install flask
# pip install redis
from flask import Flask
from flask import request
import flask
import redis
@calderonroberto
calderonroberto / Node-RED Function as API controller.
Last active August 29, 2015 14:22
A function node for Node-RED that assembles data from WoTKit to create an HTTP request.
// Return an error if data is empty.
if (msg.payload.length === 0){
msg.payload = {"error":"no data found"};
return msg;
}
// Get the values as an array
var values = []
var sensors = []
msg.payload.map(function(element){
@calderonroberto
calderonroberto / README.md
Last active August 29, 2015 14:22
Public WoTKit-powered API

A public API endpoint using WoTKit data to compute average sensor values.

@calderonroberto
calderonroberto / Data Anallysis of Real-World Data With WoTKit and Pandas
Last active August 29, 2015 14:22
Performing statistical data analysis on real-world data using the power of Python and Pandas on WoTKit sensor data.
#!/bin/python
import httplib, urllib, base64, json
import pandas as pd
#TODO: ADD YOUR SENSOR NAME AND CREDENTIALS
SENSOR_NAME = 'mike.yvr-arrive'
USERNAME = 'YOURWOTKITUSERNAME'
PASSWORD = 'YOUROWOTKITPASSWORD'
HOST = 'wotkit.sensetecnic.com'
@calderonroberto
calderonroberto / Get Raw Sensor Data From WoTKit
Last active August 29, 2015 14:22
A simple python script to retrieve raw sensor data from wotkit.
#!/bin/python
import httplib, urllib, base64, json
#TODO: ADD YOUR SENSOR NAME AND CREDENTIALS
SENSOR_NAME = 'mike.yvr-arrive'
USERNAME = 'YOURUSERNAME'
PASSWORD = 'YOURPASSWORD'
HOST = 'wotkit.sensetecnic.com'
auth = base64.encodestring('%s:%s' % (USERNAME, PASSWORD)).replace('\n', '')