Skip to content

Instantly share code, notes, and snippets.

View TheProjectsGuy's full-sized avatar
🎯
Focusing

Avneesh Mishra TheProjectsGuy

🎯
Focusing
View GitHub Profile
@TheProjectsGuy
TheProjectsGuy / env_setup.sh
Last active September 4, 2023 17:55
Starter (boilerplate) for an environment setup script (for conda/mamba environments) that installs/sets up all packages.
# Setup everything for this repository
readonly ARGS="$@" # Reset using https://stackoverflow.com/a/4827707
readonly PROGNAME=$(basename $0)
readonly PROGPATH=$(realpath $(dirname $0))
# Internal variables
env_name="proj" # Name of the environment
exec_name="conda" # Executable
dry_run="false" # 'true' or 'false'
@TheProjectsGuy
TheProjectsGuy / proc_see_kill.sh
Last active April 22, 2023 07:41
Monitor the RAM utilization of a process and kill it if it is above a threshold. Can be put in a cron job. The kills are logged. If manually invoked (on Linux Mint), a system notification is also sent.
#!/bin/bash
readonly VERSION_MAJOR=1
readonly VERSION_MINOR=2
VERSION="${VERSION_MAJOR}.${VERSION_MINOR}"
# Program properties
readonly ARGS="$@" # Reset using https://stackoverflow.com/a/4827707
readonly PROGNAME=$(basename $0)
readonly PROGPATH=$(realpath $(dirname $0))
@TheProjectsGuy
TheProjectsGuy / mic_control.sh
Created October 30, 2022 14:36
Controlling your mic using amixer on Linux Mint
#!/bin/bash
# Toggle mic ON/OFF
tgl=$(amixer -D pulse sset Capture toggle)
if echo "$tgl" | grep "\] \[off\]"; then
echo "Mic is toggled OFF"
else
echo "Mic is toggled ON"
fi
@TheProjectsGuy
TheProjectsGuy / conda-backup.sh
Last active April 22, 2023 07:41
A shell script to backup anaconda environments (single command and save YML file)
#!/bin/bash
# Copyright (C) 2022 Avneesh Mishra - GNU GPLv3
#
# This program is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation, either version 3 of the License, or (at your
# option) any later version.
#
# This program is distributed in the hope that it will be useful, but
@TheProjectsGuy
TheProjectsGuy / custom_python_iters.py
Created August 3, 2022 11:48
Testing (creating) custom python iterators using iter, next, or getitem
# Testing __getitem__() and Python Iterators
"""
Some resources:
- https://stackoverflow.com/a/61658447/5836037
"""
# %%
class Something:
def __init__(self) -> None:
self.items = [10, 20, 35, 60, 75]
@TheProjectsGuy
TheProjectsGuy / csinteractive.sh
Last active October 23, 2023 08:15
A helpful SLURM utility. Get node allocation using salloc and run an interactive shell session on it. This, plus many more bells and whistles.
#!/bin/bash
# Copyright (C) 2022 Avneesh Mishra - GNU GPLv3
#
# This program is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation, either version 3 of the License, or (at your
# option) any later version.
#
# This program is distributed in the hope that it will be useful, but
@TheProjectsGuy
TheProjectsGuy / python_path_gimmick.py
Created April 19, 2022 04:49
A gimmick to add a path to python interpreter
import os
import sys
from pathlib import Path
# Set the "./../lib" from the script folder
dir_name = None
try:
dir_name = os.path.dirname(os.path.realpath(__file__))
except NameError:
print("WARN: __file__ not found, trying local")
dir_name = os.path.abspath('')
@TheProjectsGuy
TheProjectsGuy / Multithreading_script_1.py
Created February 1, 2020 07:09
Multithreading in python using "start_new_thread" from "_thread" library in Python 3.x
#!/usr/bin/env python3
from _thread import start_new_thread
def count_to_n(id, n):
"""
Count numbers from 0 to n - 1
Parameters:
id: The identifier for the function
n: The number to count upto (exclusive of n)
@TheProjectsGuy
TheProjectsGuy / CoppeliaSim.desktop
Created December 8, 2019 18:22
VReP desktop file for Ubuntu. Logo (icon) from their twitter handle @coppeliaRobotic
[Desktop Entry]
Name=CoppeliaSim
Comment=Robotic Simulation software from Coppelia Robotics. Formally known as VReP
Exec=/opt/CoppeliaSim_Edu_V4_0_0_Ubuntu18_04/coppeliaSim.sh
Icon=/opt/CoppeliaSim_Edu_V4_0_0_Ubuntu18_04/helpFiles/logo.png
Terminal=true
Type=Application
Category=Simulation;Robotics;Education;Science;
StartupNotify=true
Keywords=VReP;
@TheProjectsGuy
TheProjectsGuy / matlab_r2019b.desktop
Created September 28, 2019 05:00
MATLAB Desktop file for MATLAB R2019b installations on Linux systems. This file must be saved in "/usr/share/applications" directory (you can use any name but "matlab_r2019b.desktop" is suggested)
[Desktop Entry]
Name=MATLAB R2019b
Comment=MATLAB R2019b software
Exec=/usr/local/MATLAB/R2019b/bin/matlab -desktop
Icon=/usr/local/MATLAB/R2019b/matlab_logo.png
Terminal=true
Type=Application
Category=Development;Simulation;Education;Science;
StartupNotify=true
Keywords=Run;