Skip to content

Instantly share code, notes, and snippets.

@kamipatel
kamipatel / Data cloud Activation EMR notebook
Created June 16, 2023 17:53
Data cloud Activation EMR notebook
import os
import sys
import pyspark.sql.functions as F
from pyspark.sql import SparkSession
from pyspark.sql.functions import lit,concat,col,concat_ws, explode, split, to_date, current_timestamp
from pyspark.sql.types import StructType,StructField, StringType, IntegerType, LongType, DateType, TimestampType
import boto3
import json
from datetime import datetime
@kamipatel
kamipatel / Pricing service aws call
Last active May 12, 2023 20:35
Pricing service aws call
global class PricingDemoService extends commercestorepricing.PricingService {
global void log(String brief, String detail){
System.debug('In PricingDemoService.PricingService brief=' + brief + ', details,' + detail);
}
global override commercestorepricing.PricingResponse processPrice(
commercestorepricing.PricingRequest request
) {
@kamipatel
kamipatel / pyspark script
Created November 18, 2022 14:56
pyspark script
import os
import sys
import pyspark.sql.functions as F
from pyspark.sql import SparkSession
from pyspark.sql.functions import lit,concat,col,concat_ws, explode, split, to_date, current_timestamp
from pyspark.sql.types import StructType,StructField, StringType, IntegerType, LongType, DateType, TimestampType
import boto3
import json
from datetime import datetime
@kamipatel
kamipatel / delete s3 buckets
Last active September 14, 2022 17:45
delete s3 buckets
import boto3
s3Client = boto3.client('s3')
s3 = boto3.resource('s3')
response = s3Client.list_buckets()
for bucket in response['Buckets']:
try:
@kamipatel
kamipatel / cdp-temp
Created July 17, 2022 23:50
cdp-temp
import boto3
import pandas as pd
import json
from io import StringIO
from botocore.exceptions import ClientError
session = boto3.Session(
aws_access_key_id='',
aws_secret_access_key='')
@kamipatel
kamipatel / README.md
Created July 4, 2022 17:06 — forked from pozil/README.md
Drawing a Sankey Chart with Lightning Web Components and Chartjs

Drawing a Sankey Chart with Chartjs

This Gist explains how to draw a Sankey chart on the Salesforce Platform with Lightning Web Components. We use the Chart.js library and the chartjs-chart-sankey plugin. For the sake of simplicy we start from an existing Salesforce project: LWC Recipes.

  1. Install LWC Recipes and make sure that you can see the Chart.js recipe located in the 3rd Party Libs tab.
  2. Enable Lightning Web Security or you'll get the following error message:

    TypeError: ResizeObserver is not a constructor

  3. Download the latest version of the chartjs-chart-sankey plugin from this CDN link and rename the file to chartJsSankey.js.
@kamipatel
kamipatel / meta.py
Last active May 26, 2022 16:09
meta data scrap
'''
Author: Kam & Stu
Setup: To run this code TBD
'''
import requests
from bs4 import BeautifulSoup
import pandas as pd
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
@kamipatel
kamipatel / do.py
Last active May 24, 2022 21:19
survey compare
'''
Author: Kam & Iyer
Setup: To run this code
0 - Copy previous quater csv as old.csv and current quater csv as new.csv
1 - Install python 3
2 - Run command "pip install pandas"
3 - Run command "python3 do.py"
4 - Results should be in out.csv... (check last what column to see why this row was included)
'''
@kamipatel
kamipatel / ebikesorder-athena-ddl
Last active May 12, 2022 20:47
ebikesorder-athena-ddl
CREATE EXTERNAL TABLE `ebikesorder`(
`id` string,
`orderdatetime` string,
`account` string,
`amount` decimal(10,2),
`model` string,
`quantity` decimal(10,0),
`status` string)
ROW FORMAT DELIMITED
FIELDS TERMINATED BY ','
@kamipatel
kamipatel / byob commands
Last active July 15, 2022 14:21
BYOB commands
//Login to your LMA/PBO org
sfdx force:auth:web:login -a pbo
sfdx force:config:set apiVersion=54.0
//Link your PBO to the S3 bucket
//replacing values of my-pbo-username (PBO org username), my-bucket-name (bucket name from aws) and my-aws-rolename (IAM role ARN from aws)
sfdx force:data:record:create -u my-pbo-username --sobjecttype AppAnalyticsDeliveryConfig --values "DataType=PackageUsageLog BucketName=my-bucket-name AwsIamRoleArn=my-aws-rolename FileNamePrefix='dt=' FileType=parquet FileCompression=gzip"
//Use only if you want to unlink (and relink) the PBO from S3 bucket.
//replacing values of my-pbo-username (PBO org username)