Skip to content

Instantly share code, notes, and snippets.

Avatar
💻
Learning

Ravi RaviPabari

💻
Learning
View GitHub Profile
@RaviPabari
RaviPabari / Readme.md
Created Apr 13, 2022 — forked from cutiko/Readme.md
Git delete last commit
View Readme.md

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.

If you want to save the commits on a new branch name, then run git branch newbranchname before doing the git reset.

ORIGINAL did fork but search didn't helped me

@RaviPabari
RaviPabari / excel2Json.js
Created Oct 13, 2021
Convert excel sheet to JSON data with Node Js using xlsx lib
View excel2Json.js
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
@RaviPabari
RaviPabari / terminator.vbs
Created Sep 22, 2021 — forked from nistath/terminator.vbs
Script to start terminator on WSL from CMD or PowerShell
View terminator.vbs
' 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 = ""
View Dselect.py
# -*- 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 / Rselect.py
Last active Sep 3, 2020
Randomized Algorithm to solve Problem of computing the ith smallest element of an input array (e.g., the median).
View Rselect.py
# -*- 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)
@RaviPabari
RaviPabari / inversion_count_with_merge_sort.py
Last active Aug 11, 2020
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)
View inversion_count_with_merge_sort.py
# -*- 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