Skip to content

Instantly share code, notes, and snippets.

View amitsaurav's full-sized avatar

Amit Saurav amitsaurav

View GitHub Profile
@amitsaurav
amitsaurav / getPreviousDate.sh
Last active August 29, 2015 13:56
Get Previous Date in Bash
#!/bin/sh
year=`date +%Y`
month=`date +%m`
day=`date +%d`
isLeap=0
if [ $((year%400)) -eq 0 ]; then
isLeap=1
elif [ $((year%100)) -eq 0 ]; then
@amitsaurav
amitsaurav / boa.js
Created January 23, 2014 23:23
JQuery script to remove all non-parking/non-travel transactions from Bank Of America credit card transactions view.
jQuery("#transactions tbody tr").each(function() {
var row = jQuery(this);
row.find('td:last').remove();
if(row.text().indexOf("CHEVRON") === -1 && row.text().indexOf("U-PARK") === -1 && row.text().indexOf("GOOD2GO") === -1) {
row.remove();
}
});
jQuery("#transactions tfoot").remove();
@amitsaurav
amitsaurav / Palindrome.java
Last active November 22, 2016 19:00
Code to generate "Palindrome Cover".
import java.io.*;
import java.util.*;
class Palindrome {
public static void main(String[] args) {
List<String> palindromes = Arrays.asList("gabbag", "baggab");
System.out.println(getShortestCover(palindromes));
}
@amitsaurav
amitsaurav / ListOfLists.java
Created November 23, 2016 19:33
List of Lists iterator.
package collections;
import java.util.Arrays;
import java.util.List;
/**
* Created by amit.saurav on 11/23/16.
*/
public class ListOfLists <T> {
private final List<List<T>> listOfLists;
@amitsaurav
amitsaurav / MinimalBalancedTree.java
Last active November 28, 2016 12:38
A balanced tree with minimal rebalances.
package trees;
import java.util.LinkedList;
import java.util.Queue;
/**
* There are bugs around odd and even array length and last element being not added but this is the
* general structure of the code.
*
* @author amitsaurav