Skip to content

Instantly share code, notes, and snippets.

View mhraihan's full-sized avatar
💭
I may be slow to respond.

Mahmudul Haque Raihan mhraihan

💭
I may be slow to respond.
View GitHub Profile
@mhraihan
mhraihan / rhf-form-with-zod.jsx
Created November 18, 2024 05:12 — forked from KolbySisk/rhf-form-with-zod.jsx
React Hook Form with Zod Example
import { useForm } from "react-hook-form";
import { zodResolver } from "@hookform/resolvers/zod";
import * as z from "zod";
const schema = z.object({
email: z.string().email().min(2),
password: z.string().min(6)
});
export default function RhfFormWithZod() {
@mhraihan
mhraihan / date-display.js
Created October 4, 2024 13:45 — forked from raselupm/date-display.js
date-display.js
function formatDateRange(startDate, endDate) {
const start = new Date(startDate);
const end = new Date(endDate);
const optionsSameYear = { year: 'numeric' };
const optionsSameMonth = { month: 'long', day: 'numeric' };
const optionsFull = { month: 'long', day: 'numeric', year: 'numeric' };
// Check if the start and end dates are the same
if (start.getTime() === end.getTime()) {
@mhraihan
mhraihan / useBroadcastChannel.ts
Created February 7, 2024 14:30 — forked from KristofferEriksson/useBroadcastChannel.ts
A React hook that allows you to send and receive messages between browser tabs or windows
import { useCallback, useEffect, useRef, useState } from "react";
interface UseBroadcastChannelOptions {
name: string;
onMessage?: (event: MessageEvent) => void;
onMessageError?: (event: MessageEvent) => void;
}
interface UseBroadcastChannelReturn<D, P> {
isSupported: boolean;
{% comment %}
Do you have customized form fields on the product pages of your Shopify store?
Shopify's order confirmation email does not automatically display the values the customer inputs. Here's how to includes them manually.
1. Go to Settings in the Shopify admin
2. Click Notifications
3. Click the link Order confirmation to open the template editor
4. Now copy and paste this code in the template right in the section where the order's line items are rendered.
Look for a line that contains {{line.variant.title}}. You'll want to experiment with the code location.
### This gist is a part of the NestJS Zero to Hero course on Udemy.
### https://www.udemy.com/course/nestjs-zero-to-hero/?referralCode=F672C0C701844DC91F4D
To run PostgreSQL on Docker, run the following in your Terminal:
docker run --name postgres-nest -p 5432:5432 -e POSTGRES_PASSWORD=postgres -d postgres
@mhraihan
mhraihan / shopify-query-string
Created March 1, 2023 04:56 — forked from enamhasan/shopify-query-string
Get the querystring values with liquid in shopify
{%- capture contentForQuerystring -%}{{ content_for_header }}{%- endcapture -%}
{% comment %} Use string splitting to pull the value from content_for_header and apply some string clean up {% endcomment %}
{%- assign pageUrl = contentForQuerystring | split:'"pageurl":"' | last | split:'"' | first | split:'.myshopify.com' | last |
replace:'\/','/' |
replace:'%20',' ' |
replace:'\u0026','&'
-%}
{%- assign pageQuerystring = pageUrl | split:'?' | last -%}
@mhraihan
mhraihan / search-form.js
Created January 31, 2023 11:16 — forked from awojtczyk/search-form.js
Shopify ajax search
$(function() {
var currentAjaxRequest = null;
var searchForms = $('form[action="/search"]').css('position', 'relative').each(function() {
var input = $(this).find('input[name="q"]');
input.attr('autocomplete', 'off').bind('keyup change', function() {
var term = $(this).val();
var form = $(this).closest('form');
var searchURL = '/search?type=product&q=*' + term + '*';
var resultsList = $('.search-results');
resultsList.perfectScrollbar({
@mhraihan
mhraihan / HandleInertiaRequests.php
Created December 4, 2022 05:33 — forked from Biegalski-LLC/HandleInertiaRequests.php
Add Permission & Roles In Laravel Jetstream Inertia
<?php
namespace App\Http\Middleware;
use Illuminate\Http\Request;
use Inertia\Middleware;
use Tightenco\Ziggy\Ziggy;
class HandleInertiaRequests extends Middleware
{
@mhraihan
mhraihan / shopify-money.js
Created November 26, 2022 02:14 — 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);
@mhraihan
mhraihan / modal-video.vue
Created November 24, 2022 14:19 — forked from daltonrooney/modal-video.vue
Modal video player component for Vue.js
/* Based on https://github.com/appleple/react-modal-video/ */
<template>
<div v-if="isOpen">
<div
:class="classNames.modalVideo"
tabIndex='-1'
role='dialog'
:aria-label="aria.openMessage"
@click="$emit('update:isOpen', false)"