This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//validation check for sku of a product | |
//alphanumeric | |
var regExp = "/^[^0][A-Za-z0-9_-]{3,50}$/"; | |
// ^ start of string | |
// [^0] 1st char will not be 0 | |
// [A-Za-z0-9_-] A or B ... Z or a or b or ... z or 0 or 1 or ... 9 or underscores(_) or hyphen/dash (-) | |
// {3,50} length between 3-50 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
http://www.webhook.com/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<img ng-if="product.image" ng-src="{{product.image}}" alt="{{product.name}}" onerror="angular.element(this).scope().product.image = false"> | |
<img ng-if="!product.image" ng-src="http://placehold.it/{{vm.image.width}}x{{vm.image.height}}" alt="{{product.name}}"> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function flatten(arr) { | |
return arr.reduce(function (flat, toFlatten) { | |
return flat.concat(Array.isArray(toFlatten) ? flatten(toFlatten) : toFlatten); | |
}, []); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function removeDuplicates(values) { | |
var uniqueValues = {}; | |
values.forEach(function(i) { | |
if (!uniqueValues[i]) { | |
uniqueValues[i] = true; | |
} | |
}); | |
return Object.keys(uniqueValues); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function countVowels(str){ | |
return (str.match(/[aeiou]/gi) == null) ? 0 : str.match(/[aeiou]/gi).length; | |
} | |
// return (str.match(/[aeiou]/gi) || []).length; - shorter version | |
// [aeiou] can be replaced by any other regex as per requirement |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Credits to - https://gist.github.com/ghoseb/25049 | |
#Newbie programmer | |
def factorial(x): | |
if x == 0: | |
return 1 | |
else: | |
return x * factorial(x - 1) | |
print factorial(6) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const videoUrls = ytplayer.config.args.url_encoded_fmt_stream_map | |
.split(',') | |
.map(item => item | |
.split('&') | |
.reduce((prev, curr) => (curr = curr.split('='), | |
Object.assign(prev, {[curr[0]]: decodeURIComponent(curr[1])}) | |
), {}) | |
) | |
.reduce((prev, curr) => Object.assign(prev, { | |
[curr.quality + ':' + curr.type.split(';')[0]]: curr |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Regex - panNum.match('/[A-Za-z]{3}[p,P,c,C,h,H,f,F,a,A,t,T,b,B,l,L,j,J,g,G]{1}[A-Za-z]{1}\d{4}[A-Za-z]{1}/g') | |
PAN structure is as follows: AAAAA9999A: First five characters are letters, next 4 numerals, last character letter. | |
1) The first three letters are sequence of alphabets from AAA to zzz | |
2) The fourth character informs about the type of holder of the Card. Each assesse is unique:` | |
C — Company | |
P — Person | |
H — HUF(Hindu Undivided Family) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div><form id="submitform"><input type="text" id="ship-pincode" required maxlength="6" placeholder="Enter Delivery Pincode" name="delivery_pincode" value=""><input type="submit"></form><p id="edd"><span></span></p></div><script>!function(){var e;if(void 0===window.jQuery||"3.3.1"!==window.jQuery.fn.jquery){var t=document.createElement("script");t.setAttribute("type","text/javascript"),t.setAttribute("src","https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"),t.readyState?t.onreadystatechange=function(){"complete"!=this.readyState&&"loaded"!=this.readyState||a()}:t.onload=a,(document.getElementsByTagName("head")[0]||document.documentElement).appendChild(t)}else e=window.jQuery,i();function a(){e=window.jQuery.noConflict(!0),i()}function i(){e(document).ready(function(e){e("#submitform").on("submit",function(t){t.preventDefault(),t.stopPropagation();var a={pickup_postcode:<PICKUP PINCODE>,delivery_postcode:e("#ship-pincode").val(),weight:<WEIGHT OF SHIPMENT IN KGS>,cod:<COD STATUS>};e.ajax({type: |
OlderNewer