Skip to content

Instantly share code, notes, and snippets.

View dsilvadeepal's full-sized avatar

Deepal DSilva dsilvadeepal

  • Salesforce
  • Atlanta, GA
View GitHub Profile
@dsilvadeepal
dsilvadeepal / index.html
Created September 21, 2016 08:01
Portfolio page
</html>
<head>
<link rel="stylesheet" href="path/to/font-awesome/css/font-awesome.min.css">
<link href="https://fonts.googleapis.com/css?family=Kalam|Merienda:700" rel="stylesheet">
<title>My portfolio</title>
</head>
<body>
<!-- Nav bar section -->
<nav class="navbar navbar-inverse navbar-fixed-top">
<div class="container-fluid">
@dsilvadeepal
dsilvadeepal / MaxCases Apex Trigger
Created December 21, 2017 21:56
A trigger that sets a case status to 'Closed' if there are more than 2 cases created that day associated with the same contact Also close cases if there are more than 3 cases created on that account that day
/*
Write a trigger that sets a case status to 'Closed' if there are more than 2 cases created
that day associated with the same contact
Also close cases if there are more than 3 cases created on that account that day
*/
trigger MaxCases on Case (before insert) {
for(Case myCase : Trigger.new) {
//Find all cases created today
if(myCase.ContactId != null) {
@dsilvadeepal
dsilvadeepal / OwnerManagerTrigger
Created December 22, 2017 16:25
Upon opportunity creation add the opportunity owner's manager as an opportunity team member with role 'Sales Manager' If the opportunity owner is a manager, add one of their direct employees as a 'Sales Rep' opportunity team member
/*
Upon opportunity creation add the opportunity owner's manager as an opportunity team member with role 'Sales Manager'
If the opportunity owner is a manager, add one of their direct employees as a 'Sales Rep' opportunity team member
*/
trigger OwnerManager on Opportunity (after insert) {
for(Opportunity opp : Trigger.new){
//Get opp owner manager info
@dsilvadeepal
dsilvadeepal / CaseContactOwnerTrigger
Created December 22, 2017 16:54
A trigger that sets the contact owner to whomever most recently created a case on the record. Also sets the account owner to whomever most recently created a case on it
/*
Write a trigger that sets the contact owner to whomever most recently created a case on the record
In the same trigger set the account owner to whomever most recently created a case on it
*/
//After trigger to access Case createdById
trigger CaseContactOwner on Case (after insert) {
for(Case myCase : Trigger.new) {
//make sure there's a contact for null pointer exceptions
@dsilvadeepal
dsilvadeepal / UpdateContactPhoneTrigger
Created December 22, 2017 21:13
When an account's phone number is updated, all related contact's 'Other Phone' must be updated. Do not update the contact's phone if the contact's country differs from the account's country
/*
When an account's phone number is updated, all related contact's 'Other Phone' must be updated
Do not update the contact's phone if the contact's country differs from the account's country
*/
trigger UpdateContactPhone on Account (before update) {
for(Account acc : Trigger.new){
//Make sure the phone number is populated
if(acc.Phone != null){
@dsilvadeepal
dsilvadeepal / AccountMatcherHwTrigger
Last active December 23, 2017 16:56
Moves new contacts to the matching account based on domain. Contact email domain should match the website domain.
/*
Move new contacts to the matching account based on domain. Contact email domain should match the website domain.
Ex. john@fastco.com matches only to an account with website www.fastco.com
*/
trigger AccountMatcherHw on Contact (before insert) {
for (Contact con : Trigger.new) {
if(con.Email != null) {
//Create a website from the email domain
@dsilvadeepal
dsilvadeepal / AccountMatcherChallengeTrigger
Created December 23, 2017 17:25
Move new contacts to the matching account based on domain. Contact email domain should match the website domain. Ex. john@fastco.com matches only to an account with website www.fastco.com Should also match with the following websites: http://www.fastco.com https://www.fastco.com fastco.com fastco.com.au fastco.com.ca
/*
Move new contacts to the matching account based on domain. Contact email domain should match the website domain.
Ex. john@fastco.com matches only to an account with website www.fastco.com
Should also match with the following websites: http://www.fastco.com https://www.fastco.com
fastco.com fastco.com.au fastco.com.ca
*/
trigger AccountMatcherChallenge on Contact (before insert, before update) {
for(Contact con : Trigger.New) {
@dsilvadeepal
dsilvadeepal / AddOppInfoToContactsTrigger
Created December 23, 2017 20:00
When a new opportunity is created, all contacts on the corresponding account need to have the following info added to their description: Opp creator's name , Opp close date
/*
When a new opportunity is created, all contacts on the corresponding account need to have
the following info added to their description: Opp creator's name , Opp close date
*/
trigger AddOppInfoToContacts on Opportunity (after insert) {
for(Opportunity opp : Trigger.new) {
if(opp.AccountId != null) {
@dsilvadeepal
dsilvadeepal / Rvest tutorial - Part 2
Last active June 10, 2018 09:00
Extracting Popular Songs and Lyrics of the top 10 Artists
#Format the link to navigate to the artists genius webpage
genius_urls <- paste0("https://genius.com/artists/",top_artists$Artist)
#Initialize a tibble to store the results
artist_lyrics <- tibble()
# Outer loop to get the song links for each artist
for (i in 1:10) {
genius_page <- read_html(genius_urls[i])
song_links <- html_nodes(genius_page, ".mini_card_grid-song a") %>%
@dsilvadeepal
dsilvadeepal / Rvest tutorial - Part 1
Last active May 4, 2018 03:13
Extracting the Top 10 Pop Artists of All Time
#Identify the url from where you want to extract data
base_url <- "https://www.billboard.com/charts/greatest-of-all-time-pop-songs-artists"
webpage <- read_html(base_url)
# Get the artist name
artist <- html_nodes(webpage, ".chart-row__artist")
artist <- as.character(html_text(artist))
# Get the artist rank
rank <- html_nodes(webpage, ".chart-row__rank")