Skip to content

Instantly share code, notes, and snippets.

View Antoinebr's full-sized avatar
:octocat:
🔥

Antoinebr

:octocat:
🔥
View GitHub Profile
var request = require('request');
const cheerio = require('cheerio')
const { URL } = require('url');
const chalk = require('chalk');
@Antoinebr
Antoinebr / moisture-soil-sensor.js
Created March 22, 2018 14:20
espruino moisture-soil-sensor.js
function get() {
return analogRead(NodeMCU.A0 / 1023);
}
function percentage (){
return Math.round(100 - ( get() * 100 ), 1);
}
var SPI2 = new SPI();
SPI2.setup({mosi: NodeMCU.D7 , sck: NodeMCU.D8 });
var disp = require("MAX7219").connect(SPI2, NodeMCU.D5, 4 /* 4 chained devices */);
disp.intensity(0);
@Antoinebr
Antoinebr / espruino-flash
Created February 19, 2018 09:43
go to /espruino_1v95/espruino_1v95_esp8266_4mb
esptool.py --port /dev/cu.SLAB_USBtoUART --baud 115200 write_flash --flash_freq 40m --flash_mode dio --flash_size 4MB 0x00000 "boot_v1.6.bin" 0x1000 espruino_esp8266_user1.bin 0x3FC000 esp_init_data_default.bin 0x37E000 blank.bin
@Antoinebr
Antoinebr / espruino-wifi.js
Last active July 7, 2018 16:22
espruino-wifi.js
const wifi = require("Wifi");
const http = require("http");
wifi.setHostname("antoine-espruino-3");
wifi.connect("potter-club", {password:"Cdfdfflllllffddssddf"}, err => {
@Antoinebr
Antoinebr / debounce.md
Last active December 31, 2017 18:59
debounce JavaScript Vue

Install

npm install debounce 

Require in Vue

function listCaches(){
return new Promise( (resolve, reject) => {  
   
caches.keys().then(function(cacheNames) {
if( cacheNames.length === 0 ) return reject("no caches");
return resolve(cacheNames);
@Antoinebr
Antoinebr / arduino-mqtt-payload-decode.h
Last active November 28, 2017 21:50
arduino-mqtt-payload-decode.h
void callback(char* topic, byte* payload, unsigned int length) {
Serial.print("Message arrived [");
Serial.print(topic);
char message[length + 1];
// copy contents of payload to message
memcpy(message, payload, length);
@Antoinebr
Antoinebr / abGAsendTime.js
Created October 20, 2017 15:28
Get speed Metrics and send them to Google Analytics
abGAsendTime = function(){
this.getLoadTime = function() {
return performance.timing.loadEventStart - performance.timing.navigationStart;
}
@Antoinebr
Antoinebr / espruino-DHT22.js
Created September 8, 2017 10:15
espruino-DHT22.js
var pin = NodeMCU.D2;
var dht = require("DHT22").connect(pin);
var data = {};
setInterval( () =>{