Skip to content

Instantly share code, notes, and snippets.

View ProgrammingFire's full-sized avatar
📚
Probably Learning Something New

Nouman Rahman ProgrammingFire

📚
Probably Learning Something New
View GitHub Profile
@ProgrammingFire
ProgrammingFire / ProtectedRoute.tsx
Last active July 26, 2023 13:15
Protected Route In React TypeScript With React Router And Firebase
import { FirebaseAuthConsumer } from "@react-firebase/auth";
import React from "react";
import { Redirect, Route } from "react-router-dom";
interface Props {
component: React.FC;
path: string;
exact?: boolean;
}
@ProgrammingFire
ProgrammingFire / binary_tree.rs
Last active November 15, 2021 13:09
Binary Tree Example With Rust
#[derive(PartialEq)]
struct Node<'a> {
val: &'a str,
l: Option<Box<Node<'a>>>,
r: Option<Box<Node<'a>>>,
}
impl<'a> Node<'a> {
pub fn insert(&mut self, new_val: &'a str) {
if self.val == new_val {
return
@ProgrammingFire
ProgrammingFire / Dockerfile
Created November 17, 2021 11:04
NestJS Docker Image Example
FROM node:latest
WORKDIR /app
COPY package*.json ./
RUN npm ci --only=production
COPY . ./
ENV NODE_ENV production
ENV PORT 8000
EXPOSE ${PORT}
RUN npm run test
RUN npm run build
@ProgrammingFire
ProgrammingFire / form-field-example.scss
Created November 29, 2021 10:31
Form Field Design With SCSS
input,
textarea {
width: 30vw;
border: 2px solid #ebebf2;
border-radius: 5px;
padding: 1rem 2rem;
&:focus {
outline: none;
border: 2px solid #7985ff;
@ProgrammingFire
ProgrammingFire / SimpleMap.ts
Created December 27, 2021 13:51
Map Implemented In Pure TypeScript
class MyMap<K, V> {
private map: [key: K, value: V][] = [];
set(key: K, value: V) {
const result = this.map.find(([k]) => k === key);
if (!result) {
this.map.push([key, value]);
return;
}
result[1] = value;
@ProgrammingFire
ProgrammingFire / type-safe-variables.js
Last active January 15, 2022 14:33
Type Safety In JavaScript
class Variable {
type;
value;
freeze;
constructor(value, type, freeze = false) {
if (!type) {
this.type = typeof value;
} else {
this.type = type;
@ProgrammingFire
ProgrammingFire / Dockerfile
Created February 3, 2022 07:08
Sample Node.JS Docker file
FROM node:latest # Replace With Your Node.JS Version
WORKDIR /app
COPY package*.json ./
RUN npm ci --only=production # Similiar To npm install
COPY . ./
ENV PORT 8000
EXPOSE ${PORT}
RUN npm run build
CMD ["npm", "run", "start"]
@ProgrammingFire
ProgrammingFire / programmingfire.omp.json
Last active March 11, 2022 10:28
ProgrammingFire Oh My Posh Theme
{
"$schema": "https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/schema.json",
"final_space": true,
"console_title": true,
"console_title_style": "folder",
"blocks": [
{
"type": "prompt",
"alignment": "left",
"horizontal_offset": 0,
@ProgrammingFire
ProgrammingFire / Microsoft.PowerShell_profile.ps1
Created March 16, 2022 13:31
My PowerShell Core 7 Profile
using namespace System.Management.Automation
using namespace System.Management.Automation.Language
if ($host.Name -eq 'ConsoleHost') {
Import-Module PSReadLine
}
Import-Module -Name Terminal-Icons
Function psql() {
@ProgrammingFire
ProgrammingFire / PointersInCSharp.cs
Created March 23, 2022 13:29
Pointer In C# Like C/C++
// Add <AllowUnsafeBlocks>true</AllowUnsafeBlocks> To Your *.csproj
int variable = 481;
unsafe
{
int* pointer = &variable; // Get The Pointer Of A Variable
Console.WriteLine((int)pointer); // Writes The Pointer
Console.WriteLine(*pointer); // Writes The Value
Console.WriteLine(pointer->ToString()); // Access Properties