Skip to content

Instantly share code, notes, and snippets.

View iKunalChhabra's full-sized avatar
🚀
Working on something great !

Kunal Chhabra iKunalChhabra

🚀
Working on something great !
View GitHub Profile
@iKunalChhabra
iKunalChhabra / dnsServer.cpp
Created September 4, 2025 12:44
A simple DNS Server in C++
#include <iostream>
#include <cstring>
#include <ranges>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <unistd.h>
#include <vector>
struct DNSHeaderFlags
@iKunalChhabra
iKunalChhabra / server.cpp
Created August 31, 2025 08:48
C++ server from scratch
#include <iostream>
#include <cstdlib>
#include <string>
#include <cstring>
#include <unistd.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <stdexcept>
@iKunalChhabra
iKunalChhabra / kunal.omp.json
Created June 8, 2025 18:37
.config/oh-my-posh/themes Material Dark style
{
"$schema": "https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/schema.json",
"palette": {
"background": "#212121",
"surface": "#303030",
"primary": "#BB86FC",
"secondary": "#03DAC6",
"accent": "#CF6679",
"text": "#FFFFFF",
"text_secondary": "#B3B3B3",
@iKunalChhabra
iKunalChhabra / main.c
Created May 11, 2025 08:27
C program with coloured output and named args to struct
#include <stdio.h>
char* red = "\033[1;31m";
char* blue = "\033[1;32m";
char* green = "\033[1;34m";
char* reset = "\033[0m";
typedef enum{
MALE,
FEMALE
@iKunalChhabra
iKunalChhabra / main.c
Created May 10, 2025 13:03
Simple test case with C
#include <stdio.h>
#define MUNIT_ENABLE_ASSERT_ALIASES
#include "munit.h"
static MunitResult
test_int_equal(const MunitParameter params[], void* data) {
int a = 5;
int b = 5;
assert_int(a, ==, b);
return MUNIT_OK;
@iKunalChhabra
iKunalChhabra / main.c
Created May 9, 2025 17:23
Create objects in C
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
typedef struct person
{
const char* name;
int age;
void (*print)(struct person*);
} person_t;
@iKunalChhabra
iKunalChhabra / Makefile
Last active May 5, 2025 16:58
Simple c++ makefile
# Makefile
# '@' added to suppress printing commands on shell
# Variables
CXX = g++
CXXFLAGS = -O3
TARGET = main
SRC = main.cpp
@iKunalChhabra
iKunalChhabra / server_raw.cpp
Created May 1, 2025 18:32
Raw HTTP Sever in c++
#include <sys/epoll.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <fcntl.h>
#include <unistd.h>
#include <cstring>
#include <iostream>
#include <thread>
#include <vector>
@iKunalChhabra
iKunalChhabra / main.py
Created April 3, 2025 13:48
FastAPI sever to execute unix commands and stream back the response via websockets
# main.py
import asyncio
from fastapi import FastAPI, WebSocket, WebSocketDisconnect
app = FastAPI()
async def stream_shell_output(command: str, websocket: WebSocket) -> None:
"""
@iKunalChhabra
iKunalChhabra / main.kt
Created December 9, 2024 14:41
JSON Web Token in Kotlin
package org.example
import io.jsonwebtoken.Jwts
import io.jsonwebtoken.security.Keys
import java.time.Duration
import java.util.*
fun main() {
// val secretKey = SIG.HS512.key().build().encoded
val secretKey = "JNu4i@rL����&�#�k\"\u000Bv0��hn����xH)�\u007FZ�]�&\u0013�]\u0011>8�qB~M�bA�1\u0017Y�U�K"