Skip to content

Instantly share code, notes, and snippets.

View mohitkh7's full-sized avatar

Mohit Khandelwal mohitkh7

View GitHub Profile
@mohitkh7
mohitkh7 / code.c
Last active April 29, 2018 03:25
Hardware code of Smart Irrigation System.
#include "ESP8266WiFi.h"
#include "ESP8266HTTPClient.h"
#include "ArduinoJson.h"
const int AnalogIn = A0;
const int Motor_Pin = D1;
const char* ssid = "JioFi3_1E8B14";
const char* password = "9d1u40ntfbb";
const char* host = "mohitkh7.pythonanywhere.com";
@mohitkh7
mohitkh7 / Analogy.md
Last active May 23, 2019 17:49
Collections of interesting analogies

Autorickshaw and Campus Opportunities

We all are just like Autorickshaws always looking for customers(opportunities). Its very good to have customer (opportunity) with you. If you don't have it keep on roaming keep on searching you will definately find one. But what about those rickshaws who just stay at rickshaw stops and don't roam around ? They are like one who is at IIT/NIT/IIM and passenger (opportunities) will themselves come up. But if you are not standing at such a rickshaw stand then keep wandering, just never stop. Coz you rickshaws made to be driven ( just like you are made to explore & struggle ). And remember even rickshaw standing at stand sometimes need to roam around in search of passenger. Just like top tier institute students sometimes need to look beyond in campus options to grab a certain opportunity. And remember if one customer(opportunity) comes but refuses to go along never be downhearted a next customer (opportunity) may be willing to travel longer distance will come soon.

TC

@mohitkh7
mohitkh7 / pg_study.md
Last active July 5, 2018 13:16
Study & Analysis of Payment Gateway

Hosted vs Integrated Gateway

The integrated gateways let your buyers enter their payment data while they are on your website; the hosted gateways redirect users to the payment processor’s platform. An integrated gateway allows users to input their payment data without leaving your website. For them this is a seamless process. But this type of payment gateway will work well only if your website is secure enough, since all payment details will be stored on your server.

Payment Gateway Fees

  • Setup fee/registration fee (one-time payment);
  • monthly fee;
  • Transaction fee/payment processing fee/credit card processing fee (charged as a percentage or a fixed fee on every transaction);
  • Chargeback fee.
@mohitkh7
mohitkh7 / file_with_milisecond_name.py
Created July 16, 2018 05:44
Python codefile to save file with name as timestamp of accuracy upto millisecond
# Python code to save a file with timestamp of accuracy upto millisecond
from datetime import datetime as dt
current_time = dt.now() # current system time e.g. 2018-07-16 16:34:43.050328
current_time_as_str = str(current_time)
filename = current_time_as_str + ".txt"
file = open(filename, "w+") # Create a empty text file with timestamp name
file.close()
@mohitkh7
mohitkh7 / game.py
Created May 4, 2019 10:03
Python Game
import turtle
# set up screen
window = turtle.Screen()
window.bgcolor("#bbb")
# Setting up boundry
mypen = turtle.Turtle()
mypen.penup()
mypen.setposition(-260, -260)
@mohitkh7
mohitkh7 / variableHeightDiv.html
Created May 4, 2019 18:06
A scroll able div inside collapsible panel having variable height
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.0/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/js/bootstrap.min.js"></script>
<style>
#scroll-section{
@mohitkh7
mohitkh7 / solution.js
Created July 23, 2021 08:55
solution for programming question
// Q2. Write a function to get Max value of a number Array?
function findMax(arr) {
maxValue = arr[0];
arr.forEach(element => {
if (element >= maxValue) {
maxValue = element;
}
});
return maxValue;
@mohitkh7
mohitkh7 / game_of_dice.py
Created August 9, 2021 11:31
"Game of Dice" is a CLI based game written in python language.
"""
The Game of Dice
The "Game of Dice" is a game where two players roll 6 faced dice in a round-robin fashion.
Each time a player rolls the dice their points increase by the number (1 to 6) achieved by the
roll. The first player to accumulate M points wins the game.
created by - Mohit Khandelwal (mohitkh7@gmail.com)
"""
@mohitkh7
mohitkh7 / interview_question.py
Created September 25, 2021 08:33
Solution for interview
"""
Q1. Given an unsorted array with multiple duplicate elements. Find the most repeated element. Return the bigger number if multiple numbers have the highest frequency.
For example:
T1:
Input: [2, 1, -2, 55, 2, 1, 3, 9, 3, 3]
Answer: 3
T2: [1, 1, 2, 2, 2, 2, 1, 1]
Answer: 2
"""
def most_frequent(arr):
@mohitkh7
mohitkh7 / blockchain_skeleton.py
Created January 20, 2022 19:44
Skeleton code for scipy 2021 blockchain workshop
from flask import Flask
class Blockchain():
def __init__(self):
self.chain = []
self.current_transactions = []
def new_block(self):
# Creates a new Block and adds it to the chain
pass