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
var express = require("express"); | |
var app = express(); | |
app.use(express.bodyParser()); | |
app.post('/postTest', function(req, res) { | |
if (req.body.hasOwnProperty("test")) { | |
console.log("test property is: " + req.body.test); | |
res.json({ok: true }); | |
} else { | |
console.log("no test property"); |
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
import React from "react"; | |
import RefreshIndicator from "material-ui/lib/refresh-indicator"; | |
class RefreshIndicatorBroken extends React.Component { | |
constructor() { | |
super(); | |
this.state = { | |
showRefresh: true | |
}; |
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
var topojson = require("topojson"); | |
//var TDXApi = require("nqm-api-tdx"); | |
var fs = require("fs"); | |
function propertyTransform(feature) { | |
return feature.properties; | |
} | |
function databot(input, output, context) { | |
output.progress(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
function createSchemaFromObject(inputObj) { | |
const keys = Object.keys(inputObj); | |
const schema = {}; | |
_.forEach(keys, (key) => { | |
if (typeof inputObj[key] === "string") { | |
schema[key] = { __tdxType: ["string"] }; | |
} else if (_.isNumeric(inputObj[key])) { | |
schema[key] = { __tdxType: ["number"] }; | |
} else { | |
// Check for arrays, objects, date? |
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
var filestream = fs.createReadStream(file); | |
filestream.pipe(res) | |
.on("finish", function() { | |
log("resource download complete"); | |
}) | |
.on("error", function(err) { | |
errLog("failure during resource download: %s", err.message); | |
}); | |
res |
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
parseXmlStringAsync(response.text) | |
.then((result) => { | |
var entryList = []; | |
_.forEach(result.feed.datastream, (val) => { | |
if (idList.indexOf(Number(val['$']['id'])) > -1) { | |
var entry = { | |
'ID': Number(val['$']['id']), | |
'timestamp': Number(new Date(val.current_time[0]).getTime()), | |
'currentvalue': Number(val.current_value[0]), | |
'maxvalue': Number(val.max_value[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
/* | |
* BEFORE | |
*/ | |
import {dataLoader} from "nqm-app-framework"; | |
//... | |
export default dataLoader.merge( | |
dataLoader.compose(dataLoader.trackerFactory(dataMapper), {propsToWatch: ["parentId"]}), | |
dataLoader.compose(dataLoader.reduxFactory(stateMapper)), |
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
let total = 0; | |
for (let i = 0; i < 100; i++) { | |
asynchronousFunction(i, (result) => { | |
total = total + result; | |
}); | |
} | |
storeTotal(total); | |
/* | |
what is wrong with this 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
// estimator.js | |
module.exports = (function() { | |
var getData = function(id, cb) { | |
return api.getDataAsync(id, this.state.filter); | |
} | |
function estimator(initial) { | |
this.state = initial; |
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
let total = 0; | |
const processChunk = function(chunkList, chunkIndex) { | |
const chunk = chunkList[chunkIndex]; | |
// do stuff with chunk asynchronously | |
return doStuff(chunk) | |
.then((result) => { | |
if (chunkIndex < chunkList.length) { | |
total += result; |
OlderNewer