Skip to content

Instantly share code, notes, and snippets.

View afawcett's full-sized avatar

Andrew Fawcett afawcett

View GitHub Profile
@afawcett
afawcett / EV3DirectCommand.java
Created October 4, 2015 18:19
Lego EV3 MachineCloud Java Code
package com.andyinthecloud.legoev3force.ev3kernal;
import lejos.hardware.Button;
import lejos.hardware.motor.Motor;
import lejos.hardware.port.SensorPort;
import lejos.hardware.sensor.EV3TouchSensor;
import lejos.robotics.SampleProvider;
import lejos.robotics.filter.AbstractFilter;
/**
@afawcett
afawcett / CMTService.cls
Last active August 17, 2018 23:53 — forked from madmax983/CMTService.cls
Apex Stub API with Static Methods
public with sharing class CMTService {
public List<CMTWrapper> getCMTs() {
List<CMTWrapper> cmtWrappers = new List<CMTWrapper>();
List<CMT__mdt> cmts = [SELECT Example_Field_1__c, Example_Field_2_c FROM CMT__mdt];
for(CMT__mdt c : cmts) {
CMTWrapper cmtWrapper = new CMTWrapper(c.Example_Field_1__c, c.Example_Field_2__c);
cmtWrappers.add(cmtWrapper);
}
return cmtWrappers;
@afawcett
afawcett / EinsteinSentimentAction.cls
Created July 31, 2017 01:45
Einstein Sentiment Wrappers
public with sharing class EinsteinSentimentAction {
public class Request {
@InvocableVariable
public String recordId;
@InvocableVariable
public String document;
@InvocableVariable
public String modelId;
}
/**
*
CustomMetadata.Operations
.callback(
// Platform event for deploy status
MetadataDeployment__e.getSObjectType(),
MetadataDeployment__e.DeploymentId__c,
MetadataDeployment__e.Result__c)
.enqueueUpsertRecords(
// Metadata record type
public with sharing class ValidationController
{
private ApexPages.StandardController standardController;
public ValidationController(ApexPages.StandardController standardController)
{
// Configure fields to query and valid (alternative to SOQL)
this.standardController = standardController;
if(!Test.isRunningTest())
this.standardController.addFields(
@afawcett
afawcett / RemoteObjectsDemo.page
Last active August 4, 2017 13:58
Demo of Visualforce Remote Objects vs Remote Actions for blog post on the pros and cons
<apex:page controller="RemoteObjectDemoController">
<apex:remoteObjects >
<apex:remoteObjectModel name="WorkOrder__c" fields="Id,Name,AccountName__c,Cost__c"/>
<apex:remoteObjectModel name="WorkOrderLineItem__c" fields="Id,Name,Description__c,Hours__c,WorkOrder__c"/>
</apex:remoteObjects>
<script>
function doSomethingJS(answer)
{
// Create work order
var workOrder = new SObjectModel.WorkOrder__c();
public with sharing class EinsteinAction {
public class Prediction {
@InvocableVariable
public String label;
@InvocableVariable
public Double probability;
}
@InvocableMethod(label='Classify the given files' description='Calls the Einsten API to classify the given ContentVersion files.')
@afawcett
afawcett / MyReportNotificationFlow-1.flow
Created September 26, 2016 09:25
Definition of the TaskReminder Flow
<?xml version="1.0" encoding="UTF-8"?>
<Flow xmlns="http://soap.sforce.com/2006/04/metadata">
<actionCalls>
<name>TaskReminder</name>
<label>TaskReminder</label>
<locationX>21</locationX>
<locationY>32</locationY>
<actionName>NewTask</actionName>
<actionType>quickAction</actionType>
<inputParameters>
@afawcett
afawcett / build.xml
Created July 16, 2016 11:15
Cloud9 /src Directory Fix
<project>
<target name="cloud9.github.init">
</target>
<target name="sync.from.cloud9">
<sync todir="src/classes" verbose="true">
<fileset dir="${basedir}/classes">
<exclude name="**/.c9/**"/>
</fileset>
</sync>
PermissionSet permissionSet = new PermissionSet();
permissionSet.Name='ApexTest';
permissionSet.label='Apex Test';
insert permissionSet;
ObjectPermissions objectPermission = new ObjectPermissions();
objectPermission.ParentId = permissionSet.Id;
objectPermission.SObjectType = Book_Order__c.SObjectType.getDescribe().getName();
objectPermission.PermissionsEdit = true;
objectPermission.PermissionsRead = true;
objectPermission.PermissionsDelete = true;