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
urlencode() { | |
python -c 'import urllib, sys; print urllib.quote(sys.argv[1], sys.argv[2])' \ | |
"$1" "$urlencode_safe" | |
} |
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 fs = require('fs'); | |
var array = fs.readFileSync('file.txt').toString().split("\n"); | |
for(i in array) { | |
console.log(array[i]); | |
} |
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 jsonToURI(json){ return encodeURIComponent(JSON.stringify(json)); } | |
function uriToJSON(urijson){ return JSON.parse(decodeURIComponent(urijson)); } |
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 util = require('util'); | |
var exec = require('child_process').exec; | |
var command = 'curl -sL -w "%{http_code} %{time_total}\\n" "http://query7.com" -o /dev/null' | |
child = exec(command, function(error, stdout, stderr){ | |
console.log('stdout: ' + stdout); | |
console.log('stderr: ' + stderr); |
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
(async function loop() { | |
for (let i = 0; i <= 10; i++) { | |
await new Promise(resolve => setTimeout(resolve, Math.random() * 1000)); | |
console.log(i); | |
} | |
})(); |
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
fs.appendFile('message.txt', 'data to append', function (err) { | |
if (err) throw err; | |
console.log('The "data to append" was appended to file!'); | |
}); |
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
if ( | |
( | |
(nowHH > openHH) // check hours first | |
|| ( (nowHH == openHH) && (nowMM > openMM) ) // check minutes if in same hour | |
|| ( (nowHH == openHH) && (nowMM == openMM) && (nowSS >= openSS) ) // check seconds if in same hour & minute | |
) | |
&& // both conditions must be valid | |
( | |
(nowHH < closeHH) // check hours first | |
|| ( (nowHH == closeHH) && (nowMM < closeMM) ) // check minutes if in same hour |
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 roundToTwo(num) { | |
return +(Math.round(num + "e+2") + "e-2"); | |
} |
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
#include <FS.h> //this needs to be first, or it all crashes and burns... | |
//#define BLYNK_DEBUG // Comment this out to disable debug and save space | |
#define BLYNK_PRINT Serial // Comment this out to disable prints and save space | |
#include <ESP8266WiFi.h> | |
#include <DNSServer.h> | |
#include <ESP8266WebServer.h> | |
#include <WiFiManager.h> //https://github.com/tzapu/WiFiManager | |
//for LED status | |
#include <Ticker.h> |
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
/* | |
Arduino Protothreading Example v1.0 | |
by Drew Alden (@ReanimationXP) 1/12/2016 | |
*/ | |
//COMPONENTS | |
/* | |
This code was made using the Sunfounder Arduino starter kit's blue LCD. | |
It can be found at Amazon.com in a variety of kits. |