Skip to content

Instantly share code, notes, and snippets.

View raihan004's full-sized avatar
🏠
Working from home

MH Raihan raihan004

🏠
Working from home
View GitHub Profile
@raihan004
raihan004 / jquery.shopify-ajax-cart.js
Created July 17, 2019 03:28 — forked from schmoove/jquery.shopify-ajax-cart.js
A handy jQuery plugin for updating the Shopify Cart via their AJAX API
/*
* Project: Shopify AJAX Cart Plugin
* Description: Provides AJAX cart functionality for interacting with the Shopify AJAX API so you don't need an "Update Cart" button
* Dependency: jQuery 1.6+
* Author: Ryan Marshall ([email protected])
* License: Free
* Usage:
*
* $('#cart-form').shopifyAJAXCart({
* item: '.line-item-container',
@raihan004
raihan004 / shopify-money.js
Created August 27, 2019 17:01 — forked from stewartknapman/shopify-money.js
The Shopify.formatMoney method extracted from option_selection.js for stand-alone purposes.
var Shopify = Shopify || {};
// ---------------------------------------------------------------------------
// Money format handler
// ---------------------------------------------------------------------------
Shopify.money_format = "${{amount}}";
Shopify.formatMoney = function(cents, format) {
if (typeof cents == 'string') { cents = cents.replace('.',''); }
var value = '';
var placeholderRegex = /\{\{\s*(\w+)\s*\}\}/;
var formatString = (format || this.money_format);
@raihan004
raihan004 / image.liquid
Created December 20, 2019 01:46
variant change when image updated
{% for image in product.images %}
<div class="swiper-slide" {% if featured_image == image %}data-featured="true"{% endif %}>
<a data-image-id="{{ image.id }}" class="mpi product-gallery__image product-gallery__image-{{ forloop.index }}" href="{{ image | product_img_url: '2048x' }}" title="{{ image.alt | escape }}" data-full-size-src="{{ image | product_img_url: 'master' }}">
{% include 'responsive-image', image: image %}
</a>
</div>
{% endfor %}
router.get("/", (req, res) => {
const msg = req.flash("success");
console.log("success: "+ msg );
res.render("admin", {
title: "admin pages",
success: msg
});
});
@raihan004
raihan004 / blob-filereader-localStorage.js
Created November 15, 2020 00:00 — forked from robnyman/blob-filereader-localStorage.js
Get file as a blob, read through FileReader and save in localStorage
// Getting a file through XMLHttpRequest as an arraybuffer and creating a Blob
var rhinoStorage = localStorage.getItem("rhino"),
rhino = document.getElementById("rhino");
if (rhinoStorage) {
// Reuse existing Data URL from localStorage
rhino.setAttribute("src", rhinoStorage);
}
else {
// Create XHR and FileReader objects
var xhr = new XMLHttpRequest(),
@raihan004
raihan004 / custom.js
Created November 25, 2020 07:08
search json data via ajax
// method one
fetch(`/search?view=json&q=tee}`)
.then(response => response.json())
.then(data => console.log(data));
// method 2
const search = async e => {
const query ="cuff";
const {results, count} = await getResults(query);
//const html = results.map(generateItemHtml).join('');