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;
@mhraihan
mhraihan / Collection with products.gql
Created December 2, 2023 18:29
This is graphql snippet for the shopify
{
collections(first: 10, sortKey: UPDATED_AT, reverse: true) {
pageInfo {
hasNextPage
}
edges {
node {
id
title
descriptionHtml
{% 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.
@mhraihan
mhraihan / filter.php
Created October 5, 2023 01:52
word filter wordpress plugin
<?php
namespace WordFilter;
/**
* Plugin Name: Word Filter
* Plugin URI: https://wordpress.com/word-filter
* Description: MH Slider is a slider plugin
* Version: 1.0.0
* Requires at least: 5.6
@mhraihan
mhraihan / index.php
Last active September 24, 2023 19:00
Post Statics plugin for wordpress
<?php
/**
* Plugin Name: Our Test plugin
* Plugin URI: https://wordpress.com/mh-slider
* Description: A truly amazing plugin.
* Version: 1.0.0
* Requires at least: 5.6
* Author: MH Raihan
* Author URI: http://mhraihan.com
### 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({