Skip to content

Instantly share code, notes, and snippets.

@navin-mohan
navin-mohan / harden-ssh.sh
Last active December 31, 2023 12:01
A script to harden openSSH on ubuntu or debian server
#!/bin/bash
# Script to harden ssh on ubuntu/debian server
# follow on my blog http://www.coderew.com/hardening_ssh_on_remote_ubuntu_debian_server/
# checkout the repo for more scripts https://github.com/nvnmo/handy-scripts
read -p "Enter your server IP:" serverIP # prompt for server IP
read -p "Enter your username(requires root privileges):" username # prompt for username
printf "\nChanging the default SSH port is one of the easiest\n things you can do to help harden you servers security. \nIt will protect you from robots that are programmed \nto scan for port 22 openings, and commence \ntheir attack."
printf "\n"
read -p "Do you want to change default SSH port?[Y/n]" -n 1 portChange
@navin-mohan
navin-mohan / producer_consumer.c
Last active January 4, 2023 19:44
Producer-Consumer problem in C using semaphores
// MIT License
// Copyright (c) 2022 Navin Mohan
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
@navin-mohan
navin-mohan / dining_philosophers.c
Created October 22, 2017 18:14
Dining Philosophers problem in C
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <string.h>
#include <unistd.h>
#include <pthread.h>
/*
use the pthread flag with gcc to compile this code
~$ gcc -pthread dining_philosophers.c -o dining_philosophers
@navin-mohan
navin-mohan / newton.cpp
Last active June 14, 2019 17:05
Newton-Raphson Method
/*
* ------------------------
* | Newton-Raphson Method |
* ------------------------
*
* Author: Navin Mohan
* Website: https://nvnmo.github.io
*
* MIT License
*
@navin-mohan
navin-mohan / hack.js
Last active May 19, 2019 09:25
resnet50 visualization
/*
** HOW TO USE
** --------------
** Go to http://alexlenail.me/NN-SVG/AlexNet.html
** Open console (Ctrl + Shift + J on Chrome)
** Paste this script and hit enter
*/
document.getElementsByClassName('btn btn-primary btn-add input-group-prepend')[0].classList.add('add-layer-btn')
@navin-mohan
navin-mohan / diff.py
Created August 9, 2016 15:38
Subtracting Two Images - OpenCV Python
import cv2
def diff(img,img1): # returns just the difference of the two images
return cv2.absdiff(img,img1)
def diff_remove_bg(img0,img,img1): # removes the background but requires three images
d1 = diff(img0,img)
d2 = diff(img,img1)
return cv2.bitwise_and(d1,d2)
@navin-mohan
navin-mohan / add-new-user-passwordless.sh
Last active July 3, 2018 13:38
Shell script to add new user to a remote debian server and set up password less login
#!/bin/bash
# This script adds a new user to the remote server , adds it to sudoers list and enables passwordless login
# follow on my blog https://www.coderew.com/computers/ssh-add-user-remotely-script/
read -p "Enter your Server IP:" serverIP #get server IP address
read -p "Enter a new username:" newusername #username for the new user
read -s -p "Enter the password for $newusername:" password #password
printf "\nEnter the root password of the server when prompted\n"
ORG 0000
CLR C
MOV DPTR,#0100
MOVX A,@DPTR
MOV R0,A
INC DPTR
MOVX A,@DPTR
ADD A,R0
INC DPTR
MOVX @DPTR,A
@navin-mohan
navin-mohan / concat.c
Created April 11, 2018 15:39
concat and remove
#include <stdio.h>
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/shm.h>
#include <pthread.h>
#include <string.h>
#include <stdlib.h>
// gcc -pthread concat.c -o concat
@navin-mohan
navin-mohan / A.c
Created April 11, 2018 03:34
FIFO NET LAB
#include <stdio.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
#include <stdlib.h>
int main(){
int n,i,a,fd1;