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
/** | |
* Reverses a string using StringBuilder. | |
* You can replace it with a StringBuffer as well, | |
* but in this case, you don't need it to be thread-safe, | |
* hence, a StringBuilder will do. | |
* @param input | |
* @return | |
*/ | |
static String reverseString(String input) { | |
return (new StringBuilder(input)).reverse().toString(); |
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
/** | |
* A simple recursive method that outputs numbers from 1 - 10 | |
* @param number of times the method will recurse / repeat | |
* @return | |
*/ | |
static int recursiveMethod(int num) { | |
// An important line, which defines the case when will the recursion ends | |
if (num == 0) | |
return num; | |
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
/** | |
* Checks the primality of the given number. | |
* Prime numbers can be used in password encryptions | |
* and cryptography. | |
* | |
* Basically, a prime number is: | |
* 1. A whole number which is greater than 1 | |
* 2. And can only be divided evenly by 1 | |
* and the number itself. | |
* |
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
/** | |
* Simple blackjack method that: | |
* | |
* 1. Returns the input which is the nearest to number 21 | |
* 2. Returns 0 if both numbers are over 21 | |
* @author Jon Bonso | |
* @param a | |
* @param b | |
*/ | |
static int blackjack(int a, int b) { |
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
/** | |
* Check if the given input is a Palindrome | |
* using a StringBuilder. | |
* @author Jon Bonso | |
* @param input | |
* @return boolean | |
*/ | |
private static boolean isPalindrome(String input) { | |
return input.equals(new StringBuilder(input).reverse().toString()); | |
} |
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
/** | |
* https://www.bloomberg.com/markets/watchlist/recent-ticker/GOOG:US | |
* https://www.bloomberg.com/markets/chart/data/1D/GOOG:US | |
*/ |
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
The What, When and Why of GraphQL | |
In our previous lecture, we had a good introduction of what GraphQL is | |
by looking at the common issues of a RESTful API, and how GraphQL solves | |
and improves | |
Those certain issues. | |
This time, we will dive deeper on what GraphQL is, | |
the story on how it came to be |
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
-- Show all images | |
docker images -a | |
-- Show all containers | |
docker volume ls | |
-- Removes dangling/unused container | |
docker volume prune | |
-- Basically similar with (docker volume prune) command. |
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
/* | |
* Returns the number of arithmetic slices in | |
* the given number array. | |
* | |
* Examples: | |
* [-1, 1, 3, 3, 3, 2, 1, 0] = 5 | |
* | |
* A sequence is an Arithmetic if: | |
* 1. It consists of 3 elements | |
* 2. The difference between any two consecutive |
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
/** | |
* Example of Java's Stream API - ForEach | |
* @author jonbonso | |
* @param args | |
*/ | |
public static void main(String... args) { | |
System.out.println("Iterate using the traditional for loop..."); | |
int[] numArray = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; | |
OlderNewer