Skip to content

Instantly share code, notes, and snippets.

@sfdcale
sfdcale / README.md
Created May 22, 2025 04:00
🔍 Find the first merge commit on the mainline that changed a file
git log -1 --merges --ancestry-path <commit-A>..HEAD -- path/to/file

✅ When to use:

Use this to identify the first merge commit on the mainline (first-parent path) from <commit-A> to HEAD that touched a specific file. Especially useful when a line disappears due to merge conflict resolution and isn't visible with -S or -G.


🧩 Flag breakdown:

@sfdcale
sfdcale / listener_visa_slots.py
Created July 21, 2024 18:45 — forked from savithruml/visa_slots.py
Listens for events on the H1b-visa-slots telegram channel & notifies you (audio and/or msg forwarding)
#!/usr/bin/env python3
# Author: SAVITHRU LOKANATH
# Login to Telegram on web browser https://web.telegram.org
# Install tesseract-ocr: apt-get install tesseract-ocr && pip install pytesseract
# Install Telethon lib: pip install telethon
# Install Text-to-Speech lib if using Windows: pip install pyttsx3
# To run, increase speaker volume to 100% & in your cmd prompt: python3 listener_visa_slots.py
@sfdcale
sfdcale / HowToCreatePrincipalsInNamedCredentials.md
Last active June 24, 2024 16:54
How to create External Credentials

Step 1:

Make POST call to endpoint (/services/data/v58.0/named-credentials/external-credentials/) with below JSON body to create external credential.

{
  "authenticationProtocol": "Custom",
  "customHeaders": [],
  "developerName": "Test2",
  "masterLabel": "Test",
@sfdcale
sfdcale / sfCliReleaseInfo.sh
Last active September 20, 2023 20:40
Command to print release info for the given org
# Command to print release info for the given org
sf org display --json --target-org scratch-org | jq -r '[.result.instanceUrl,.result.accessToken] | @tsv' | \
xargs -t sh -c 'curl -i --location $1/services/data --header "Authorization: Bearer $2"' sh
@sfdcale
sfdcale / autoPublishCommunityOnLwcChanges.sh
Created July 21, 2023 19:00
Auto Publish community on LWC changes
#!/bin/bash
# Validates command line arguments to make sure everything looks correct.
validateArguments() {
if [ "$lwcFolderToWatch" = "" ] || [ "$orgUserNameOrAlias" = "" ] || [ "$communityToPublish" = "" ]; then
echo "Error: Incorrect number of arguments. Please provide exactly 3 arguments."
exit 1
fi
}
# command to find files that were modified in last 7 days in downloads folder.
# It shows prompt, asking if we want to delete.
# Useful for cleaning a directory.
find ~/Downloads -mtime -7d -type f -maxdepth 1 -exec rm -i {} \;
@sfdcale
sfdcale / findPlusGrepPlusSed.sh
Created November 10, 2022 05:42
Find + Grep + Sed
# Find for files matching specific pattern
# Check if specific text is there in that file
# Replace that specific text with other text.
find . -type f -not -iregex '.*node_modules.*' -exec grep -EHni 'abc' {} \; -exec sed -i '' -e 's/abc/xyz/g' {} \;
@sfdcale
sfdcale / useful_command.sh
Created May 1, 2022 21:20
Grep command to search for specific text in files recursively
sudo grep --color --ignore-case --extended-regexp --with-filename --regexp 'Mellbourne' --recursive --binary-files=without-match 2>/dev/null
@sfdcale
sfdcale / gist:d4a80cb4f315be1cabb9de827a00122f
Created November 11, 2021 05:47
Sqlite - Syntax for UPDATE FROM
UPDATE
Employee
SET
Id = T2.Id // DO NOT USE Employee.Id HERE. IT FAILS.
FROM
(
SELECT
Department.Id AS Id
FROM
Department
@sfdcale
sfdcale / sfdxcurlshortcut.sh
Last active August 10, 2021 21:53
Shortcut on how to read instance url and access token from SFDX CLI and use that in curl
sfdx force:org:display --targetusername sandbox --json | jq -r '[.result.instanceUrl,.result.accessToken] | @tsv' \
| xargs -t sh -c 'curl -i --location $1/services/data/v50.0/sobjects/ContentVersion \
--header "Authorization: Bearer $2" \
--form entity_content='\''{ "PathOnClient": "Statement.pdf" };type=application/json'\'' \
--form VersionData="@Metecho Training.pdf;type=application/octset-stream;"' sh
# Make sure that there is a file named `@Metecho Training.pdf` in the location where this command is run from.