This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// We can use stl container list as a double | |
// ended queue to store the cache keys, with | |
// the descending time of reference from front | |
// to back and a set container to check presence | |
// of a key. But to fetch the address of the key | |
// in the list using find(), it takes O(N) time. | |
// This can be optimized by storing a reference | |
// (iterator) to each key in a hash map. | |
#include <bits/stdc++.h> | |
using namespace std; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Below are the Big O performance of common functions of different Java Collections. | |
List | Add | Remove | Get | Contains | Next | Data Structure | |
---------------------|------|--------|------|----------|------|--------------- | |
ArrayList | O(1) | O(n) | O(1) | O(n) | O(1) | Array | |
LinkedList | O(1) | O(1) | O(n) | O(n) | O(1) | Linked List | |
CopyOnWriteArrayList | O(n) | O(n) | O(1) | O(n) | O(1) | Array |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Version implements Comparable<Version> { | |
@NonNull | |
public final int[] numbers; | |
public Version(@NonNull String version) { | |
final String split[] = version.split("\\-")[0].split("\\."); | |
numbers = new int[split.length]; | |
for (int i = 0; i < split.length; i++) { | |
numbers[i] = Integer.valueOf(split[i]); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Comparator vs Comparable |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!groovy | |
import groovy.json.JsonOutput | |
import groovy.json.JsonSlurper | |
/* | |
Please make sure to add the following environment variables: | |
HEROKU_PREVIEW=<your heroku preview app> | |
HEROKU_PREPRODUCTION=<your heroku pre-production app> | |
HEROKU_PRODUCTION=<your heroku production app> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
node { | |
echo "=======================================" | |
echo "JENKINS_HOME = ${env.JENKINS_HOME}" | |
echo "JOB_NAME = ${env.JOB_NAME}" | |
echo "REPO_GIT = " + REPO_GIT | |
echo "DEFAULT_GIT_BRANCH = "+ DEFAULT_GIT_BRANCH | |
echo "SONAR_SERVER = "+ SONAR_SERVER | |
echo "=======================================" | |
def sonarInstance=hudson.plugins.sonar.SonarInstallation.get(SONAR_SERVER).name; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1xx-Informal | |
100-Continue | |
2xx-Success | |
200-Ok | |
201-Created | |
202-Accepted | |
204-No-Content | |
3xx-Redirection | |
304-Not Modified | |
4xx-Client Error |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DELIMITER $$ | |
CREATE PROCEDURE GetDeliveryStatus( | |
IN pOrderNumber INT, | |
OUT pDeliveryStatus VARCHAR(100) | |
) | |
BEGIN | |
DECLARE waitingDay INT DEFAULT 0; | |
SELECT | |
DATEDIFF(requiredDate, shippedDate) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DELIMITER $$ | |
CREATE PROCEDURE GetCustomerLevel( | |
IN pCustomerNumber INT, | |
OUT pCustomerLevel VARCHAR(20)) | |
BEGIN | |
DECLARE credit DECIMAL(10,2) DEFAULT 0; | |
SELECT creditLimit | |
INTO credit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE PROCEDURE `GetCityCountByName`(IN cityName varchar(255), OUT total INT) | |
BEGIN | |
select COUNT(*) into total from user where city=cityName; | |
END | |
//call test_db.GetCityCountByName('Belagavi', @total); | |
//select @total; |
NewerOlder