Skip to content

Instantly share code, notes, and snippets.

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

Sadaf Siddiqui halfbug

🏠
Working from home
View GitHub Profile
@halfbug
halfbug / pagination.input.ts
Last active April 18, 2023 07:16
Define a pagination input type:
@InputType()
export class Pagination {
@Field(() => Int, { defaultValue: 0 })
skip: number;
@Field(() => Int, { defaultValue: 10 })
take: number;
}
@halfbug
halfbug / terminal
Created October 18, 2022 12:01
open vscode as editor in git cmd
git config --global core.editor "code --wait"
@halfbug
halfbug / productGrid.jsx
Created September 29, 2022 12:43
usePagination Custom hook to create pagination in any grid.
....
import usePagination from 'hooks/usePagination';
import Pagination from 'react-bootstrap/Pagination';
....
const ProductGrid = ({
...props
}: ProductGridProps) => {
....
const {
screens, breakPoint, pageSize,
@halfbug
halfbug / gist:53135621f609e87d1be22598c80775a7
Created November 18, 2020 12:32
How to make Sitemap.xml public in React Js
1. Add sitemap.xml to public folder.
2. Import sitemap.xml in main app.js file ( you need to add it inside src folder too )
3. Update Rewrites and redirects with xml
</^[^.]+$|\.(?!(css|json|gif|ico|jpg|js|png|xml|txt|svg|woff|ttf)$)([^.]+$)/>
@halfbug
halfbug / hook
Last active September 29, 2022 12:12
Create a custom hook in react and write its unit test.
import { useSelector, useDispatch } from 'react-redux';
import { isEmpty } from 'lodash';
import lastPropertyIdSelector from 'selectors/lastPropertyId';
import { setLastPropertyId } from 'slices/lastPropertyId';
import propertySelector from 'selectors/properties';
export default function useLastProperty() {
const dispatch = useDispatch();
const { properties } = useSelector(propertySelector);
import { createSlice } from '@reduxjs/toolkit';
export const initialState = {};
const slice = createSlice({
name: 'lastPropertyId',
initialState,
reducers: {
store(state, action) {
const { payload } = action;
@halfbug
halfbug / gist:8f729c5730f08b00f8043b0ff64b4fc7
Created October 25, 2020 07:31
Take check out from remote origin's branch on local
- First fetch remote
git fetch origin
- then take the checkout for the branch
git checkout task2
@halfbug
halfbug / git-revert
Created October 20, 2020 05:09
Git revert a commit
Revert a last git
git revert Head
Revert a git commit with hash
git revert {hash of commit}