Skip to content

Instantly share code, notes, and snippets.

View avijitmondal's full-sized avatar

Avijit avijitmondal

View GitHub Profile
//export PS1="\u@\h:\W \$ "
//export PS1="\[\e[30;46m\]\u@\h:\W \\$ \[\e[0m\]"
[[ -s "/Users/dwightk/.rvm/scripts/rvm" ]] && source "/Users/dwightk/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*
function parse_git_branch {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'
}
export PS1="🍔 \[\033[01;35m\]\u@\h:\[\033[01;34m\]\$(parse_git_branch) \[\033[01;32m\]\w \[\033[01;34m\]>\[\e[0m\] "
alias ll='ls -lG'
@avijitmondal
avijitmondal / terminal_commands.sh
Created February 25, 2021 13:48
Ubuntu terminal cool commands
sudo apt-get install cowsay
sudo apt-get install fortune
sudo apt-get install lolcat
sudo apt-get install sl
sudo apt-get install figlet
sudo apt-get install toilet
sudo apt-get install cmatrix
@avijitmondal
avijitmondal / JavaConsoleColorString
Created August 9, 2018 12:59
Coloring system out in console using java programming
public class ConsoleLog {
public static final String RESET = "\u001B[0m";
public static final String BLACK = "\u001B[30m";
public static final String RED = "\u001B[31m";
public static final String GREEN = "\u001B[32m";
public static final String YELLOW = "\u001B[33m";
public static final String BLUE = "\u001B[34m";
public static final String PURPLE = "\u001B[35m";
public static final String CYAN = "\u001B[36m";
@avijitmondal
avijitmondal / github-download-release-asset.sh
Last active July 5, 2018 10:23 — forked from metral/gh-dl-release
Download assets from private Github releases
#!/usr/bin/env bash
#
# gh-dl-release! It works!
#
# This script downloads an asset from latest or specific Github release of a
# private repo. Feel free to extract more of the variables into command line
# parameters.
#
# PREREQUISITES
#
@avijitmondal
avijitmondal / github-upload-release-asset.sh
Last active July 5, 2018 10:22 — forked from relaxdiego/upload-github-release-asset.sh
Script to upload a release asset using the GitHub API v3.
#!/usr/bin/env bash
#
# Author: Stefan Buck
# https://gist.github.com/stefanbuck/ce788fee19ab6eb0b4447a85fc99f447
#
#
# This script accepts the following parameters:
#
# * owner
# * repo
@avijitmondal
avijitmondal / Longest common substring
Created March 29, 2018 03:31
Given 2 string str1 and str2 we have to find the length of the longest common substring between them. Examples Input : X = "abcdxyz", y = "xyzabcd" Output : 4 The longest common substring is "abcd" and is of length 4. Input : X = "zxabcdezy", y = "yzabcdezx" Output : 6 The longest common substring is "abcdez" and is of length 6.
public int getLongestCommonSubstring(String str1, String str2) {
int arr[][] = new int[str2.length() + 1][str1.length() + 1];
int max = Integer.MIN_VALUE;
for (int i = 1; i <= str2.length(); i++) {
for (int j = 1; j <= str1.length(); j++) {
if (str1.charAt(j - 1) == str2.charAt(i - 1)) {
arr[i][j] = arr[i - 1][j - 1] + 1;
if (arr[i][j] > max)
max = arr[i][j];
} else
@avijitmondal
avijitmondal / Longest Common Subsequence
Created March 28, 2018 17:00
Given with the two strings we have to find the longest common sub-sequence present in both of them
public class LCS {
public static void main(String[] args) {
// TODO Auto-generated method stub
String str1 = "AGGTAB";
String str2 = "GXTXAYB";
LCS obj = new LCS();
System.out.println(obj.lcs(str1, str2, str1.length(), str2.length()));
System.out.println(obj.lcs2(str1, str2));
}
//Recursive function
@avijitmondal
avijitmondal / Minimum Comparison to convert a string into another
Created March 28, 2018 16:43
Given two string str1 and str2 then how many minimum number of operations can be performed on the str1 that it gets converted to str2
public class EditDistance {
public static void main(String[] args) {
// TODO Auto-generated method stub
String str1 = "march";
String str2 = "cart";
EditDistance ed = new EditDistance();
System.out.println(ed.getMinConversions(str1, str2));
}
public int getMinConversions(String str1, String str2) {
int dp[][] = new int[str1.length() + 1][str2.length() + 1];
import java.util.*;
import java.lang.*;
import java.io.*;
class ShortestPath {
static final int V = 9;
int minDistance(int dist[], Boolean sptSet[]) {
int min = Integer.MAX_VALUE, min_index = -1;
for (int v = 0; v < V; v++)
if (sptSet[v] == false && dist[v] <= min) {
min = dist[v];