Skip to content

Instantly share code, notes, and snippets.

View johnathanDOS's full-sized avatar
🌵
[ • • ]

Johnathan Ortiz-Sonnen johnathanDOS

🌵
[ • • ]
View GitHub Profile
/*eloquent javascript solution*/
var differences = ancestry.filter(function(person) {
return byName[person.mother] != null;
}).map(function(person) {
return person.born - byName[person.mother].born;
});
console.log(average(differences))
<!DOCTYPE html>
<html>
<body>
<form action="">
bill amount:<br>
<input type="text" id="bill" value="0.00"><br>
tip amount:<br>
<input type="text" id="tip" value="0.15"><br><br>
</form>
<button onclick="calculateTip()" id="calculate">Calculate Tip</button><br>
@johnathanDOS
johnathanDOS / convertUnit.js
Created June 5, 2017 00:17
This function interacts with HTML elements to convert a number from one unit of measurement to another.
function convertUnit() {
//check to see if the input is a number
var input = document.getElementById("userInput").value
var startUnit = document.getElementsByName("startUnit");
var endUnit = document.getElementsByName("endUnit");
var output = ""
//check to see if input is a number
if (isNaN(input) == true) {
@johnathanDOS
johnathanDOS / registerFaceRec.js
Last active April 29, 2019 18:40
Register for face recognition events on Misty
function registerFaceRec(){
misty.AddPropertyTest("FaceRec", "PersonName", "exists", "", "string");
misty.RegisterEvent("FaceRec", "FaceRecognition", 1000, true);
}
registerFaceRec();
@johnathanDOS
johnathanDOS / _FaceRec.js
Last active January 21, 2019 23:46
_FaceRec() callback
function _FaceRec(data) {
// Check if the FaceRec event was triggered by a stranger
if (data.PropertyTestResults[0].PropertyValue == "unknown person"){
// Misty doesn't recognize this person. Sound the alarm!
}
else {
// Misty knows this person. Do something else.
}
}
@johnathanDOS
johnathanDOS / faceRecCallback.js
Created January 21, 2019 23:38
faceRecCallback.js
function _FaceRec(data) {
// Check if the FaceRec event was triggered by a stranger
if (data.PropertyTestResults[0].PropertyValue == "unknown person"){
// Misty doesn't recognize this person. Sound the alarm!
}
else {
// Misty knows this person. Do something else.
}
}
misty.SendExternalRequest("GET", "http://api.apixu.com/v1/current.json?key=<key>&q=Paris", null, null, "application/json", "{}")
function _SendExternalRequest(data) {
_data = JSON.parse(data.Result.ResponseObject.Data)
_condition = _data.current.condition.text
misty.Debug(_condition);
}
misty.SendExternalRequest("POST", "https://maker.ifttt.com/trigger/blink_intruder/with/key/<key>",null,null,"","{}");
misty.SendExternalRequest("POST", "https://maker.ifttt.com/trigger/text_intruder/with/key/<key>",null,null,"","{}");
function _SendExternalRequest(data_response) {
misty.Debug(JSON.stringify(data_response));
}