Skip to content

Instantly share code, notes, and snippets.

View RaviPabari's full-sized avatar
💻
Learning

Ravi Pabari RaviPabari

💻
Learning
View GitHub Profile
@RaviPabari
RaviPabari / inversion_count_with_merge_sort.py
Last active August 11, 2020 17:09
Simple way to find inversions count in an array using python (with comments step by step) by augmenting the Merge Sort by simply adding a inversion count value. Week 2 Divide and Conquer Algorithms Stanford University Coursera(Specialization Part-1)
# -*- coding: utf-8 -*-
"""
Spyder Editor
Created on Tue Aug 11 22:37:02 2020
@author: Ravi
"""
def merge_lists(left_sublist,right_sublist):
#augmentaion starts here
#initialize a inversion count variable to zero
@RaviPabari
RaviPabari / Rselect.py
Last active September 3, 2020 09:44
Randomized Algorithm to solve Problem of computing the ith smallest element of an input array (e.g., the median).
# -*- coding: utf-8 -*-
"""
Created on Mon Aug 31 19:53:34 2020
@author: Ravi
"""
'''
Random Selection Algorithm to compute ith order statistic in O(n) time with
high probability, this algorithm is just a made by simple modification of
Quick Sort. If we are very very unlucky then worst case running time = O(n**2)
# -*- coding: utf-8 -*-
"""
Created on Tue Sep 1 12:12:18 2020
@author: Ravi
"""
'''
Deterministic Selection Algorithm !(one of the coolest linear time algo)
Running Time O(n) {note that not as practical as randomized, cause the constant here is big compare to randomized}
'''
@RaviPabari
RaviPabari / terminator.vbs
Created September 22, 2021 07:23 — forked from nistath/terminator.vbs
Script to start terminator on WSL from CMD or PowerShell
' Usage: terminator[.vbs] [path to starting directory]
' contents enclosed in square brackets optional
args = "-c" & " -l " & """DISPLAY=:0 terminator"""
' If there's a single argument, interpret it as the starting directory
If WScript.Arguments.Count = 1 Then
dir = WScript.Arguments(0)
Else
dir = ""
@RaviPabari
RaviPabari / excel2Json.js
Created October 13, 2021 13:23
Convert excel sheet to JSON data with Node Js using xlsx lib
const xlsx = require('xlsx')
function excelToJson() {
//read the whole sheet
const sheet = xlsx.readFile('/home/ravi/Desktop/message.xlsx')
//depending on the sheet you want to convert, in my case I wanted the to convert
//first sheet only
const first_sheet = sheet.SheetNames[0]
const sheet1 = sheet.Sheets[first_sheet]
//returns array of object mapped to key pair values dynamically
Removing the last commit
To remove the last commit from git, you can simply run git reset --hard HEAD^
If you are removing multiple commits from the top, you can run git reset --hard HEAD~2 to remove the last two commits.
You can increase the number to remove even more commits.
If you want to "uncommit" the commits, but keep the changes around for reworking,
remove the "--hard": git reset HEAD^ which will evict the commits from the branch and from the index,
but leave the working tree around.

SSH keypair setup for GitHub (or GitHub/GitLab/BitBucket, etc, etc)

Create a repo.

Make sure there is at least one file in it (even just the README.md)

Generate a SSH key pair (private/public):

ssh-keygen -t rsa -C "your_email@example.com"