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 / bash_string_to_array.sh
Created May 13, 2021 10:04
Convert a bash string to an array of words. Using the IFS (internal field seperator).
export IFS=" "
str="hello world what is happening"
arr=( $str )
echo first word: ${arr[0]}
echo second word: ${arr[1]}
echo third word: ${arr[2]}
@aahnik
aahnik / #clean-pip.md
Last active May 24, 2025 10:14
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 / 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

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 / 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)
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")
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@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);
@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 / 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;