Skip to content

Instantly share code, notes, and snippets.

View monkbroc's full-sized avatar

Julien Vanier monkbroc

View GitHub Profile
@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) {
@monkbroc
monkbroc / index.html
Last active November 6, 2015 17:45
Button Dashboard Theme
<html>
<head><title>Counter</title>
<style>
body {
max-width: 500px;
margin: 50px auto;
text-align: center;
font-family: 'Helvetica','Arial',sans-serif;
}
h1 {
@monkbroc
monkbroc / button.js
Last active November 6, 2015 18:22
Button webhook
module['exports'] = function counter (hook) {
var expectedEvent = "magicButton";
function authorized() {
return hook.params.event === expectedEvent;
}
function increment(key, callback) {
var datastore = hook.datastore;
datastore.get(key, function (err, counter) {
if(err) {
@monkbroc
monkbroc / press.ino
Created November 6, 2015 14:54
Photon Button Press
void loop() {
static bool pressedOld = false;
bool pressed = HAL_Core_Mode_Button_Pressed(50);
if (pressed && !pressedOld) {
Particle.publish("press");
}
pressedOld = pressed;
}
@monkbroc
monkbroc / slack-chrono.js
Last active December 11, 2015 19:53
Chrono Slack command
// A Slack slash command to convert between timezones.
// Copyright 2015 Julien Vanier
// Released under the MIT license
// Adapted from https://github.com/forresto/slack-slash-time
var got = require('got');
var chrono = require('chrono-node');
var moment = require('moment');
// Entry point for hook.io
@monkbroc
monkbroc / In case of fire.svg
Created October 11, 2015 21:39
In case of fire
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@monkbroc
monkbroc / build.log
Created August 27, 2015 23:37
Particle debugger log
monkbroc@slim:~/Programming/Photon/modules$ make clean all program-dfu PARTICLE_DEVELOP=1 PLATFORM=photon USE_SWD_JTAG=y
clean all program-dfu
make -C /home/monkbroc/Programming/Photon/modules/photon/system-part1/ clean all program-dfu USE_SWD_JTAG=y PLATFORM=photon PARTICLE_DEVELOP=1
make[1]: Entering directory '/home/monkbroc/Programming/Photon/modules/photon/system-part1'
make -C ../../../communication clean
make[2]: Entering directory '/home/monkbroc/Programming/Photon/communication'
rm -f ../build/target/communication/platform-6-m-prod-6/lib/tropicssl/library/aes.o ../build/target/communication/platform-6-m-prod-6/lib/tropicssl/library/bignum.o ../build/target/communication/platform-6-m-prod-6/lib/tropicssl/library/padlock.o ../build/target/communication/platform-6-m-prod-6/lib/tropicssl/library/rsa.o ../build/target/communication/platform-6-m-prod-6/lib/tropicssl/library/sha1.o ../build/target/communication/platform-6-m-prod-6/src/coap.o ../build/target/communication/platform-6-m-prod-6/src/handshake.
@monkbroc
monkbroc / profiler_authorization.rb
Created August 27, 2015 20:45
Profiler authorization
require 'active_support/concern'
# In application_controller.rb:
# include Concerns::ProfilerAuthorization
module Concerns::ProfilerAuthorization
extend ActiveSupport::Concern
included do
before_action :authorize_profiler
@monkbroc
monkbroc / detect_leaks.rb
Created August 27, 2015 20:24
Heap dump scripts
#!/usr/bin/env ruby
# Analyze heap dumps for memory leaks
#
# Gather the memory dumps with
# bundle exec rbtrace — timeout 30 -e ‘load “#{Rails.root}/scripts/heap_dump.rb”’ -p $RAILS_PID
require 'set'
require 'json'
if ARGV.length != 3
@monkbroc
monkbroc / schema.sql
Created August 21, 2015 21:30
Schema for skills sharing app
--
-- PostgreSQL database dump
--
SET statement_timeout = 0;
SET lock_timeout = 0;
SET client_encoding = 'UTF8';
SET standard_conforming_strings = on;
SET check_function_bodies = false;
SET client_min_messages = warning;