Created
October 7, 2013 21:58
-
-
Save wolfeidau/6875651 to your computer and use it in GitHub Desktop.
Leaking Code
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = {key: 'XXXX', secret:'XXXX'}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
var url = require('url'); | |
var request = require('request'); | |
var creds = require('./creds.js'); | |
var scheme = 'https'; | |
var hostname = 'api.tempo-db.com'; | |
var baseUrl = scheme + '://' + hostname; | |
var auth = 'Basic ' + new Buffer(creds.key + ':' + creds.secret).toString('base64'); | |
var headers = { | |
Host: hostname, | |
Authorization: auth | |
}; | |
var seriesKey = '1_D90343085872CA9C_687_0_2000'; | |
function uploadEntry(cb){ | |
var data = []; | |
data.push({t: new Date(), v: Math.random() * 50}) | |
var opts = { | |
url: url.parse(baseUrl + '/v1/series/key/' + seriesKey + '/data/'), | |
method: 'POST', | |
headers: headers, | |
body: JSON.stringify(data) | |
} | |
console.log('sending', data[0]); | |
request(opts,cb); | |
}; | |
function callback(err, result){ | |
if (!err) console.log('statusCode', result.statusCode); | |
} | |
setInterval(uploadEntry.bind(null, callback), 1000); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Diff of pmap.