Skip to content

Instantly share code, notes, and snippets.

@swapnilshrikhande
swapnilshrikhande / trim.java
Created February 21, 2024 07:57
Trim Non Space Characters In java
// Trim all whitespace characters
// It is a Unicode space character (SPACE_SEPARATOR, LINE_SEPARATOR, or PARAGRAPH_SEPARATOR) but is not also a non-breaking space ('\u00A0', '\u2007', '\u202F').
// Reference : https://docs.oracle.com/javase/8/docs/api/java/lang/Character.html#isWhitespace-char-
public static String trim(String value){
// first replace characters which are ignored by java to space.
char spaceChar = ' ';
return value == null ? null
: value.replace('\u00A0',spaceChar)
.replace('\u2007',spaceChar)
.replace('\u202F',spaceChar)
@swapnilshrikhande
swapnilshrikhande / getStringBetween.js
Created May 6, 2022 11:05
JavaScript Get String Between Two Strings
function getStringBetween(str, start,end){
return str.substring(
str.indexOf(start) + start.length,
str.lastIndexOf(end)
);
}
@swapnilshrikhande
swapnilshrikhande / nested_sort.js
Created March 10, 2022 02:47
JavaScript Nested Sort On Multiple Fields
var providers = [
{
"provider" : {"name" : "Zaa"},
"licenseStates" : ["TX"]
},
{
"provider" : {"name" : "Aaa"},
"licenseStates" : ["CA"]
},
{
@swapnilshrikhande
swapnilshrikhande / ApexExtension.cls
Last active December 7, 2021 05:45
HttpConnector
public inherited sharing virtual class ApexExtension {
public static String str(String input){
return input == null ? '' : input;
}
public static String str(Object input){
return str(String.valueOf(input));
}
@swapnilshrikhande
swapnilshrikhande / UnDeleteContacts.cls
Created November 27, 2021 10:31
Undeleting Records In Apex (Salesforce)
List<Contact> contactsToUnDelete = new List<Contact>();
for(Contact c : [Select Id, Name, IsDeleted from Contact LIMIT 50000 ALL ROWS]){
if( c.IsDeleted == true ) {
System.debug('Undeleting Contact ='+c.Name+' : '+c.IsDeleted);
contactsToUnDelete.add(c);
}
}
if( contactsToUnDelete.size() > 0 ){
System.debug('Undeleting In Total '+contactsToUnDelete.size()+' Contacts');
undelete contactsToUnDelete;
@swapnilshrikhande
swapnilshrikhande / README.md
Created September 9, 2021 07:38
Merge Angular Project into Spring Boot project
@swapnilshrikhande
swapnilshrikhande / ParsingEnum.java
Created June 9, 2021 04:34
Parsing String from JSON into an Enum value
import java.beans.IntrospectionException;
import java.beans.PropertyDescriptor;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Type;
class Person {
public Gender gender;
@swapnilshrikhande
swapnilshrikhande / Action.cls
Last active May 13, 2021 11:04
Generic Chainable Batch
interface Action {
String getQuery();
Boolean execute(List<SObject> records);
Object getResult();
void setData(Object value);
Integer getDelay();
String getJobName();
}
This file has been truncated, but you can view the full file.
/*! jQuery v3.5.1 | (c) JS Foundation and other contributors | jquery.org/license */
!function (e, t) {
'use strict';
'object' == typeof module && 'object' == typeof module.exports ? module.exports = e.document ? t(e, !0) : function (e) {
if (!e.document) throw new Error('jQuery requires a window with a document');
return t(e)
}
: t(e)
}('undefined' != typeof window ? window : this, function (C, e) {
'use strict';
public class SurveyData {
public class Survey {
public List<Question> rows;
//index must map with the isApplicable array
public List<String> allProducts;
{
rows = new List<Question>();
allProducts = new List<String>();