Skip to content

Instantly share code, notes, and snippets.

View kartick14's full-sized avatar
🎯
Focusing

Kartick Karmakar kartick14

🎯
Focusing
  • kolkata, India
View GitHub Profile
@kartick14
kartick14 / functions.js
Created February 21, 2019 12:32
Create global function in jquery
window.myModule = window.myModule || {};
myModule.upsellReload = (function() { //global function call from anywhere
console.log('Upsell added!');
location.reload();
});
myModule.upsellReload(); //Call function from anywhere
@kartick14
kartick14 / force-download.html
Created March 7, 2019 11:33
Javascript force file download
<button class="js-download-link button" onclick="downloadFile('https://wattswork.s3.amazonaws.com/test-media/video/test_Drop-1280x720-16-9-HD.mp4','dwn.mp4'); return false;">Download MP4 File</button>
<button class="js-download-link button" onclick="downloadFile('https://wattswork.s3.amazonaws.com/test-media/PDFs/test-file.pdf','tfile.pdf'); return false;">Download PDF File</button>
<button class="js-download-link button" onclick="downloadFile('https://wattswork.s3.amazonaws.com/test-media/Text/test-file.txt','file.txt'); return false;">Download TXT File</button>
<script type="text/javascript">
function downloadFile(data, fileName, type="text/plain") {
// Create an invisible A element
const a = document.createElement("a");
@kartick14
kartick14 / bigdump.php
Created April 29, 2019 10:04
import db into phpmyadmin (import large size db into localhost or server)
<?php
error_reporting(E_ALL);
// BigDump ver. 0.36b from 2015-04-30
// Staggered import of an large MySQL Dump (like phpMyAdmin 2.x Dump)
// Even through the webservers with hard runtime limit and those in safe mode
// Works fine with latest Chrome, Internet Explorer and Firefox
// Author: Alexey Ozerov (alexey at ozerov dot de)
@kartick14
kartick14 / insertpost.php
Created October 10, 2019 08:28
Create a new post with custom post id and custom post name
$post = array(
'import_id' => 9999,
'comment_status' => 'open',
'post_content' => 'hi world!',
'post_name' => 'title_1',
'post_status' => 'publish',
'post_title' => 'your title',
'post_type' => 'post',
);
@kartick14
kartick14 / jquery-function.html
Created November 11, 2019 06:52
Display dynamic time using jquery
Use momentjs for display dynamic time.
https://momentjs.com/docs/
@kartick14
kartick14 / index.html
Created March 12, 2020 15:36
Smooth Page Scrolling in jQuery
<div id="page-wrap">
<h1 id="top">Smooth Page Scrolling</h1>
<ul>
<li><a href="#two">Scroll to Section Two</a></li>
<li><a href="#three">Scroll to Section Three</a></li>
</ul>
<h2 id="one">Section One</h2>
@kartick14
kartick14 / wp-config.php
Created April 24, 2020 11:12 — forked from MikeNGarrett/wp-config.php
All those damned wp-config constants you can never remember.
<?php
// PHP memory limit for this site
define( 'WP_MEMORY_LIMIT', '128M' );
define( 'WP_MAX_MEMORY_LIMIT', '256M' ); // Increase admin-side memory limit.
// Database
define( 'WP_ALLOW_REPAIR', true ); // Allow WordPress to automatically repair your database.
define( 'DO_NOT_UPGRADE_GLOBAL_TABLES', true ); // Don't make database upgrades on global tables (like users)
// Explicitely setting url
@kartick14
kartick14 / index.html
Created May 12, 2020 11:15
View instagram post
<div id="instagram-feed1" class="instagram_feed"></div>
https://github.com/jsanahuja/jquery.instagramFeed
https://www.sowecms.com/demos/InstagramFeed/
<script >
(function($){
$(window).on('load', function(){
$.instagramFeed({
'username': '{{ section.settings.instagram_id | escape }}',
'container': "#instagram-feed1",
'display_profile': false,
@kartick14
kartick14 / header.liquid
Created November 18, 2020 07:10
add currency switcher in shopify theme
{% form 'currency' %}
<select name="currency">
{% for currency in shop.enabled_currencies %}
{% if currency == cart.currency %}
<option selected="true">{{currency.iso_code}} {{currency.symbol}}</option>
{% else %}
<option>{{currency.iso_code}}</option>
{% endif %}
{% endfor %}
</select>
@kartick14
kartick14 / function.js
Created April 15, 2021 11:28
Jquery get current url and add/push parameter
function dropdownChange(){
var byDate = document.getElementById('filter-by-date').value;
var myUrl = addQSParm('cat_type',cat_type);
var myUrl = addQSParm('keyword',sKeyword, myUrl);
window.location.href = myUrl;
}
/**************************************************
@ Constructing a URL with parameters using jQuery