Skip to content

Instantly share code, notes, and snippets.

/* Example for sending an email when there is an error on a JSON request */
private static void sendErrorEmail(String method, HttpResponse response, String requestJSON) {
Messaging.SingleEmailMessage message = new Messaging.SingleEmailMessage();
message.toAddresses = new String[] { 'me@example.org' };
message.subject = 'Error in ' + method + ' : ' + response.getStatusCode() + ' - ' + response.getStatus();
if (requestJSON == '' || requestJSON == null)
message.plainTextBody = 'No body';
else message.plainTextBody = requestJSON;
Messaging.SingleEmailMessage[] messages = new List<Messaging.SingleEmailMessage> {message};
Messaging.SendEmailResult[] results = Messaging.sendEmail(messages);
@danic85
danic85 / gist:4c48f7dd1d4532049b491c8cd1d47f31
Created December 7, 2016 14:46
Binding lightning:input checkbox value. Must bind to 'checked' not 'value'
<aura:attribute name="testBoolean" type="Boolean" default="false" />
<lightning:input name="testBoolean" label="Test Boolean" type="checkbox" checked="{!v.testBoolean}" />
@danic85
danic85 / arduino-watch-frog-sketch
Last active September 10, 2021 19:18
Arduino Watch Frog (HC-SR04 door distance alarm)
// ---------------------------------------------------------------- //
// Arduino Watch Frog (HC-SR04 door distance alarm)
// Place with sensor facing a closed door and then attach power.
// Alarm will sound if distance to door changes in either direction
// beyond the THRESHOLD. Alarm will not stop until power is disconnected.
// Tested on 10 September 2020
// Author: Dan Nicholson (github.com/danic85)
// ---------------------------------------------------------------- //
#define echoPin 7 // Echo of HC-SR04
@danic85
danic85 / arduino-smart-servo
Created September 10, 2021 19:33
Arduino Smart Servo (continuous servo voltage monitor)
// ---------------------------------------------------------------- //
// Arduino Smart Servo (continuous servo voltage monitor)
// Uses a uses a shunt resistor to create a voltage divider that the arduino can monitor.
// When the voltage passes a threshold the servo pauses for a second before continuing.
// https://www.instagram.com/p/CTXWAH9jmJE/
// Tested on September 2020
// Author: Dan Nicholson (github.com/danic85)
// ---------------------------------------------------------------- //
#include <Servo.h>
@danic85
danic85 / docker-ros-ref-mac.md
Last active January 23, 2023 20:52
ROS2 on MacOS reference commands
@danic85
danic85 / RobotLeg.ino
Created February 26, 2023 19:07
Test script for robotic legs
/*
* ThreeServos.cpp
*
* Shows smooth movement from one servo position to another for 3 servos synchronously.
* Demonstrates the use of ServoEasingArray and ServoEasingNextPositionArray.
*
* Copyright (C) 2019-2022 Armin Joachimsmeyer
* armin.joachimsmeyer@gmail.com
*
* This file is part of ServoEasing https://github.com/ArminJo/ServoEasing.
2023-11-25T16:43:08.623Z   error   robot_server   impl/resource_manager.go:472   configuration error: reached max of 5 configuration attempts for rdk:component:board/local  
2023-11-25T16:43:03.624Z   error   robot_server   impl/resource_manager.go:621   error building resource   resource rdk:component:board/local   model rdk:builtin:pi   error error: PI_INIT_FAILED: gpioInitialise failed  
2023-11-25T16:42:58.624Z   error   robot_server   impl/resource_manager.go:621   error building resource   resource rdk:component:board/local   model rdk:builtin:pi   error error: PI_INIT_FAILED: gpioInitialise failed  
2023-11-25T16:42:53.124Z   error   robot_server   impl/resource_manager.go:621   error building resource   resource rdk:component:board/local   model rdk:builtin:pi   error error: PI_INIT_FAILED: gpioInitialise failed  
2023-11-25T16:42:48.125Z   error   robot_server   impl/resource_manager.go:621   error building resource   resource rdk:component:board/local   model rdk:builtin:pi   error error: PI_INIT_FA
$ sudo gpioinfo
gpiochip0 - 32 lines:
line 0: "-" unused input active-high
line 1: "2712_BOOT_CS_N" "spi10 CS0" output active-low [used]
line 2: "2712_BOOT_MISO" unused input active-high
line 3: "2712_BOOT_MOSI" unused input active-high
line 4: "2712_BOOT_SCLK" unused input active-high
line 5: "-" unused input active-high
line 6: "-" unused input active-high
line 7: "-" unused input active-high
@danic85
danic85 / gist:5cb7e43c720e23db32aa77d8dd263d01
Created November 30, 2023 07:19
Viam - Pi 5 Camera Error Logs
2023-11-30T07:18:26.610Z   error   robot_server.rdk:component:camera/camera   resource/graph_node.go:223   resource build error: rpc error: code = Unavailable desc = error reading from server: EOF   resource rdk:component:camera/camera   model viam:camera:csi-pi  
2023-11-30T07:18:26.610Z   error   robot_server   modmanager/manager.go:620   module has unexpectedly exited, attempting to restart it   module viam_csi-cam-pi  
2023-11-30T07:18:26.478Z   error   robot_server.process.viam_csi-cam-pi_/root/.viam/packages/.data/module/e76d1b3b-0468-4efd-bb7f-fb1d2b352fcb-csi-cam-pi-0_3_0-linux-arm64/bin/viam-csi-latest-aarch64.AppImage.StdErr   pexec/managed_process.go:242   \_ Failed to start the pipeline  
2023-11-30T07:18:26.459Z   error   robot_server.process.viam_csi-cam-pi_/root/.viam/packages/.data/module/e76d1b3b-0468-4efd-bb7f-fb1d2b352fcb-csi-cam-pi-0_3_0-linux-arm64/bin/viam-csi-latest-aarch64.AppImage.StdErr   pexec/managed_process.go:242   \_ [8:23:37.657109219] [5436]  INFO Camera c
@danic85
danic85 / gist:99bfa7b20d5f5b4151bc04d03523af40
Last active November 30, 2023 23:00
Viam - Pi5 Camera Error Log with camera:csi
2023-11-30T22:56:53.854Z   error   robot_server.process.ilboud_picam2_/root/.viam/packages/.data/module/eb7f22ef-2bbc-45ac-9d70-72271d2fa7ae-picam2-0_0_9-linux-arm64/run.sh.StdErr   pexec/managed_process.go:242   \_ hint: See above for details.  
2023-11-30T22:56:53.854Z   error   robot_server.process.ilboud_picam2_/root/.viam/packages/.data/module/eb7f22ef-2bbc-45ac-9d70-72271d2fa7ae-picam2-0_0_9-linux-arm64/run.sh.StdErr   pexec/managed_process.go:242   \_ note: This is an issue with the package mentioned above, not pip.  
2023-11-30T22:56:53.854Z   error   robot_server.process.ilboud_picam2_/root/.viam/packages/.data/module/eb7f22ef-2bbc-45ac-9d70-72271d2fa7ae-picam2-0_0_9-linux-arm64/run.sh.StdErr   pexec/managed_process.go:242   \_  
2023-11-30T22:56:53.854Z   error   robot_server.process.ilboud_picam2_/root/.viam/packages/.data/module/eb7f22ef-2bbc-45ac-9d70-72271d2fa7ae-picam2-0_0_9-linux-arm64/run.sh.StdErr   pexec/managed_process.go:242   \_ See above for output.  
2023-11-30T22:56:53.854Z   error