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 bobToHexString(data) { | |
local s = "0x"; | |
foreach (b in data) s += format("%02X", b); | |
return s; | |
} | |
function testHash() { | |
local data = "The quick brown fox jumps over the lazy dog"; | |
local hash = http.hash.sha1(data); | |
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 blobToHexString(data) { | |
local s = "0x"; | |
foreach (b in data) s += format("%02X", b); | |
return s; | |
} | |
function testHash() { | |
local data = "The quick brown fox jumps over the lazy dog"; | |
local hash = http.hash.sha512(data); | |
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 blobToHexString(data) { | |
local s = "0x"; | |
foreach (b in data) s += format("%02X", b); | |
return s; | |
} | |
function testHash() { | |
local data = "The quick brown fox jumps over the lazy dog"; | |
local hash = http.hash.sha256(data); | |
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
// Establish the device's settings table with default values | |
deviceSettings <- {}; | |
deviceSettings.mode <- true; | |
deviceSettings.dst <- true; | |
deviceSettings.utc <- false; | |
deviceSettings.offset <- 12; | |
deviceSettings.brightness <- 15; | |
// Load preserved settings in from permanent storage | |
local loadedSettings = server.load(); |
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
// The 'interfaces' variables holds references to available interfaces | |
local interfaces = {}; | |
// Set flags that the app can check to see if an interface can be used | |
local availableForLocal = { "wifi" : false, | |
"ethernet" : false, | |
"cell" : false }; | |
// These globals are used for reporting | |
local interfaceCount = 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
local myArray = [true, true, false, false, true]; | |
myArray.apply(function(value) { | |
return !value; | |
}); | |
// myArray now equals [false, false, true, true, false] |
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
// Get all the local networks | |
local wlans = imp.scanwifinetworks(); | |
local myWlan = null; | |
foreach (network in wlans) { | |
if (network.ssid == "hasdrubals_folly") { | |
// This is my network, so save it | |
myWlan = network; | |
break; | |
} |
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
local sourceArray = [10, 21, 30, 43]; | |
// Find the array items that are multiples of ten | |
local resultArray = sourceArray.filter(function(index, value) { | |
return (value % 10 == 0); | |
}); | |
server.log(resultArray.len()); | |
server.log(sourceArray.len()); | |
// Displays "2" and "4" |
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
// Constants for the alphanumeric character set | |
static charset = [ | |
[0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00], // Space - Ascii 32 | |
[0x00,0x10,0x10,0x10,0x10,0x00,0x10,0x00], // ! | |
[0x00,0x24,0x24,0x00,0x00,0x00,0x00,0x00], // " | |
... | |
[0xFF,0xFF,0xFF,0xFF,0x55,0xAA,0x55,0xAA], | |
[0xAA,0x55,0xAA,0x55,0xFF,0xFF,0xFF,0xFF], | |
[0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55] // Block Graphic 11 | |
]; |
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
local anArray = [true, true, false, false, true]; | |
// Apply the data conversion function and save the result in a new array | |
local newArray = anArray.map(function(value) { | |
return !value; | |
}); | |
// newArray equals [false, false, true, true, false] |