Skip to content

Instantly share code, notes, and snippets.

View mswat5's full-sized avatar
🎯
Focusing

Swatantra Mishra mswat5

🎯
Focusing
View GitHub Profile
@mswat5
mswat5 / stdc++.h
Created October 1, 2025 17:11
c++ bits/stdc++.h file
// C++ includes used for precompiling -*- C++ -*-
// Copyright (C) 2003-2015 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
@mswat5
mswat5 / disjointSet.cpp
Last active August 5, 2025 07:08
template for disjoint set in c++
class DisjointSet{
public:
vector<int> rank,parent,size;
DisjointSet(int n){
rank.resize(n+1,0);
parent.resize(n+1);
size.resize(n+1);
for(int i=0;i<=n;i++){
parent[i]=i;
size[i]=1;
@mswat5
mswat5 / setup.md
Created July 23, 2025 06:33
nodejs with typescript setup
  • npm init -y
  • npm i express cors dotenv mongodb mongoose
  • npm i ts-node typescript @types/node @types/express @types/cors nodemon --save-dev
  • change the main and scripts in package.json
  • npx tsc --init
  • then tsconfig me u can make changes if needed
@mswat5
mswat5 / expo.tsx
Created May 16, 2025 12:33
expo user flow
import React, { createContext, useContext, useEffect, useState } from 'react';
import { View, Text, Button, StyleSheet, Image } from 'react-native';
import { Stack, Redirect, router } from 'expo-router';
import AsyncStorage from '@react-native-async-storage/async-storage';
import Onboarding from 'react-native-onboarding-swiper';
// Auth Context to manage user session
interface AuthContextType {
session: string | null;
isLoading: boolean;
@mswat5
mswat5 / useMousePosition.tsx
Last active February 19, 2025 11:50
custom hook to track mouse position
export const useMousePosition = (global: boolean = true) => {
const [mouseCoords, setMouseCoords] = useState<{
x: number;
y: number;
}>11
х: 0,
y: 0,
}) ;
const handleMouseMovement = (event:
setMouseCoords ({
@mswat5
mswat5 / Text.tsx
Created February 18, 2025 10:29
custom components in react native and nativewind
import { Text as RNText, TextProps } from "react-native";
type TextElement = "h1" | "h2" | "h3" | "h4" | "p" | "span";
type FontWeight = "regular" | "medium" | "semibold" | "bold";
interface TextProperties extends TextProps {
as?: TextElement;
weight?: FontWeight;
className?: string;
children: React.ReactNode;
@mswat5
mswat5 / Button.tsx
Created February 18, 2025 10:29
how can we create custom components in react
import { ReactElement } from "react"
interface ButtonProps{
variant: "primary" | "secondary",
text: string,
startIcon: ReactElement,
onClick?: () => void,
fullWidth?: boolean,
loading?: boolean;
}
interface CircularProgressProps {
value: number;
size: number;
strokeWidth: number;
children?: React.ReactNode;
}
export function CircularProgress({
value,
size,
@mswat5
mswat5 / CountOccString.cpp
Created October 12, 2023 11:00
12thOct_DS-LAB
#include <bits/stdc++.h>
using namespace std;
int main() {
string str2= "lelo";
string str1= "hello";
int count=0;
for(int i =0;i<str2.size();i++){
for(int j=0;j<str1.size();j++){
if(str2[i] ==str1[j]) {
@mswat5
mswat5 / MetaCraftersIntroToSolidity1.sol
Created September 23, 2023 07:13
challenges 1 of module 3 of eth beginner course of metacrafter
// SPDX-License-Identifier: MIT
pragma solidity >=0.8;
contract variables{
uint var1;
bool var2;
string var3;
address var4;
function getFunction(uint _val1,bool _val2,string memory _val3,address _val4) public {
var1=(_val1);
var2=_val2;