Skip to content

Instantly share code, notes, and snippets.

@rahuldhole
rahuldhole / cpu-ram-usage-xmessage.sh
Last active May 9, 2024 00:22
CPU & RAM usage popup | Create a shortcut to call this script
#!/bin/bash
# Capture CPU usage
cpu_usage=$(top -bn2 | grep '%Cpu' | tail -1 | grep -P '(....|...) id,' | awk '{print 100-$8}')
# Capture memory usage
memory_usage=$(free -m | grep 'Mem:' | awk '{ print $3/$2*100 }')
# Display CPU and memory usage in a popup message using xmessage
echo -e "System Usage \nCPU Usage: $cpu_usage% \nMemory Usage: $memory_usage%"
@rahuldhole
rahuldhole / resource-limiter
Last active May 9, 2024 19:20
Increase laptop battery life: A Simple Bash Script
#!/bin/bash
# Change Settings
cpu_threshold=30 # max percentage
memory_threshold=95 # max percentage
processes="chrome,code" # Processes to monitor and kill (comma-separated)
# Article to read more: https://dev.to/rahuldhole/managing-resource-deadlocks-a-simple-bash-script-for-linux-1n64
# Function to monitor CPU usage
@rahuldhole
rahuldhole / Dockerfile.rsync
Last active May 9, 2024 00:22
rsync your code into docker container. Instead of direct mounting to the WORKDIR mount somewhere else an sync it to avoid permission override issue leading to permission denied errors in the container.
# Use a Debian base image
FROM debian:latest
ARG USERNAME=debian
# Define environment variables
ENV SOURCE_CODE_VOLUME_MOUNT="/host-code" \
WORKING_DIR="/app"
# Install rsync, make, nano, and procps
RUN apt-get update \
@rahuldhole
rahuldhole / Dockerfile.devtools
Last active May 17, 2024 21:10
Docker Devtools for Debian based image. TMUX, Oh My ZSH, Powerlevel10k, Fuzzy finder, htop, etc
# ##########################################################
# Dockerfile for Developer Tools.
# Description: This Dockerfile is for adding a devtools stage.
#
# Author information:
# Name: Rahul Dhole
# Email: rdhole95@gmail.com
# GitHub: https://github.com/rahuldhole
#
# Dockerfile description:
@rahuldhole
rahuldhole / nextcloud-production-torrent.docker-compose.yml
Created April 24, 2024 01:28
Nextcloud for production along with torrent downloader.
version: '3'
services:
app:
image: nextcloud
container_name: nextcloud
restart: unless-stopped
ports:
- "80:80"
volumes:
@rahuldhole
rahuldhole / Enable and disable events.EXCEL.yaml
Created May 2, 2020 04:10
Toggles event firing on and off.
name: Enable and disable events
description: Toggles event firing on and off.
host: EXCEL
api_set: {}
script:
content: >
$("#toggleEvents").click(() => tryCatch(toggleEvents));
$("#setup").click(() => tryCatch(setup));
/*
* Inspired by: http://stackoverflow.com/questions/4360060/video-streaming-with-html-5-via-node-js
*/
var http = require('http'),
fs = require('fs'),
util = require('util');
http.createServer(function (req, res) {
var path = 'video.mp4';