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
/* | |
I need to monitor my UK border crosses for residential purposes. | |
This script will calculate whenever I moved more than 5 degrees, either on lat or long, from one datapoint to the other, since the start of 2017. | |
*/ | |
// First of all, go to Google Takeout and fetch your Location data. | |
// Then, for each day, extract the last position for the day with the following command (using gojq) | |
// cat Records.json | gojq -r '[.locations[] | select((.timestamp | sub("\\.[0-9]+";"") | strptime("%Y-%m-%dT%H:%M:%SZ")) | mktime >= 1483228800) | {latitudeE7, longitudeE7, accuracy, source, timestamp}] | group_by(.timestamp[:10]) | map(max_by(.timestamp)) | map({latitude: (.latitudeE7 / 10000000), longitude: (.longitudeE7 / 10000000), accuracy: .accuracy, source: .source, timestamp: .timestamp})' > grouped.json | |
// *** You might want to change the Unix timestamp after mktime to filter on your needs |
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
// TestSubject.js | |
const ExternalDependency = require('./ExternalDependency') | |
module.exports = class TestSubject { | |
constructor () { | |
this.externalDependency = new ExternalDependency() | |
} | |
isExternalDependencyMocked () { | |
return this.externalDependency.isMocked |
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 = function CustomError(message) { | |
this.name = this.constructor.name | |
this.message = message | |
Error.captureStackTrace(this, this.constructor) | |
} | |
module.exports.prototype.inspect = function () { | |
return this.stack | |
} |
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
//file substack.js | |
module.exports = function() { | |
console.log('main entry point'); | |
}; | |
module.exports.details = function() { | |
console.log('more detailed functionality'); | |
}; | |
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 getDatasetfromJsonData(jsonData){ | |
return jsonData[0].scores; | |
}; | |
function getLabels(dataset) { | |
return Object.keys(dataset) | |
}; | |
function getData(dataset) { | |
return Object.keys(dataset).map(function(key) { |
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
// ...IN THE CALLER | |
import JSONDataConverter from './JSONDataConverter'; | |
<RadarChart data={JSONDataConverter(data)} width={width} height={height} redraw /> |
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 JSONDataConverter = (function () { | |
var getDatasetfromJsonData = function(jsonData){ | |
return jsonData[0].scores; | |
}; | |
var getLabels = function(dataset) { | |
return Object.keys(dataset) | |
}; | |
var getData = function(dataset) { |
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
class DataConverterContainer extends Component { | |
getDatasetfromJsonData(jsonData){ | |
return jsonData[0].scores; | |
}; | |
getLabels(dataset){ | |
return Object.keys(dataset) | |
}; | |
getData(dataset){ |
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
16 lines (14 sloc) 0.36 kB | |
function average(data) { | |
/*Can't find an average function in JS, made one | |
This function is able to handle null values!!!*/ | |
var count = null; | |
var sum = null; | |
for (i=0; i<data.length; i++) { | |
if (data[i]) { | |
count++; |