Skip to content

Instantly share code, notes, and snippets.

View julio73's full-sized avatar
🚀
in the flow

Julio Maniratunga julio73

🚀
in the flow
View GitHub Profile
/**
* Combines indexed entries in the parallel arrays of a given location object.
* Expects the same number of entries in each array.
*
* @param data Object with parallel values in arrays.
* @param separator String to use as a separator in the raw values.
* @param display_separator String to use as a separator in the display values.
* @param bottom_to_top Boolean to indicate if the values should be hierarchically displayed from bottom to top or top to bottom in the display values.
* @returns Object with raw and display values in parallel arrays.
* // The data is in the form:
/**
* Builds an array of object structure from an object with parallel values.
* Expects the same number of entries in each array.
* Similar to building a pivot table, but with a tree structure.
*
* @param data Object with parallel values in arrays.
* @param separator String to use as a separator in the keys from the data.
* @returns Array of objects with the keys from the data and the values from the data arranged hierarchically.
* @example
* // The data is in the form:
/**
* Turns a tree structure into an array of objects.
* @param tree Object tree with object entries attached by their IDs as keys.
* @returns Array of objects entries with their IDs embedded in their structure
* @example
* // given a tree:
* {
* 'a': {
* label: 'A', id: 'a', children: {
* 'a|b': {
@julio73
julio73 / Salesforce_Flow_BestPractices.md
Created August 5, 2020 14:12
10 Best practices for designing flows in Salesforce

10 Best practices for designing flows in Salesforce

  1. Write each step of the flow in pseudocode before attempting to implement the flow itself. It's easier to change things at this stage and breakdown the flow into chunks and possible subflows.

  2. Identify fixed (or hardcoded) values and turn them into inputs for a process builder (if run-as a background process) or into inputs passed by apex class (if run-as a user facing flow). This makes the testing process easier since you can pass your own test accounts IDs and other random values for debugging.

  3. Validate user inputs before passing them to the flow but also confirm all required inputs available before launching the flow. This is an early detection process for misconfigured flows or missing objects.

  4. Put all DML fetch actions to retrieve necessary objects at the beginning of the flow. This helps validate that the flow will be able to proceed smoothly.

@julio73
julio73 / Readme.md
Last active March 9, 2020 17:54
A case for a faster debugging workflow in VS Code for SFDX projects

A solution for a faster debugging workflow in VS Code for SFDX projects

My problem:

In most cases, I launch an Apex Replay Debugger session to review the last generated log file on my Salesforce sandboxes. However, retrieving the latest log from Salesforce to VS Code for debugging requires:

  • Triggering the command to retrieve the debug logs (SFDX: Get Apex Debug Logs...)
  • Waiting and watching out for a popup that lists all the recent debug logs
  • Selecting the first (or desired) debug log for download, note: the popup might easily dismiss itself if doing anything else at this stage
  • Finally, launching the replay debugger for the downloaded log (SFDX: Launch Apex Replay Debugger with Current File)

The above steps take too much of my attention and are not fun to keep track on a spotty internet connection.

@julio73
julio73 / SketchSystems.spec
Created August 13, 2018 09:37
My Awesome Sketch
My Awesome Sketch
First State
some event -> Second State
Second State
@julio73
julio73 / SketchSystems.spec
Last active August 13, 2018 09:37
My Sketch
My Sketch
First State
some event -> Second State
Second State
some sketch
### Keybase proof
I hereby claim:
* I am julio73 on github.
* I am julio73 (https://keybase.io/julio73) on keybase.
* I have a public key ASBp0UYq4fSIanLBiy3wTLNiiS5uNr1mNnnKkrjz_XWGmQo
To claim this, I am signing this object:
"""
An Armstrong number is an n-digit number that is equal to the sum of the nth powers of its digits
"""
def isArmstrongNumber(x):
return sum([n**len(str(x)) for n in [int(d) for d in list(str(x))]]) == x
[x for x in range(100000) if isArmstrongNumber(x)]
#=> [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 153, 370, 371, 407, 1634, 8208, 9474, 54748, 92727, 93084]
@julio73
julio73 / closest_2d_coords.rb
Created March 6, 2014 23:06
Fun ruby exercise on 2D coords
# Output the closest n points to a random point from a pool of m 2-D coordinates.
# All coordinates are within the domain range 0..d
# m may be be smaller than n
def closest_2d_coords(n = 5, m = 100, d = 100)
rand2d_gen = ->(d) { 2.times.map { (rand*d).round }}
cartesian_distance =
->(c1, c2) { ((c1[0] - c2[0])**2 + (c1[1] - c2[1])**2)**0.5 }
ref_pt = rand2d_gen.call(d)