Skip to content

Instantly share code, notes, and snippets.

@pcon
pcon / .bashrc
Last active May 23, 2016 15:09
My Bash setup
#Add to .bashrc_sfdc
if [ -f $HOME/.bashrc_sfdc ]
then
. $HOME/.bashrc_sfdc
fi
@electricimp
electricimp / spiShiftRegister.device.nut
Last active May 30, 2017 01:09
Example code for writing to a shift register via SPI
// Shift Register via SPI Example
// Configure Hardware
// Pin 1 is the reset line and should be high unless driven low
hardware.pin1.configure(DIGITAL_OUT_OD_PULLUP);
// Pin 8 is the output enable line and should also be high unless driven low
hardware.pin8.configure(DIGITAL_OUT_OD_PULLUP);
@electricimp
electricimp / httpjsonencode.agent.nut
Last active February 20, 2016 22:16
Basic example to demonstrate how to encode json data and POST it to an arbitrary web service.
device.on("senddata", function(data) {
// Set URL to your web service
local url = "https://www.mywebservice/object";
// Set Content-Type header to json
local headers = { "Content-Type": "application/json" };
// encode data and log
local body = http.jsonencode(data);
server.log(body);
@pcon
pcon / Alternate.cls
Last active December 12, 2015 01:48
// Alternate way to get the name from a given Id
String objName = objId.getSObjectType().getDescribe().getName();