Skip to content

Instantly share code, notes, and snippets.

@navin-mohan
navin-mohan / debian.md
Last active April 22, 2017 15:16
installing and setting up debian

Installing and Setting Up Debian

A quick guide on installing and setting up debian.

Getting Debian

You can download the Debian ISO image from the official debian website. It's available for download over HTTP, FTP and BitTorrent. The 64-bit CD version should work on most systems, get the DVD image if you need more packages preinstalled.

Installing Debian

In a Virtual Machine

To install Debian on a VM, create a new VM and choose the downloaded Debian ISO file as the start-up disk. The VM should boot up with the installation screen.

On an Actual Machine

#!/bin/bash
if [ -e ~/.nvm/nvm.sh ]; then
. ~/.nvm/nvm.sh
fi
if [ -e ~/.profile ]; then
. ~/.profile
fi
if [ -e ~/.bashrc ]; then
. ~/.bashrc
@navin-mohan
navin-mohan / kernel.sh
Last active April 2, 2017 11:15
Configure Debian
#!/bin/bash
cat << EOF > ~/src
deb [arch=amd64] http://mirror.cse.iitk.ac.in/debian/ jessie main contrib non-free
deb-src [arch=amd64] http://mirror.cse.iitk.ac.in/debian/ jessie main contrib non-free
deb [arch=amd64] http://mirror.cse.iitk.ac.in/debian/ jessie-updates main contrib non-free
deb-src [arch=amd64] http://mirror.cse.iitk.ac.in/debian/ jessie-updates main contrib non-free
deb [arch=amd64] http://security.debian.org/ jessie/updates main contrib non-free
@navin-mohan
navin-mohan / ship.cpp
Created February 12, 2017 07:36
Arduino Leonardo Joystick Library
#include <Joystick.h>
Joystick_ Joystick(JOYSTICK_DEFAULT_REPORT_ID,
JOYSTICK_TYPE_MULTI_AXIS, 32, 0,
false, false, false, false, false, false,
true, true, false, false, false); // only rudder and throttle
const int rudderPin = A1;
const int throttlePin = A2;
@navin-mohan
navin-mohan / bracket_matching.cpp
Created January 21, 2017 13:37
Bracket Matching C++ code
#include <iostream>
#include <stack>
using namespace std;
class bracket_matcher: public stack<char>{
public:
bracket_matcher(): stack<char>() { matching = 1;}
void push_bracket(const char &arg){
@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)
#include <IRremote.h> //include the IR library
//#define DEBUG 0 //enable debug mode
#define LED_PIN 13 //the pin showing the output
int IR_pin = 4; //digital pin connected to output of the TSOP
unsigned long currentCode=0,storedCode=0; //to store the recieved code for comparison
bool outputState = 0; //stores the default output state of the lED that is OFF
@navin-mohan
navin-mohan / sketch.ino
Last active May 12, 2016 12:26
Arduino Based Automatic Plant Watering System Using Soil Moisture Sensor
/*
Automatic Plant Watering System Using Soil Moisture Sensor
-------------------------------------------------------------
This is an Arduino based Plant watering system that uses a soil moisture sensor
to monitor the garden soil and automatically water the plants when the moisture
level falls below a threshold value. The minimum moisture level can be set using
a Potentiometer.
Arduino Pin Config:
-> A0 : The analog output from the moisture sensor
@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 / runningkey.cpp
Last active March 9, 2018 19:46
Running key cipher implementation in C++
/*
The Running Key
----------------
The running key cryptographic algorithm is a classical cipher that uses a long key
such as random sentences from books to encrypt another message. It uses a table for
mapping the cipher text using the key and the plain-text.
get more info here