Skip to content

Instantly share code, notes, and snippets.

<?
// set some variables we'll use later
$timezone_offset = '-06'; // set to your local timezone offset from UTC
$raw_url = "http://urltoyourdata.xml"; // replace with actual path to your published raw data
$title = "data logger"; // the title for your Cosm feed
$feed_id = 83211;
$api_key = "insert_api_key"; // this api key needs to have 'update' access to your feed
@smulube
smulube / automatic_cosm.php
Created October 30, 2012 09:59
Simple PHP script for converting WEL web energy logger XML for Cosm
<?
// set some variables we'll use later
$timezone_offset = '-05'; // set to your local timezone offset from UTC
$raw_url = "http://urltoyourdata.xml"; // replace with actual path to your published raw data
$title = "The title for your feed"; // the title for your Cosm feed
// Get raw data
$raw_xml = simplexml_load_file($raw_url);
@smulube
smulube / gist:3347929
Created August 14, 2012 09:59
Sample multi datastream CSV
stream0,2012-05-01T00:00:00Z,1
stream0,2012-05-01T00:00:05Z,2
stream0,2012-05-01T00:00:06Z,3
stream0,2012-05-01T00:00:07Z,4
stream1,2012-05-01T00:00:00Z,1
stream1,2012-05-01T00:00:05Z,2
stream1,2012-05-01T00:00:06Z,3
stream1,2012-05-01T00:00:07Z,4
@smulube
smulube / gist:2718463
Created May 17, 2012 12:06
Basic Cosm WebSocket example
<html>
<head>
<title>Socket Test</title>
</head>
<body>
<h1>Cosm Websocket Test</h1>
<p>Status: <span id="status"></span></p>
<p>Current value: <span id="current_value"></span></p>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.7.2.min.js"></script>
<script type="text/javascript">
# Create an object from an eeml document
environment = Eeml::Environment.new_from_eeml(string_containing_eeml_representation)
# attributes available like this
puts environment.title
puts environment.description
puts environment.feed
# etc...
# alternatively would this be better?