Skip to content

Instantly share code, notes, and snippets.

View rafaelmaeuer's full-sized avatar

Rafael M. rafaelmaeuer

View GitHub Profile
urlencode() {
python -c 'import urllib, sys; print urllib.quote(sys.argv[1], sys.argv[2])' \
"$1" "$urlencode_safe"
}
var fs = require('fs');
var array = fs.readFileSync('file.txt').toString().split("\n");
for(i in array) {
console.log(array[i]);
}
function jsonToURI(json){ return encodeURIComponent(JSON.stringify(json)); }
function uriToJSON(urijson){ return JSON.parse(decodeURIComponent(urijson)); }
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);
(async function loop() {
for (let i = 0; i <= 10; i++) {
await new Promise(resolve => setTimeout(resolve, Math.random() * 1000));
console.log(i);
}
})();
fs.appendFile('message.txt', 'data to append', function (err) {
if (err) throw err;
console.log('The "data to append" was appended to file!');
});
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
function roundToTwo(num) {
return +(Math.round(num + "e+2") + "e-2");
}
#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>
/*
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.