Skip to content

Instantly share code, notes, and snippets.

View alwaisy's full-sized avatar

Awais alwaisy alwaisy

View GitHub Profile
@alwaisy
alwaisy / key-to-specified-case.ts
Created June 23, 2024 14:28
Converts a 2D array of data to an array of objects.
/**
* Converts a key to a specified case.
* @param key - The original key.
* @param keyCase - The case to convert the key to. Can be "camel", "snake", or a custom function.
* @param renameFields - An object that maps original keys to new keys.
* @returns The converted key.
*/
function getKey(
key: string,
keyCase: "camel" | "snake" | ((key: string) => string),
@alwaisy
alwaisy / page.tsx
Last active June 20, 2024 06:12
Requesting to review my code `pagination bug` to Dev friend.
import { DocList } from "@/@application";
import { getDocuments } from "@/app/actions";
import { IdeasContainer } from "@/app/containers";
import { AppLoadmore } from "@/components";
import { env } from "@/config";
import { Container } from "@mantine/core";
import { Query } from "appwrite";
interface Props {
searchParams: {
@alwaisy
alwaisy / case-insensitive-search.js
Created June 11, 2024 03:13
Combining Js string & array methods to develop search program
/**
* Performs a case-insensitive search through an array of strings.
*
* @param {string[]} products - The array of strings to search through.
* @param {string} searchTerm - The term to search for (case-insensitive).
* @returns {string[]} An array containing the matching strings from the input array.
*/
function caseInsensitiveSearch(products, searchTerm) {
// Convert everything to lowercase for case-insensitive comparison
const lowercaseProducts = products.map(product => product.toLowerCase());
@alwaisy
alwaisy / check-url-validity.ts
Last active May 28, 2024 07:53
Two ways to check URL validity. New || Old
/*
author: @alwaisy -> github
reference: https://rahuulmiishra.medium.com/url-canparse-a-game-changer-in-web-development-8b0572f1354c
*/
/* ======================== old way =================================== */
// Js version
/**

The issue here lies in the usage of event.preventDefault(). It should be placed at the beginning of the event handler and not within the submitHandler. The submitHandler is a method provided by the jQuery Validate plugin, not by jQuery's event system. In this case, you do not actually have direct access to the event object for the submit event, so calling event.preventDefault() will not work.

Here's how you can modify your code to correctly use event.preventDefault():

$(".commentForm").on('submit', function(event) {
    event.preventDefault();
    var form = $(this);
    if (!form.valid()) return; // You should add validation here

Some of my projects

GitHub -> https://gist.github.com/awaisalwaisy

1. ProxyScrape - Loopbrackets

(Business logic is implemented in standard way)

Skills: Vuex · TypeScript · Vue.js Responsibilities: There was a website stacked with traditional technologies like jQuery and PHP. My responsibility was to convert it into a

@alwaisy
alwaisy / article-topics.md
Created February 23, 2023 13:49
article-topics

Hi, this gist will be updated soon.

@alwaisy
alwaisy / awaisalwaisy-vue-projects.md
Last active July 10, 2023 09:57
Projects I have made in VueJs

Here is the list of my work in VueJs

Proxyscrape (client)

Main project I did in the last company. Requirements were to convert traditional php + jquery webiste to vuejs. I used

  1. Typescript
  2. Vue 3
  3. Vuex later pinia
  4. Webpack 4 later Vite
  5. SPA later ssr/nuxt
import React, { FormEvent } from "react";
import { SectionTitle } from "@shared";
import { Text } from "@atoms";
import { FormText } from "@cells";
import { Label } from "@molecules";
import styles from "./Contact.module.css";
import { FieldHint, FieldLabel, FormSubmit, FormTerms } from "./FormComponents";
import { radioFields, textFields } from "@/data";
import { useState } from "react";
@alwaisy
alwaisy / _spacing-helpers.scss
Created December 28, 2022 09:19 — forked from jacurtis/_spacing-helpers.scss
SASS Margin and Padding Helpers Loop. Generates .m-t-10 type helper classes.
/*
This .scss loop will create "margin helpers" and "padding helpers" for use in your web projects.
It will generate several classes such as:
.m-r-10 which gives margin-right 10 pixels.
.m-r-15 gives MARGIN to the RIGHT 15 pixels.
.m-t-15 gives MARGIN to the TOP 15 pixels and so on.
.p-b-5 gives PADDING to the BOTTOM of 5 pixels
.p-l-40 gives PADDING to the LEFT of 40 pixels