Skip to content

Instantly share code, notes, and snippets.

View aahnik's full-sized avatar
🏠
something's happening!

Aahnik Daw aahnik

🏠
something's happening!
View GitHub Profile
@aahnik
aahnik / #get_session_string.md
Last active March 12, 2024 01:56
A python script to get Telegram session string after logging into user account. Using Telethon.

You must ensure that you have Telethon installed. Run pip install telethon to install.

[optional]

You can can create file called .env in the directory from which you are running the script.

.env

@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 / #tg_conv_bot.md
Last active August 6, 2023 18:31
A simple conversation bot that will ask user's name, and save it. Persistent, Polling, Shows Button, Has conversation flow, Conversation Handler, python-telegram-bot, ptb,

How to run

  1. Install dependancies.
pip3 install python-dotenv python-telegram-bot
  1. Then put the files of this gist inside a folder.
@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);
Loading
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)