Skip to content

Instantly share code, notes, and snippets.

View codeeshop-oc's full-sized avatar
🎯
Focusing

Anant Negi codeeshop-oc

🎯
Focusing
View GitHub Profile
@codeeshop-oc
codeeshop-oc / control_production_logger.txt
Created June 13, 2022 07:28
controlling logger for production mode
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)
}
}
@codeeshop-oc
codeeshop-oc / reading_forbes_without_removing_adblocker.js
Last active May 9, 2022 13:50
Reading Forbes Without Removing AdBlocker
/* 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() {
@codeeshop-oc
codeeshop-oc / customer_save_amount_cart.php
Last active March 29, 2022 12:13
Opencart - How much amount customer saved in cart
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'];
}
@codeeshop-oc
codeeshop-oc / animation-frame-js.js
Last active March 9, 2022 09:29
Custom Animate Frame with time delay and function
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) {
@codeeshop-oc
codeeshop-oc / get-script-tag.js
Last active March 4, 2022 13:57
Get Script Tag / Attributes Using JavaScript String Prototype
/*
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() {
@codeeshop-oc
codeeshop-oc / one_off_event_handler.js
Created February 9, 2022 12:07
One-Off Event Handler Javascript
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/
*/
@codeeshop-oc
codeeshop-oc / summernote.txt
Created February 7, 2022 13:57
Add custom font in Summernote
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']
@codeeshop-oc
codeeshop-oc / git-queries.txt
Created February 7, 2022 09:50
Git Important Queries
Find Stars
https://github.com/search?p=3&q=stars%3A%3E100000&type=Repositories
@codeeshop-oc
codeeshop-oc / string_prototype_convert_text.js
Last active February 3, 2022 12:01
Ellipsis Text and add `anchor tag` to URL
/* 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;
}
/*
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
}