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
window.logger = function (logLevel, ...args) { | |
// condition: adding to show only logs only when debugging is enabled | |
if(!process.env.PROD) { | |
if(!['error', 'log', 'info', 'warn'].includes(logLevel)) { | |
logLevel = 'error' | |
} | |
console[logLevel](...args) | |
} | |
} |
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
/* Use Any Method */ | |
======================================================== | |
/* | |
With Chrome Extension install need - with extension you don't need to add it everyday | |
https://github.com/codeeshop-oc/custom-html-in-pages | |
*/ | |
<script type="text/javascript" id="newday" async="true"> | |
function removeAdBlockerIssue() { |
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
public function savedAmountInCart() { | |
$this->load->model('catalog/product'); | |
$saved_amt = 0; | |
foreach ($this->cart->getProducts() as $product) { | |
$product_info = $this->model_catalog_product->getProduct($product['product_id']); | |
$actual_price = 0; | |
if ($this->customer->isLogged() || !$this->config->get('config_customer_price')) { | |
$actual_price = $product_info['price']; | |
} |
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
window.animateFrame = function(delay = 0, func = () => {}) { | |
let start = Date.now(), // starting time | |
myReq; | |
if(typeof func != 'function') { | |
throw new Error('Not a function') | |
} | |
function loop() { | |
// check if timer is expired | |
if (Date.now() - start < delay) { |
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
/* | |
In case you want solution using NPM Package | |
### https://www.npmjs.com/package/get-script-tag | |
*/ | |
// String to find script tags from | |
let html = `<p>You have the Script Tags <script type=\"text/javascript\" async=\"async\" src=\"//web.webformscr.com/apps/fc3/build/default-handler.js\" sp-form-id=\"YOUR_ID\"></script></p>` | |
// Individual Script Tag with Index | |
String.prototype.getScriptTag = function() { |
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
let func = (e) => { | |
alert('Function Run') | |
} | |
window.addEventListener('click', func, {once: true}); | |
/* | |
More Details: | |
https://www.javascripttutorial.net/dom/events/create-a-one-off-event-handler/ | |
*/ |
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
Include font style on your page. For example, I am adding the Roboto font family. | |
Single | |
<link href="https://fonts.googleapis.com/css?family=Roboto" / rel="stylesheet"> | |
Multiple | |
<link async href="https://fonts.googleapis.com/css?family=Roboto|Nunito:300,400,400i,600,700&display=swap" rel="stylesheet"> | |
$('#summernote').summernote({ | |
fontNames: ['Arial', 'Arial Black', 'Comic Sans MS', 'Courier New', 'Helvetica', 'Impact', 'Tahoma', 'Times New Roman', 'Verdana', 'Roboto'], | |
fontNamesIgnoreCheck: ['Roboto'] |
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
Find Stars | |
https://github.com/search?p=3&q=stars%3A%3E100000&type=Repositories |
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
/* Ellipsis Text and add `anchor tag` to URL */ | |
String.prototype.convertText = function (ellipse = 0, suffix = '...') { | |
if (!this.length) return; | |
let urlRegex = /(((https?:\/\/)|(www\.))[^\s]+)/g; | |
this.replace(urlRegex, function (url) { | |
let hyperlink = url; | |
if (!hyperlink.match('^https?:\/\/')) { | |
hyperlink = 'http://' + hyperlink; | |
} |
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
/* | |
Using https://gist.github.com/paulmillr/4524946#file-github-users-stats-json | |
all -- JSON Data from above Gist to get All Followers | |
Found Least Follow Count | |
*/ | |
let leastFollow = 100000000 | |
all.map(v => { | |
if (v.followers > 0 && v.followers < leastFollow) { | |
leastFollow = v.followers | |
} |