Skip to content

Instantly share code, notes, and snippets.

View haseeb-heaven's full-sized avatar
🏠
Working from home

HaseebHeaven haseeb-heaven

🏠
Working from home
View GitHub Profile
@haseeb-heaven
haseeb-heaven / stb_vector.h
Last active November 1, 2025 08:23
A simple and safe dynamic array in C that grows automatically, checks index bounds, prevents crashes from invalid access, and makes handling lists of data easier and safer.
/**
* stb_vector.h - v1.0 - public domain type-safe generic dynamic arrays
*
* This is a single-header-file library that provides easy-to-use
* dynamic arrays for C (also works in C++).
*
* DO THIS ONCE, AT THE START OF ONE SOURCE FILE:
* #define STB_VECTOR_IMPLEMENTATION
* #include "stb_vector.h"
*
@haseeb-heaven
haseeb-heaven / ASCII_TextGenerator.cpp
Created July 8, 2025 10:20
Clever way of Gemini pro to use factory map for print ASCII art from input.
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <functional>
#include <stdexcept>
#include <algorithm>
#include <utility>
#include <cctype>
@haseeb-heaven
haseeb-heaven / printc.cpp
Last active July 2, 2025 12:07
C++ General way of printing data of container including List,Sets,Maps,Stack,Queues etc.
/*
Info: C++ General way of printing data of container including List, Sets, Maps, Stack, Queues, etc.
From this library, we have two ways to print supported STL containers:
* 1. Use the printc(container) function
* 2. Use the overloaded << operator with std::cout
Author: Haseeb Mir @2022.
*/
@haseeb-heaven
haseeb-heaven / employees_max_salary.sql
Created June 6, 2025 13:22
Employees max salary from each department
SELECT employee_name, department, salary
FROM employees e
WHERE salary = (
SELECT MAX(salary)
FROM employees
WHERE department = e.department
)
ORDER BY department;
@haseeb-heaven
haseeb-heaven / interactive_calculator_ui.c
Last active February 19, 2025 02:32
A terminal-based calculator program written in C that simulates a physical calculator. Uses C with classes, handles errors safely, and shows a colorful number pad interface. Supports basic math operations with high decimal precision.
#include <stdio.h>
#include <stdlib.h>
#include <setjmp.h>
#include <stdbool.h>
#include <string.h>
#include <stdint.h>
#ifdef _WIN32
#include <conio.h>
void clear_screen() { system("cls"); }
@haseeb-heaven
haseeb-heaven / file_checker.cpp
Created December 1, 2024 18:55
Advanced File Type Detection Program like GNU file type detection tool
// Advanced File Type Detection Program like GNU file type detection tool
// Note: This program is a simplified version and may not cover all possible file types.
// Created by: HeavenHM.
// Date: 2024-01-12
#include <iostream>
#include <fstream>
#include <string>
#include <filesystem>
#include <algorithm>
@haseeb-heaven
haseeb-heaven / README.md
Last active January 7, 2025 11:47
Turn your keyboard to Piano using Python.

PyPiano

This Python program uses several libraries to generate and play sine wave tones based on keyboard input.

Libraries Used

  • io: This is a built-in Python library for handling streams of data. It's included with Python, so you don't need to install it separately.

  • pydub: This is a simple and easy-to-use library to manipulate audio files. It can be installed with pip using pip install pydub. It's used in this code to generate a sine wave tone and play it.

@haseeb-heaven
haseeb-heaven / void_return.c
Last active January 4, 2025 12:04
An innovative approach to returning values from void/null-based methods using function pointers, ensuring compatibility across all major operating systems.
#include <stdio.h>
#include <stdint.h>
// Define ARCH_NAME based on the detected architecture
#if defined(__x86_64__) || defined(_M_X64)
#define ARCH_NAME "x86_64"
#elif defined(__i386__) || defined(_M_IX86)
#define ARCH_NAME "x86"
#elif defined(__aarch64__) || defined(_M_ARM64)
#define ARCH_NAME "ARM64"
@haseeb-heaven
haseeb-heaven / crud_file.cpp
Created January 3, 2025 19:43
CRUD Operations with std::print and clean optimised code with binary file support using latest C++ 23.
#include <fstream>
#include <string>
#include <print> # C++ 23 print
#include <stdexcept>
bool is_binary_file(const std::string& filename) {
std::ifstream input_file_stream(filename, std::ios::binary);
if (!input_file_stream) {
throw std::runtime_error("Could not open file '" + filename + "'.");
}
@haseeb-heaven
haseeb-heaven / falling_matrix.cpp
Created January 1, 2025 14:34
Simulation of falling matrix in C++ 20 , modular and robust approach.
#include <iostream>
#include <string>
#include <vector>
#include <random>
#include <thread>
#include <chrono>
void initialize_random_seed() {
std::random_device rd;
std::srand(rd());