Skip to content

Instantly share code, notes, and snippets.

@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(
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
// 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');
@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">
/*
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
/*
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
@ReidCarlberg
ReidCarlberg / Simple_MotorParty
Created November 1, 2013 22:18
One DC Motor one 1, one Servo on the outer controller.
/*
This is a test sketch for the Adafruit assembled Motor Shield for Arduino v2
It won't work with v1.x motor shields! Only for the v2's with built in PWM
control
For use with the Adafruit Motor Shield v2
----> http://www.adafruit.com/products/1438
This sketch creates a fun motor party on your desk *whiirrr*
Connect a unipolar/bipolar stepper to M3/M4
@ReidCarlberg
ReidCarlberg / Simplest DC Motor Test
Created November 1, 2013 22:16
Simplest possible Motor Shield Test - one motor full speed on and off.
/*
This is a test sketch for the Adafruit assembled Motor Shield for Arduino v2
It won't work with v1.x motor shields! Only for the v2's with built in PWM
control
For use with the Adafruit Motor Shield v2
----> http://www.adafruit.com/products/1438
*/
#include <Wire.h>
const int xInput = A0;
const int yInput = A1;
const int zInput = A2;
void setup()
{
Serial.begin(9600);
}
void loop()
@ReidCarlberg
ReidCarlberg / Halloween 2013
Created October 26, 2013 18:52
Halloween 2013
/*
Terrible Code written by @ReidCarlberg
I promise to refactor it sometime.
*/
#include <Wire.h>
#include <Adafruit_LSM303.h>
#include <Adafruit_NeoPixel.h>
#define PIN 6