Skip to content

Instantly share code, notes, and snippets.

/*
Requires npm installs for
* nforce (handles salesforce API)
* faye (handles streaming API -- there's an old version in nforce, but install a new one)
* serialport (this handles serial communication and will do a little compiling on your machine)
Configure Salesforce as follows
* Start with a standard developer org -- http://developer.force.com/join
* Install the package for the simple Streaming API demo here
https://github.com/ReidCarlberg/LAB-Streaming-API-Demo
/*
Reid Carlberg
reid.carlberg@gmail.com
v4 - With updated alarm LED wiring and new DISCO handler
v3 - With alarm LED, Longer duration, 00 is key for "ALL DEVICES"
v2 - Custom serial scheme & fixed ID
v1 - JSON & Random ID
@ReidCarlberg
ReidCarlberg / 29-Salesforce-Push-Topic.html
Created December 19, 2013 20:27
The HTML portion of the push topic -- this is where you configure your Client ID, etc.
<!-- Sample html file that corresponds to the 99-sample.js file -->
<!-- This creates and configures the onscreen elements of the node -->
<!-- If you use this as a template, replace IBM Corp. with your own name. -->
<!-- First, the content of the edit dialog is defined. -->
<script type="text/x-red" data-template-name="salesforce in">
// If you use this as a template, replace IBM Corp. with your own name.
// Sample Node-RED node file
// Require main module
var RED = require(process.env.NODE_RED_HOME+"/red/red");
var nforce = require('nforce');
var http = require('http'),
faye = require('faye');
Challenge: deploy node-red to a heroku endpoint.
2013/12/27
First challenge -- you have to have red.js listen on process.env.PORT rather than 1880.
https://devcenter.heroku.com/articles/getting-started-with-nodejs
Second challenge -- web sockets -- node-red uses web sockets, so the server comes up and disconnects right away.
When you enable the lab:websockets it doesn't fix it out of the box.
https://blog.heroku.com/archives/2013/10/8/websockets-public-beta
@ReidCarlberg
ReidCarlberg / Date - This week, Next 90 Days, Past or Future
Last active November 25, 2019 15:53
A formula field for calculating a timeframe.
if (
and (
YEAR(Date_Start__c) == YEAR(TODAY()),
IF(
CEILING( ( Date_Start__c - DATE( YEAR( Date_Start__c ), 1, 1) + 1) / 7) > 52,
52,
CEILING( ( Date_Start__c - DATE( YEAR( Date_Start__c ), 1, 1) + 1) / 7)
) ==
IF(