Skip to content

Instantly share code, notes, and snippets.

@doppiomacchiatto
doppiomacchiatto / README.md
Created January 13, 2020 17:29
Salesforce DX steps, tips, and tricks

Initial Set-Up

Authenticate with Dev Hub (one time)

The Dev Hub is our production org. Scratch orgs are registered against a Dev Hub and can be managed from there. Execute the following command in a terminal (you'll be prompted to enter your username and password in a browser window):

  • sfdx force:auth:web:login --setdefaultdevhubusername -a Unum_DevHub

Set Your Default Dev Hub Username

It's possible to have multiple Dev Hub orgs. If you want to change to a different Dev Hub, you must specify your defaultdevhubusername setting with this command:

// XPath CheatSheet
// To test XPath in your Chrome Debugger: $x('/html/body')
// http://www.jittuu.com/2012/2/14/Testing-XPath-In-Chrome/
// 0. XPath Examples.
// More: http://xpath.alephzarro.com/content/cheatsheet.html
'//hr[@class="edge" and position()=1]' // every first hr of 'edge' class
@doppiomacchiatto
doppiomacchiatto / spark-duplicates.scala
Created August 19, 2019 16:47
Find duplicates in a Spark DataFrame
val transactions = spark.read
.option("header", "true")
.option("inferSchema", "true")
.json("s3n://bucket-name/transaction.json")
transactions.groupBy("id", "organization").count.sort($"count".desc).show
@doppiomacchiatto
doppiomacchiatto / .gitlab-ci.yml
Created June 20, 2019 19:38 — forked from daicham/.gitlab-ci.yml
A sample of .gitlab-ci.yml for a gradle project
image: java:8-jdk
stages:
- build
- test
- deploy
before_script:
# - echo `pwd` # debug
# - echo "$CI_BUILD_NAME, $CI_BUILD_REF_NAME $CI_BUILD_STAGE" # debug
@doppiomacchiatto
doppiomacchiatto / spark.md
Created May 26, 2019 14:34 — forked from rolandjitsu/spark.md
Apache Spark installation for Mac OS X

Apache Spark

Install steps for Apache Spark on Mac OS X using Homebrew.

Install Java Development Kit


Download and install it from oracle.com, then add following code to your .bash_profile, .zshrc, etc.:

# Apache Spark
if which java > /dev/null; then export JAVA_HOME=$(/usr/libexec/java_home); fi
@doppiomacchiatto
doppiomacchiatto / config.py
Created March 5, 2019 21:00 — forked from bonzanini/config.py
Twitter Stream Downloader
consumer_key = 'your-consumer-key'
consumer_secret = 'your-consumer-secret'
access_token = 'your-access-token'
access_secret = 'your-access-secret'
@doppiomacchiatto
doppiomacchiatto / apex random string
Created November 10, 2018 22:33 — forked from coder36/apex random string
Apex random string generator
trigger ContactGuidGenerator on Contact (before insert) {
for( Contact c: Trigger.new ) {
final String chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz';
String guid = '';
while (guid.length() < 16) {
Integer idx = Math.mod(Math.abs(Crypto.getRandomInteger()), chars.length());
guid += chars.substring(idx, idx+1);
}
c.guid__c = guid;
@doppiomacchiatto
doppiomacchiatto / Address.cls
Created October 15, 2018 23:18 — forked from afawcett/Address.cls
Apex Address compound type, based on that provided in Spring'14 for Salesforce API, http://www.salesforce.com/us/developer/docs/api/Content/compound_fields_address.htm
public class Address
{
// Internally used to determine if valueOf method should read the state and country picker fields
private static Boolean stateAndCountryPickersEnabled = false;
static
{
// Are State and Country pickers enabled in this org?
Map<String, Schema.SObjectField> accountFields = Account.sObjectType.getDescribe().fields.getMap();
stateAndCountryPickersEnabled = accountFields.containsKey('BillingStateCode');
@doppiomacchiatto
doppiomacchiatto / ApexCoding.txt
Created October 10, 2018 20:38 — forked from KorbenC/ApexCoding.txt
Apex Coding Standards
Apex Coding Standard
Introduction
-------------
Apex is a strongly-typed, object-oriented, proprietary programming language for the Force.com platform.
It lets you execute flow and transaction control statements in conjunction with calls to the Force.com API.
Apex borrows it's syntax from Java, and functions like a database stored procedure.
To learn more about Apex, read the developer documentation on the Force.com developer site.
[http://www.salesforce.com/us/developer/docs/apexcode/index.htm]
@doppiomacchiatto
doppiomacchiatto / split_image_4_quarters.py
Created September 25, 2018 19:19 — forked from alexlib/split_image_4_quarters.py
Python code using PIL to split the image into 4 quarters. useful for the four-view image splitter 3D-PTV project on http://www.openptv.net
import Image
import os
import glob
def crop(im,height,width):
# im = Image.open(infile)
imgwidth, imgheight = im.size
for i in range(imgheight//height):
for j in range(imgwidth//width):
# print (i,j)