Skip to content

Instantly share code, notes, and snippets.

View victorabraham's full-sized avatar
💭
...

Victor Abraham victorabraham

💭
...
  • United States
View GitHub Profile
@victorabraham
victorabraham / bootstrapCodespace.sh
Last active November 21, 2023 15:45
Bootstrap Codespace
#!/bin/bash
cd ~/.ssh
echo "Please provide email for Github SSH. Use keyname /home/codespace/.ssh/github"
read email
ssh-keygen -t ed25519 -C $email
echo "Add/Update key got Github"
cat /home/codespace/.ssh/github.pub
eval "$(ssh-agent -s)"
ssh-add /home/codespace/.ssh/github
npm i -g sfdx-cli
@victorabraham
victorabraham / Bashaliases.sh
Last active June 14, 2023 18:46
Bash Aliases
alias ll='ls -lahG'
alias home='cd ~'
alias ni="npm install"
alias nid="npm install --save-dev"
alias nis="npm install --save"
alias nit="npm init"
alias glog="git log --oneline --decorate --graph"
alias gsl="git diff --cached --name-only"
alias gad="git diff"
@victorabraham
victorabraham / JsClassInerhitance.js
Created October 18, 2022 22:53
Inheritance in JavaScript
class Animal {
constructor(name, age) {
this.name = name;
this.age = age;
}
eats() {
console.log(this.name + ' eats');
}
}
public with sharing class Utils {
//If parser is at start of inner object or array, skipping till end of the section
public static JSONParser skipTillEndOfSection(JSONParser parser) {
if(parser != null && parser.getCurrentToken() == JSONToken.START_ARRAY) {
if(parser.getCurrentToken() == JSONToken.START_ARRAY) {
while(parser.getCurrentToken() != JSONToken.END_ARRAY) {
parser.nextToken();
if(parser.getCurrentToken() == JSONToken.START_ARRAY || parser.getCurrentToken() == JSONToken.START_OBJECT) {
skipTillEndOfSection(parser);
public with sharing class PackageUtils {
private static Set<String> AccountFields = null;
//Method to check if person account is enabled
public static Boolean isPersonAccountEnabled() {
if (AccountFields == null) {
AccountFields = Schema.SObjectType.Account.fields.getMap().keyset();
}
return AccountFields.contains('ispesonaccount');
}
List<AsyncApexJob> trackerJobs = [SELECT Id, Status, ApexClassID FROM AsyncApexJob WHERE Status IN ('Holding', 'Queued','Processing','Preparing')
AND ApexClassID IN (SELECT Id FROM ApexClass WHERE Name = 'TrackerSchedulable')];
if(!trackerJobs.isEmpty()) {
//Apex jobs are running for specified class
}
for(CronTrigger cTrigger : [SELECT Id, CronJobDetail.Name FROM CronTrigger WHERE CronJobDetail.Name like 'TrackerJob%']){
//Try catch to ignore any exceptions to abort jobs
try{
system.abortJob(cTrigger.Id);
}
catch (exception e) {}
}
//This can be any time in future
Datetime nextRun = System.now().addHours(2);
//Generating cron expression for next run time
String year = String.valueOf(nextRun.year());
String day = String.valueOf(nextRun.day());
String hour = String.valueOf(nextRun.hour());
String min = String.valueOf(nextRun.minute());
String sec = String.valueOf(nextRun.second());
String cronExp = sec + ' ' + min + ' ' + hour + ' '+day+' '+nextRun.format('MMM').toUpperCase()+' ? '+year;
<aura:component controller="Util_AutocompleteInputController">
<aura:attribute name="label" type="String"/>
<aura:attribute name="placeholder" type="String" default="Search"/>
<aura:attribute name="iconName" type="String" default="utility:account"/>
<aura:attribute name="objectToSearch" type="String" required="true"/>
<aura:attribute name="fieldToSearch" type="String" default="Name"/>
<aura:attribute name="fieldsToDisplay" type="String[]" default="['Name']"/>
<aura:attribute name="fieldsToReturn" type="String[]" default="['Id']"/>
<aura:attribute name="extraWhereClause" type="String" default=""/>
<aura:application extends="force:slds">
<div>
<c:DisplayBlogs></c:DisplayBlogs>
</div>
</aura:application>