Skip to content

Instantly share code, notes, and snippets.

View keirbowden's full-sized avatar

Keir Bowden keirbowden

View GitHub Profile
@keirbowden
keirbowden / deploy_notify.js
Created April 16, 2018 11:54
Node JS script to generate a MacOS notification when a deployment finishes
#!/usr/local/bin/node
var fs=require('fs');
var child_process=require('child_process');
var username='keir.bowden@sfdx.deploy';
var deployParams=['force:mdapi:deploy', '-d', 'src',
'-u', username, '--json'];
@keirbowden
keirbowden / deploy_format_output.js
Created April 16, 2018 11:49
Example Node JS script to process SFDX deployment report output and reformat.
#!/usr/local/bin/node
var fs=require('fs');
var child_process=require('child_process');
var username='keir.bowden@sfdx.deploy';
var deployParams=['force:mdapi:deploy', '-d', 'src',
'-u', username, '--json'];
@keirbowden
keirbowden / BarcodeSF1
Created March 15, 2014 12:17
Visualforce page to decode a barcode from a captured or selected image.
<apex:page applyHtmlTag="false" showheader="false" sidebar="false" controller="BarcodeSF1Ctrl">
<head>
<title>BarcodeReader</title>
<apex:stylesheet value="{!URLFOR($Resource.alertify, 'alertify.js-0.3.11/themes/alertify.core.css')}"/>
<apex:stylesheet value="{!URLFOR($Resource.alertify, 'alertify.js-0.3.11/themes/alertify.default.css')}"/>
<apex:includeScript value="{!URLFOR($Resource.alertify, 'alertify.js-0.3.11/lib/alertify.min.js')}"/>
</head>
<body>
<div>
<img width="320" height="240" src="" id="picture" style="border:10px groove silver" />
@keirbowden
keirbowden / BarcodeSF1Ctrl
Created March 15, 2014 12:19
Visualforce controller with a JavaScript remoting method to retrieve a matching record after scanning a barcode.
public with sharing class BarcodeSF1Ctrl
{
@RemoteAction
public static String getRecordFromBarcode(String bcStr)
{
String result;
List<String> eles=bcStr.split(':');
String code=eles[1].trim();
List<Account> accs=[select id, Barcode__c from Account where Barcode__c=:code];
<apex:page >
<script type="text/javascript">
var __sfdcSessionId = '{!GETSESSIONID()}';
</script>
<script src="../../soap/ajax/40.0/connection.js"
type="text/javascript"></script>
<script type="text/javascript">
function getMetrics()
{
@keirbowden
keirbowden / Streaming.component
Last active July 23, 2017 10:30
Visualforce component to display browser notifications when a case is updated that is owned by the currently logged in user
<apex:component >
<apex:attribute name="topic" description="The topic name" type="String" required="true"/>
<apex:includeScript value="{!URLFOR($Resource.streaming, 'streaming/cometd.js')}"/>
<apex:includeScript value="{!URLFOR($Resource.streaming, 'streaming/jquery-1.5.1.js')}"/>
<apex:includeScript value="{!URLFOR($Resource.streaming, 'streaming/json2.js')}"/>
<apex:includeScript value="{!URLFOR($Resource.streaming, 'streaming/jquery.cometd.js')}"/>
<script type="text/javascript">
(function($){
$(document).ready(function() {
$.cometd.addListener("/meta/*",
@keirbowden
keirbowden / NotHotDog.cmp
Created July 21, 2017 11:42
Not Hotdog Lightning Component
<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,force:hasRecordId" access="global" controller="EinsteinVision_Admin">
<aura:attribute name="initialised" type="boolean" default="false" />
<aura:attribute name="files" type="Object[]"/>
<aura:attribute name="spinnerWaiting" type="Boolean" default="false"/>
<aura:attribute name="image" type="String" />
<aura:attribute name="imagedata" type="String" />
<aura:attribute name="result" type="String" default="Need a picture"/>
<aura:attribute name="showResult" type="Boolean" default="false" />
<div class="slds-page-header">
@keirbowden
keirbowden / CheckAttachmentSize.page
Created September 5, 2014 16:41
Visualforce page that checks the size of a file selected for upload
<apex:page standardController="Account" extensions="AddAttachmentExt">
<apex:includeScript value="https://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.9.1.min.js"/>
<apex:form>
<apex:sectionHeader title="{!Account.name} Attachments" />
<apex:pageBlock mode="maindetail">
<apex:pageBlockSection title="Existing Attachments" columns="1">
<apex:PageBlockTable value="{!Account.Attachments}" var="attach">
<apex:column value="{!attach.Name}" />
<apex:column headerValue="Length (bytes)" value="{!attach.BodyLength}" />
<apex:column headerValue="Owner" value="{!attach.Owner.Name}" />
@keirbowden
keirbowden / AddAttachmentExt.cls
Created September 5, 2014 16:43
Extension controller to save an attachment associated with a record encapsulated in the standard controller
public with sharing class AddAttachmentExt
{
private ApexPages.StandardController stdCtrl;
public Attachment att {get; set;}
public AddAttachmentExt(ApexPages.StandardController inStd)
{
stdCtrl=inStd;
att=new Attachment();
}
@keirbowden
keirbowden / UserFreezer.cmp
Last active January 31, 2016 08:28
Lightning Component for the User Freezer Blog Post
<aura:component controller="UserFreezer">
<aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
<aura:attribute name="UserDetails" type="Object" />
<aura:attribute name="Message" type="String" />
<table>
<tr>
<th>First Name</th>
<th>Last Name</th>
<th>Username</th>