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 / 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);
@chavarera
chavarera / pwbar.py
Last active July 7, 2023 08:41
Displays a progress bar while iterating over an iterable.
"""
Author: Ravishankar Chavare
Version: 1.0
File: pwbar.py
Description: This module provides a progress bar utility for tracking the
progress of iterative tasks.
1.1
===
@phatnguyenuit
phatnguyenuit / how-to-sort-imports-like-a-pro.md
Last active July 3, 2024 21:28
How to sort imports like a pro in TypeScript

How to sort imports like a pro in TypeScript

Crossing reviews becomes a very common activity today in engineering behavior. To help us review changes for pull/merge requests easier, sorting imports can help us a much. The codebase becomes more professional and more consistent, reviewers will be happier, and the review process will be faster, focusing on the implementation changes ONLY.

Have you ever thought about how to sort imports in TypeScript projects automatically?

Let me show you how to archive sorting imports automatically in TypeScript projects with ESLint!

@aahnik
aahnik / #clean-pip.md
Last active May 17, 2021 08:03
A script to uninstall all python packages via pip and clear cache. (For Unix based systems only. Ditch Windows today.)

Run this script directly

curl -Lks bit.ly/pipclear | python
@aahnik
aahnik / locorg.py
Last active April 3, 2022 16:26
organize files of loconotion output https://github.com/leoncvlt/loconotion/issues/36
# MIT License
# Aahnik 2021
# a script to organize the files in loconotion output
# also updates html and css files
# unix (linux / mac) style file paths are used in the program,
# will fail inevitably if run on windows
# ditch windows
import logging
import os
@aahnik
aahnik / #run_multi.md
Last active August 5, 2022 14:51
Run multiple bot telegram bot clients using gnu-screen (terminal-multiplexer). Supply bot tokens via bots.yml to this script. [telethon,telegram,bots.gnu-screen,screen,multiples]

First of all you make a bot whose multiple instances are to be run from the same server.

Suppose the bot is run by invoking main.py with the bot_name and token as command line arguments.

Syntax:

[PYTHON] [ENTRY_POINT] [bot_name] [token]

Example:

python main.py mysamplebot "173453434:42jhs894_13234jsjgasjs"

@aahnik
aahnik / #channel joiner.md
Last active October 22, 2022 19:54
Telethon , telegram , join telegram channels from a list

Here is an example of .env file you need to use:

Screenshot from 2021-01-15 17-21-41

Make sure to have telethon and python-dotenv installed.

@aahnik
aahnik / get_chat_info.py
Last active January 8, 2021 15:47
Telegram Chat info. Telethon. Python.
import asyncio
from settings import API_ID, API_HASH
from telethon import TelegramClient
from utils import _
async def get_chat_id(ref=None):
async with TelegramClient('tg_session', API_ID, API_HASH) as client:
if not ref:
ref = input('Enter link/phone/username/id to get chat info: ')
@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.