Skip to content

Instantly share code, notes, and snippets.

View mohxmd's full-sized avatar
:electron:
Never give up

Mohammed mohxmd

:electron:
Never give up
View GitHub Profile
@mohxmd
mohxmd / apollo-provider.tsx
Created October 28, 2025 20:19
React native appolo provider
import { ApolloClient, InMemoryCache } from "@apollo/client";
import { SetContextLink } from "@apollo/client/link/context";
import { HttpLink } from "@apollo/client/link/http";
import { ApolloProvider as BaseApolloProvider } from "@apollo/client/react";
import { useMemo } from "react";
const IDN_BASE_URL = process.env.EXPO_PUBLIC_IDN_BASE_URL;
if (!IDN_BASE_URL) throw new Error("Missing IDN_BASE_URL in env");
const httpLink = new HttpLink({
@mohxmd
mohxmd / serach-filter.ts
Created December 15, 2024 08:58
Search filter helper function
function searchResponseByQuery(response: RFQResponse, query: string): boolean {
if (!query) return true;
const searchTermLower = query.toLowerCase().trim();
if (searchTermLower.length === 0) return true;
const searchFields = [
response.profileInSupplier.companyName,
response.supplierId,
@mohxmd
mohxmd / README.md
Last active October 15, 2024 16:39
Automate mern deployment

🚀 Automated MERN Stack Deployment Script

This bash script automates the process of deploying a MERN (MongoDB, Express, React, Node.js) stack application on an Ubuntu server. It handles:

  • 🔄 System updates and installation of necessary dependencies: Node.js, Nginx, Certbot, and PM2.
  • 📂 Environment variable management: Prompts for and manages environment variables using a .env file.
  • 📦 App installation and build: Installs the backend and frontend dependencies, then builds the application.
  • 🌐 Nginx setup: Configures Nginx as a reverse proxy for the Node.js app.
  • 🔐 SSL setup: Automatically sets up SSL with Certbot for the provided domain name.
  • 🛡️ Firewall configuration: Sets up the firewall to allow secure web traffic.
@mohxmd
mohxmd / doted.html
Last active August 30, 2024 05:17
Doted bg tailwind css
{/* doted bg */}
<div
className="absolute top-0 z-[-2] h-screen w-screen dark:bg-[#000000] dark:bg-[radial-gradient(#ffffff33_1px,#00091d_1px)]
dark:bg-[size:20px_20px] bg-[#ffffff] bg-[radial-gradient(#00000033_1px,#ffffff_1px)] bg-[size:20px_20px]"
aria-hidden="true"
/>
@mohxmd
mohxmd / auth.ts
Last active July 23, 2024 01:58
Astro actions firebase auth
//actions/auth.ts
import { defineAction, z } from "astro:actions"
import {
createUserWithEmailAndPassword,
signInWithEmailAndPassword,
updateProfile,
} from "firebase/auth"
import { auth } from "@firebase/config"
@mohxmd
mohxmd / ArtPlum.astro
Created July 19, 2024 06:58
Javascript Plum tree art
<!-- Plum tree art -->
<div class="canvas-container">
<canvas id="canvas" width="400" height="400"></canvas>
</div>
<style>
.canvas-container {
position: fixed;
top: 0;
@mohxmd
mohxmd / Loader.jsx
Last active November 15, 2023 16:27
A basic loader raect svg component (styled using tailwind css)
const Loader = () => {
return (
<div className="w-12 mx-auto my-8">
<svg
aria-hidden="true"
className="w-12 h-12 mr-2 text-white animate-spin fill-dark-grey"
viewBox="0 0 100 101"
fill="none"
>
<path
@mohxmd
mohxmd / useForm.js
Created November 5, 2023 09:54
coustom hook for handling form
import { useState } from "react"
export const useForm = (initialValue) => {
const [value, setValue] = useState(initialValue)
return [
value,
(event) => {
setValue({
...value,
@mohxmd
mohxmd / regex.js
Last active November 2, 2023 20:03
regex for email and password
const emailRegex = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/; // regex for email
const passwordRegex = /^(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{6,20}$/; // regex for password
@mohxmd
mohxmd / slugify.js
Created July 17, 2023 17:44
text into slug
export const slugify = (text) => {
return text
.toString()
.toLowerCase()
.replace(/\s+/g, "-")
.replace(/[^\w-]+/g, "")
.replace(/--+/g, "-")
.replace(/^-+/, "")
.replace(/-+$/, "");
}