Skip to content

Instantly share code, notes, and snippets.

View espl-saket's full-sized avatar

Saket Joshi espl-saket

  • Pune, India
View GitHub Profile
@espl-saket
espl-saket / ExtractFromString.js
Created January 5, 2016 06:50
Regex to extract string and number from a combination of both
var stringPattern = /[A-Za-z]+/g;
var numberPattern = /\d+/g;
'This10Is200'.match(stringPattern);
// Returns ["This", "Is"]
'This10Is200'.match(numberPattern);
// Returns ["10", "200"]
@espl-saket
espl-saket / SheetJs.html
Created January 3, 2016 07:08
Implementation of the SheetJs library to parse Excel workbooks
<html>
<head>
<title>SheetJs implementation</title>
</head>
<body>
<input type="file" id="inputFile" />
<script src="http://oss.sheetjs.com/js-xlsx/jszip.js"></script>
<script src="http://oss.sheetjs.com/js-xlsx/ods.js"></script>
@espl-saket
espl-saket / MetadataCreation.txt
Last active January 3, 2016 06:31
Sample request information to create metadata using SFDC REST APIs
Headers - Authorization: OAuth <YOUR_SESSION_ID>
Content-Type: text/xml
SOAPAction: createMetadata
URL - /services/Soap/m/35.0
Body -
<?xml version="1.0" encoding="UTF-8"?>
<env:Envelope
xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"
1. Class selector - .<classname>
2. Id selector - #<id>
3. Scope selector - .<classname><space>.<dusra_classname>
4. Immediate child selector - .<classname>">".<child_classname>
5. Attribute selector - [<attributename>='<value>'] OR [<attributename>]
6. Tag selector - "<tagname>"
7. DOM element - Directly pass the element to jquery function
8. Multiple element - separate selectors using <comma>
@espl-saket
espl-saket / getUrlParams.js
Created December 20, 2015 13:42
Method to get the URL params using jQuery
var urlParamMap = {};
(function () {
var urlParams = window.location.href.split("?");
if (urlParams.length > 1) {
var paramArray = urlParams[1].split("?");
for (var i = 0; i < paramArray.length; i++) {
var paramKeyValue = paramArray[i].split("=");
urlParamMap[paramKeyValue[0]] = paramKeyValue[1];
}
}
@espl-saket
espl-saket / selectAll_sfdc.js
Last active November 25, 2016 06:48
JS to select all checkboxes in Salesforce on the profile level FLS page
var jq = document.createElement('script');
jq.src = "https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js";
document.getElementsByTagName('head')[0].appendChild(jq);
setTimeout(function(){
var jQ = jQuery.noConflict();
jQ('input[type="checkbox"][title="Read Access"]').each(function(index,cb){jQ(cb).prop( "checked", true );});
jQ('[type="submit"][title="Save"]').click();
},3000);