View arduino-smart-servo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ---------------------------------------------------------------- // | |
// 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> |
View arduino-watch-frog-sketch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ---------------------------------------------------------------- // | |
// 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 |
View send-error-email.apex
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* 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); |
View TestComponent.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<aura:component implements="flexipage:availableForAllPageTypes"> | |
<!-- Simple example of conditional default blocking changes --> | |
<aura:attribute name="myString" type="string" default="{!if(false, 'Default Val', 'Other Default')}"/> | |
<aura:attribute name="mySimpleString" type="string" default="Default Val"/> | |
<!-- Conditional default on object value will update, but will not allow external changes --> | |
<aura:attribute name="myObj" type="object"/> | |
<aura:attribute name="myObjString" type="string" default="{!if(empty(v.myObj), 'Default Val', v.myObj.val)}"/> | |
<aura:handler name="init" value="{!this}" action="{!c.doInit}" /> |
View TestComponent.cmp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<aura:component implements="flexipage:availableForAllPageTypes"> | |
<aura:attribute name="myString" type="string" default="{!if(false, 'Default Val', 'Other Default')}"/> | |
<aura:attribute name="mySimpleString" type="string" default="Default Val"/> | |
<aura:handler name="init" value="{!this}" action="{!c.doInit}" /> | |
<div class="slds-card"> | |
{!v.myString} <!-- Will always output 'Other Default', even if changed later by doInit --> | |
{!v.mySimpleString} <!-- Will be changed to 'Set Directly' by doInit --> | |
</div> | |
</aura:component> |
View onewire.ino
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* YourDuino Example: Find Address of a DS18B20 Temperature Sensor | |
Cut and paste the address to a text file for later use. | |
V1.1 01/17/2013 | |
Questions: terry@yourduino.com | |
URL: http://arduino-info.wikispaces.com/Brick-Temperature-DS18B20#Read%20individual | |
Connections: | |
DS18B20 Pinout (Left to Right, pins down, flat side toward you) | |
- Left = Ground | |
- Center = Signal (Pin 2): (with 3.3K to 4.7K resistor to +5 or 3.3 ) |
View cancelScheduledJobs.cls
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Cancel Scheduled Jobs in Apex */ | |
for(CronTrigger delCron: [SELECT Id FROM CronTrigger ]) { | |
System.abortJob(delCron.Id); | |
} |
View urlformat.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
window.location.pathname |
View outputproxy.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
outputProxy : function(record) { | |
var obj = {}; | |
for(var propt in record) { | |
obj[propt] = record[propt]; | |
if (typeof(record[propt]) == 'object') { | |
obj[propt] = this.outputProxy(record[propt]); | |
} | |
} | |
return obj; | |
} |
View gist:a5519c6591bce94cf4e7c7064506c50b
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//https://developer.salesforce.com/page/Lightning_Security#Access_Control_in_Apex_Controllers_and_Supporting_Classes | |
List<String> fields = new List<string>(); // Add your fields to check here | |
String objectName = ''; //Add your object name here | |
Map<String,Schema.SObjectField> fieldMap = Schema.getGlobalDescribe().get(objectName).getDescribe().fields.getMap() | |
for (String fieldToCheck : fields) { | |
// Check if the user has access to view field | |
if (!fieldMap.get(fieldToCheck).getDescribe().isAccessible()) { | |
//also pass error to client | |
throw new System.NoAccessException(); |
NewerOlder