Last active
September 18, 2017 22:28
-
-
Save TJkrusinski/10735569 to your computer and use it in GitHub Desktop.
Node.js Soup-To-Bits data producer
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
{ | |
"name": "producer", | |
"version": "0.0.0", | |
"description": "produce faux data for Node.js soup to bits", | |
"main": "app.js", | |
"scripts": { | |
"test": "echo \"Error: no test specified\" && exit 1" | |
}, | |
"author": "TJ Krusinski <tjkrus@gmail.com>", | |
"license": "MIT", | |
"dependencies": { | |
"arrandom": "0.0.3", | |
"request": "^2.34.0" | |
} | |
} |
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 request = require('request'); | |
var arrandom = require('arrandom'); | |
var data = [ | |
{ | |
"course_id": 102, | |
"badge_id": "javascript-road-trip-part-2-d4fd45ae7ecb6601fe4a0c8d506ca306.png" | |
}, | |
{ | |
"course_id": 104, | |
"badge_id": "javascript-road-trip-part-3-6c96fe52f9c68b790937d3db2110325a.png" | |
}, | |
{ | |
"course_id": 111, | |
"badge_id": "discover-drive-2b1029e989beb93b6fe63af100dd28d9.png" | |
}, | |
{ | |
"course_id": 112, | |
"badge_id": "exploring-google-maps-for-ios-c6bbca90b0b53d7ba338f91acc88d741.png" | |
}, | |
{ | |
"course_id": 105, | |
"badge_id": "front-end-formations-165329e44a56cd6d401c0c60369d368e.png" | |
}, | |
{ | |
"course_id": 97, | |
"badge_id": "ios-operation-mapkit-1de49437d7999696885179345c443692.png" | |
}, | |
{ | |
"course_id": 98, | |
"badge_id": "jquery-the-return-flight-6bf0a32c22a6804cc007ee71308a5afd.png" | |
}, | |
{ | |
"course_id": 101, | |
"badge_id": "rails-4-patterns-e029cd411b83525e82500b0ce2b268ec.png" | |
}, | |
{ | |
"course_id": 28, | |
"badge_id": "rails-4-zombie-outlaws-34baf50cb535a8ef10496a09cb6f9e07.png" | |
}, | |
{ | |
"course_id": 22, | |
"badge_id": "ruby-bits-part-2-59098ceb97c12ac640eebadf6a4da58a.png" | |
}, | |
{ | |
"course_id": 108, | |
"badge_id": "surviving-apis-with-rails-482f87efd9827f52ecaa027f733592cb.png" | |
} | |
]; | |
var requestObj = { | |
json: data, | |
method: 'POST', | |
url: 'http://localhost:8000' | |
}; | |
(function _request () { | |
requestObj.json = [arrandom(data)[0]]; | |
request(requestObj, function(err){ | |
if (err) console.log(err); | |
setTimeout(_request, 1900); | |
}); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi
I've seen the screencast Build an Image Streaming App With Node.js. I used this code to generate badges for my local installation of the pub/sub server and the webserver. The code is generating information and they are written to Redis correctly, but no badge is shown, because the path to the image is wrong:
http://192.168.142.158:3000/
img src="ruby-bits-part-2-59098ceb97c12ac640eebadf6a4da58a.png" alt="Code School Badge"
What is the correct path for the image to run all locally? (only point to images on codeschool.com). Or what does I have to change, that my local webserver and pub/hub server is working fine. I would like to have all local.
Thanks for your help.