Skip to content

Instantly share code, notes, and snippets.

View aahnik's full-sized avatar

Aahnik Daw aahnik

View GitHub Profile
@aahnik
aahnik / index.js
Last active March 4, 2024 14:12
[Ejs + Static Files] Frotend Server process... Server all ejs templates from a directory "views" + server static files from "public"
/*
frontend server
server HTML,CSS and frontend js
use ejs to render html
Credits: https://gist.github.com/noampc/6a36885dbe75f24056ac7a3c7f50d2b7
*/
import express from "express";
@aahnik
aahnik / cpp.json
Created January 9, 2024 12:33
Cp Vs code setup for leetcode and codeforces
{
"Cp cpp": {
"prefix": "cpp",
"body": [
"#include <bits/stdc++.h>",
"using namespace std;",
"",
"#ifdef aahnik",
"#include \"dbg.cpp\"",
"#else",
@aahnik
aahnik / oplo.c
Created September 12, 2023 06:44
Testing Optimistic Locking
#include <pthread.h>
#include <stdatomic.h>
#include <stdbool.h>
#include <stdio.h>
#define MAX 90000
atomic_int count = ATOMIC_VAR_INIT(0);
int faltu = 0;
@aahnik
aahnik / graphs_dot.md
Last active July 31, 2023 16:38
Visualizing graphs and trees while solving dsa problems

Simple guide to visualize graphs

Install the graphviz tool

code_graphviz_install

Run dot -V to check the version and if it was installed properly or not.

@aahnik
aahnik / cat.c
Last active July 27, 2023 20:12
Implementation of cat from book The C Programming Language 2e
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[]) {
FILE *fp;
void filecopy(FILE *, FILE *);
if (argc == 1) {
// no input, so copy stdin
filecopy(stdin, stdout);
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
def perm(suffix, prefix="") -> None:
if len(suffix) == 1:
print(prefix + suffix)
else:
for i, char in enumerate(suffix):
perm(suffix[:i] + suffix[i + 1 :], prefix + char)
perm("hello")
@aahnik
aahnik / suffixer.py
Created November 30, 2022 10:43
Python Script to add suffix to all your files
import os
SUFFIX = "S20220010001" # replace with your suffix
for item in os.listdir():
fname, ext = item.split(".")
if not fname.endswith(SUFFIX):
fname += f"_{SUFFIX}"
os.rename(item, fname + "." + ext)

Keybase proof

I hereby claim:

  • I am aahnik on github.
  • I am aahnik (https://keybase.io/aahnik) on keybase.
  • I have a public key ASD6gkdBjzzeDitjNKdxB9SEUv5Is-CoLe_C47s-1PG85go

To claim this, I am signing this object:

@aahnik
aahnik / server_setup.sh
Created June 18, 2021 04:02
My script to setup Digital Ocean Ubuntu Droplet for deploying python apps
apt-get update && apt-get upgrade -y
apt install wget curl git zsh -y
sh -c "$(wget https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh -O -)"
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
apt install python3.9 python3.9-venv python3-pip -y
python3.9 -m pip install --upgrade pip
sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.9 2
pip install pipx
pipx ensurepath
pipx install poetry