Skip to content

Instantly share code, notes, and snippets.

View monkbroc's full-sized avatar

Julien Vanier monkbroc

View GitHub Profile
@monkbroc
monkbroc / settings.js
Last active October 24, 2016 17:58
CLI settings with additional logging
/**
******************************************************************************
* @file settings.js
* @author David Middlecamp (david@particle.io)
* @company Particle ( https://www.particle.io/ )
* @source https://github.com/spark/particle-cli
* @version V1.0.0
* @date 14-February-2014
* @brief Setting module
******************************************************************************
@monkbroc
monkbroc / _service.md
Created August 26, 2016 20:21 — forked from naholyr/_service.md
Sample /etc/init.d script

Sample service script for debianoids

Look at LSB init scripts for more information.

Usage

Copy to /etc/init.d:

# replace "$YOUR_SERVICE_NAME" with your service's name (whenever it's not enough obvious)
@monkbroc
monkbroc / FreeRTOS.a
Last active June 15, 2016 11:38
Onboard RTOS thread walking and stack dumping for system thread

Keybase proof

I hereby claim:

  • I am monkbroc on github.
  • I am jvanier (https://keybase.io/jvanier) on keybase.
  • I have a public key whose fingerprint is F7EE AE22 D936 1AE4 495D 7C50 6A7E E035 A430 D34E

To claim this, I am signing this object:

@monkbroc
monkbroc / tree.cpp
Last active December 24, 2015 14:01
Animated Particle tree
#include "application.h"
char number = -1;
char maxNumber = 2;
bool alt = false;
int setNumber(String value) {
EEPROM.write(0, value.toInt());
return 0;
}
@monkbroc
monkbroc / beach-safety-v1.js
Last active December 13, 2015 16:03
Beach safety web hook
module['exports'] = function udpateBeachStatus (hook) {
var got = require('got');
got('http://hawaiibeachsafety.com/rest/ratings.json')
.then(function (response) {
hook.res.end(response.body);
})
.catch(function (error) {
hook.res.end("Error fetching data: " + error);
});
};
@monkbroc
monkbroc / beach-safety.ino
Created December 13, 2015 15:14
Beach safety
int setBeachStatus(String value) {
RGB.control(true);
if(value == "green") {
RGB.color(RGB_COLOR_GREEN);
return 0;
} else if(value == "yellow") {
RGB.color(RGB_COLOR_YELLOW);
return 0;
} else if(value == "red") {
RGB.color(RGB_COLOR_RED);
@monkbroc
monkbroc / what-to-wear.js
Last active November 29, 2018 14:52
What to wear
function forecastUrl(apiKey, location) {
var apiUrl = "https://api.forecast.io/forecast";
var excludeFields = "exclude=minutely,hourly";
return apiUrl + "/" + apiKey + "/" + location + "?" + excludeFields;
}
function getForecast(url) {
var got = require("got");
return got(url)
.then(function (response) {
@monkbroc
monkbroc / particle.js
Created November 11, 2015 00:35
List devices hook
module['exports'] = function particle (hook) {
var Spark = require('spark');
function output(data) {
hook.res.end(JSON.stringify(data, true, 2));
}
var token = hook.env.PARTICLE_API_TOKEN;
Spark.login({ accessToken: token }).
then(function () {
@monkbroc
monkbroc / dashboard.js
Created November 6, 2015 17:08
Button dashboard code
module['exports'] = function dashboard (hook) {
function get(key, callback) {
var datastore = hook.datastore;
datastore.get(key, function (err, counter) {
callback(counter || 0);
});
}
get('counter', function (counter) {