Skip to content

Instantly share code, notes, and snippets.

View bearlike's full-sized avatar
🍄
+1UP

Krishnakanth Alagiri bearlike

🍄
+1UP
View GitHub Profile
@bearlike
bearlike / SSH_Banner_Script.md
Last active June 9, 2022 00:51
Dynamic banner for each time that you login through SSH.

Raspberry Pi – Awesome custom MOTD

Introduction

Even though the Raspberry Pi comes with an HDMI port, most projects are headless (runs without a display), which suggests you're mostly using SSH to access the system. I'm bored of seeing the most basic login banner, so I've played around a little bit and added something a little more useful. This login banner is your MOTD (Message of the day, Linux term).

How to do it?

Open /home/<user>/.bash_profile if you're using Raspberry Pi OS (aka. Raspbian). First you need to edit your profile:

@bearlike
bearlike / Quick-Raspberry-Pi.md
Last active March 28, 2022 09:47
Quick scripts or command sets I'll require often

Scripts and commands I use often on my Raspberry Pi

Install Docker on Raspberry Pi

curl -fsSL get.docker.com -o get-docker.sh && sh get-docker.sh && \
sudo usermod -aG docker pi && \
sudo curl https://download.docker.com/linux/raspbian/gpg && \
sudo echo "deb https://download.docker.com/linux/raspbian/ stretch stable" >> /etc/apt/sources.list && \
sudo apt-get update && sudo apt-get upgrade -y && \
@bearlike
bearlike / Test_File_Scaling.html
Created June 20, 2020 14:05
HTML Document used in the scaling experiment
<html>
<head>
<style>
html {
font-family: sans-serif;
-webkit-text-size-adjust: 100%;
-ms-text-size-adjust: 100%;
}
body {
font-family: "Helvetica Neue",Helvetica,Arial,sans-serif;
import cv2
import numpy as np
import torch
def visualize_cam(mask, img):
"""Make heatmap from mask and synthesize GradCAM result image using heatmap and img.
Args:
mask (torch.tensor): mask shape of (1, 1, H, W) and each element has value in range [0, 1]
img (torch.tensor): img shape of (1, 3, H, W) and each pixel value is in range [0, 1]
@bearlike
bearlike / .bash_profile
Created December 10, 2020 10:01
Raspberry Pi – Awesome custom MOTD
clear
echo "$(tput bold)$(tput setaf 2)"
echo " .~~. .~~. "
echo " '. \ ' ' / .' "
echo "$(tput setaf 1)"
echo " .~ .~~~..~. "
echo " : .~.'~'.~. : "
echo " ~ ( ) ( ) ~ "
echo " ( : '~'.~.'~' : )"
echo " ~ .~ ( ) ~. ~ "
@bearlike
bearlike / Common_Installation.md
Created December 15, 2020 23:13
Common Packages I use. To fasten my future Vitual Machine Setups

Python3 Libraries I always use

pip3 install wheel flask numpy pymongo selenium opencv-python bs4

Auto-Installers (For Windows Only)

https://ninite.com/7zip-discord-everything-irfanview-qbittorrent-sumatrapdf-vlc-vscode/
https://just-install.github.io/customizer.html#git,github,windows-terminal
@bearlike
bearlike / create-dns-record.py
Last active May 16, 2021 21:08
Adds DNS A records pointing to a mentioned server using Cloudflare API v4. Edit places necessary.
#!/usr/bin/env python3
"""
Adds DNS A records pointing to a mentioned server using Cloudflare API v4. Edit places necessary.
Note:
For better codebase privacy/security, refer configuration file for
authentication in python-cloudflare docs. This is for internal usage.
"""
import CloudFlare # pip3 install cloudflare
import sys
@bearlike
bearlike / clean-server.sh
Last active June 2, 2021 10:51
Script to perform system cleaning and freeing cache on my Ubuntu Server 20.04 as a part of routine server maintenance. (Purging unused Docker Objects, APT Packages, etc.)
#!/usr/bin/env bash
# Last Updated June 2, 2020
# Tested on Ubuntu Server 20.04 LTS
# Variables for pretty printing
RED=`tput bold``tput setaf 1` # Red Color
GREEN=`tput bold``tput setaf 2` # Green Color
NC=`tput sgr0` # No Color
BEGIN=$(df /home --output=used | grep -Eo '[0-9]+')
@bearlike
bearlike / update.sh
Created October 21, 2021 10:12
For Updating Packages and Portainer (if new version is available)
#!/bin/bash
# For Updating Packages and Portainer
# Tested on Ubuntu 20.04
LATEST="`wget -qO- https://hub.docker.com/v1/repositories/portainer/portainer-ce/tags`"
LATEST=`echo $LATEST | sed "s/{//g" | sed "s/}//g" | sed "s/\"//g" | cut -d ' ' -f2`
RUNNING=`docker inspect "portainer/portainer-ce" | grep Id | sed "s/\"//g" | sed "s/,//g" | tr -s ' ' | cut -d ' ' -f3`
if [ "$RUNNING" != "$LATEST" ];then
@bearlike
bearlike / delete_old_file.py
Last active November 27, 2021 12:14
Service script for a TorrentBox to periodically deletes files from a directory.
#!/usr/bin/env python3
# Service script for TorrentBox to periodically deletes files from a directory.
# Use systemctl to init a service.
import os
from datetime import datetime
import logging
logging.basicConfig(filename='delete_service.log',
format='%(asctime)s %(levelname)-8s %(message)s',
datefmt='%d-%m-%Y %H:%M:%S',