Skip to content

Instantly share code, notes, and snippets.

View greatsharma's full-sized avatar
🏠
Working from home

Gaurav Sharma greatsharma

🏠
Working from home
View GitHub Profile
@greatsharma
greatsharma / mongo_cmds
Created June 22, 2020 05:14
Some important mongo commands
* docker run --name mongo-container -d -p 27017:27017 -v data:/data/db mongo
* mongo remote_ip [connect to a remote monogodb using mongoshell]
* mongo --host mongodb0.example.com --port 27017
* sql:table::nosql:collection
* sql:datarow::nosql:document
@greatsharma
greatsharma / lxc_lxd_cmds
Created June 22, 2020 05:10
Some important lxc lxd commands
* sudo gpasswd -a user_name[like winter_soilder] lxd [to add user to the lxd group so no sudo is required to execute lxc cmds]
* getent group group_name[lxd] [to see the group members]
* lxd init [initialize lxd env]
* lxc version
* lxc help | less
@greatsharma
greatsharma / docker_commands
Created June 22, 2020 05:08
Some important docker commands
* sudo systemctl status docker [check whether docker is running]
* getent group docker [check whether we are the memeber of the group, if not then we need
to add in the group to run docker commands]
* to add in docker group
sudo usermod -aG docker ${USER}
su - ${USER}
* docker pull image_name [pull the image]
@greatsharma
greatsharma / git_commands
Last active July 8, 2021 06:28
Some Important git commands.
Resources ->
http://rogerdudler.github.io/git-guide/
https://git-scm.com/book/en/v2/Git-Branching-Remote-Branches
* git config cmds :-
git config --global user.name "user name"
git config --global user.email "user email"
git config --global color.ui "auto"
git config --global core.editor "vim"
@greatsharma
greatsharma / termds.txt
Created November 16, 2019 16:30
important terminal commands.
* man command [manual for a command]
* sudo -s passwd [to set root password]
* figlet "text here" [show text in design]
* grep pattern file_name [find pattern in file]
* | [pipe commands, eg: cat file | grep pattern]
@greatsharma
greatsharma / fuzzymatch_spaceOptimal.py
Last active August 28, 2020 06:00
Space Optimal Fuzzy Matching: This gist do a fuzzy matching of documents on the basis of levenshtein distance and returns a similarity score. This do the same as my previous gist https://gist.github.com/greatsharma/eeb22285a837a9b29431179451d0ba7f with a time complexity of O(mn) but the space complexity is now reduced to O(m) i.e., linear time,…
import gc
import numpy as np
from pprint import pprint
def levenshtein_distance_optimal(pattern, docs, ignore_case=True) -> dict:
"""Do a fuzzy matching of documents using levenshtein distance in linear space complexity
Parameters
----------
@greatsharma
greatsharma / fuzzymatch.py
Last active September 21, 2019 06:47
This gist do a fuzzy matching of documents on the basis of levenshtein distance and returns a similarity score. Time and space complexities are O(mn), where m and n are documents length which we match
import numpy as np
from pprint import pprint
def levenshtein_distance(pattern, docs, ignore_case=True) -> dict:
"""Do a fuzzy matching of documents using levenshtein distance.
Parameters
----------
pattern : str
@greatsharma
greatsharma / quickSortRandomPivot.cpp
Created April 29, 2019 10:04
A simple c++ program to sort an array using quick sort algorithm with random pivoting.
/*
Name: Randomized Quick Sort
Author: Gaurav Sharma
Date: 29-04-19 15:34
Description: A simple c++ program to sort an array using quick sort algorithm with random pivoting.
*/
#include <iostream>
#include <conio.h>
#include <time.h>
@greatsharma
greatsharma / mergeSort.cpp
Last active April 29, 2019 12:07
C++ program to sort an array using Merge sort algorithm.
/*
Name: Merge Sort
Author: Gaurav Sharma
Date: 28-04-19 15:23
Description: A simple c++ program to sort an array using Merge sort algorithm.
*/
#include <iostream>
#include <conio.h>
#include <time.h>
@greatsharma
greatsharma / quickSort.cpp
Last active April 29, 2019 09:56
A simple c++ program to sort an array using Quick sort algorithm.
/*
Name: Quick Sort
Author: Gaurav Sharma
Date: 27-04-19 18:01
Description: A simple c++ program to sort an array using Quick sort algorithm.
*/
#include <iostream>
#include <conio.h>
#include <time.h>