Skip to content

Instantly share code, notes, and snippets.

View brianbier's full-sized avatar
:octocat:

Brian Bier brianbier

:octocat:
View GitHub Profile
@brianbier
brianbier / sfdx-throttle-platformevents.apex
Created November 4, 2021 18:04 — forked from c4tch/sfdx-throttle-platformevents.apex
Throttle Apex Platform Events to avoid overloading trigger DML
/**
* Entrypoint from the Trigger, dispatch the events here
* Bobby White
* The use case is universal... you're never going to be able to consume 2000 PE in a single Apex transaction if the PE are independent.
* You have to "clip" the executions into manageable chunks.
* Best case N = 200, in practice if the DML's will touch objects that are poorly governed, it could hit limits at a lower number like 25 or 50.
* Q: What is "Independent"?
* A: Let's say that you had a flood of PE's that had the applied to the same ExternalId, you might be able to consume these with a single DML (e.g. 10 meter readings for the same Meter, or a series of notifications for the same Client) -- if your use case doesn't demand that you preserve every state change, you could collapse them into one. My default assumption is that you need to design your PE trigger with the premise that the PE's stand alone and have no correlation to other PE's in the same invocation.
* I get you, so in the PE loop you have here you might collapse sim
@brianbier
brianbier / getidofRecords.txt
Created February 14, 2020 19:31
New way of creating a map from recently inserted records
//After Inserting opportunities
List<Opportunity> opptys = new List<Opportunity>();
insert opptys;
// Get the IDs of the opportunities we just inserted
Map<Id, Opportunity> opptyMap = new Map<Id, Opportunity>(opptys);
//This will create a map of the opportunities
// Will allow you to do this
List<Id> opptyIds = new List<Id>(opptyMap.keySet());
@brianbier
brianbier / eventCreation.txt
Created November 19, 2019 20:41
All possible Options for creating an event, Since It doesn't work for regular lightning components
window.open('/lightning/o/Event/new');
var urlEvent = $A.get("e.force:navigateToURL");
urlEvent.setParams({
"url": "/lightning/o/Event/new"
});
urlEvent.fire();
var createRecordEvent = $A.get("e.force:createRecord");
createRecordEvent.setParams({
@brianbier
brianbier / salesforce.js
Created July 14, 2019 17:41 — forked from cweems/salesforce.js
Salesforce Message Push
exports.handler = function(context, event, callback) {
//================================================================================
// Modules
//================================================================================
var querystring = require('querystring');
var request = require('request');
//================================================================================
@brianbier
brianbier / vim-heroku.sh
Created November 25, 2018 03:01 — forked from dvdbng/vim-heroku.sh
Run vim in heroku updated 2017
mkdir ~/vim
cd ~/vim
# Staically linked vim version compiled from https://github.com/ericpruitt/static-vim
# Compiled on Jul 20 2017
curl 'https://s3.amazonaws.com/bengoa/vim-static.tar.gz' | tar -xz
export VIMRUNTIME="$HOME/vim/runtime"
export PATH="$HOME/vim:$PATH"
cd -
@brianbier
brianbier / Lookup.cmp.html
Created June 22, 2018 17:09 — forked from JitendraZaa/Lookup.cmp.html
Salesforce Lightning Lookup component - Pure SLDS and Javascript based
<aura:component controller="Lookup">
<aura:attribute Name="selItem" type="object" access="public"
description="This attribute can be used by parent component to read selected record"/>
<aura:attribute Name="server_result" type="object[]" access="private" />
<aura:attribute name="lookupIcon" type="String" access="public" default="standard:contact"/>
<aura:attribute name="objectName" type="String" access="public"
description="Name of Object to be searched"/>
<aura:attribute name="field_API_text" type="String" access="public"
@brianbier
brianbier / progressRing.cmp
Created June 13, 2018 16:45 — forked from brianmfear/progressRing.cmp
LightningProgressRing component
<aura:component >
<aura:attribute name="value" type="Integer" default="0" />
<aura:attribute name="variant" type="String" />
<aura:attribute name="hasVariant" type="Boolean" access="private" default="{!false}" />
<aura:attribute name="ringClass" type="String" access="private" />
<aura:attribute name="iconName" type="String" access="private" />
<aura:attribute name="altText" type="String" access="private" />
<aura:handler name="init" value="{!this}" action="{!c.updateView}" />
@brianbier
brianbier / progressRing.cmp
Created June 13, 2018 16:45 — forked from brianmfear/progressRing.cmp
LightningProgressRing component
<aura:component >
<aura:attribute name="value" type="Integer" default="0" />
<aura:attribute name="variant" type="String" />
<aura:attribute name="hasVariant" type="Boolean" access="private" default="{!false}" />
<aura:attribute name="ringClass" type="String" access="private" />
<aura:attribute name="iconName" type="String" access="private" />
<aura:attribute name="altText" type="String" access="private" />
<aura:handler name="init" value="{!this}" action="{!c.updateView}" />
Just a quick note on the problem a couple of you were having yesterday where a rails generator appeared not to
be creating files. A zombie "spring" process from a different project was still running and so the generator was
actually writing files into a different application.
You can read about what spring does here: https://github.com/rails/spring The short version is that it's an application
preloader that makes running certain tasks faster by keeping parts of your app loaded in memory.
This makes things like running your tests faster as the app doesn't have to load from scratch every time.
If you don't want an app to use it, pass --skip-spring as an option to rails new.
@brianbier
brianbier / gh_script.rb
Created June 12, 2016 14:27 — forked from ltw/gh_script.rb
A script to check GitHub's status.
require 'json'
require 'net/http'
status = nil
until status == 'good'
url = URI('https://status.github.com/api/status.json')
response = Net::HTTP.get(url)
body = JSON.parse(response)
p body
status = body['status']