Skip to content

Instantly share code, notes, and snippets.

View jsbonso's full-sized avatar
🎯
portal.tutorialsdojo.com

Jon Bonso jsbonso

🎯
portal.tutorialsdojo.com
View GitHub Profile
@jsbonso
jsbonso / Java Reverse a String.java
Created October 14, 2017 05:01
[Java] Reverse a String
/**
* 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();
@jsbonso
jsbonso / Simple Recursive Method.java
Created October 14, 2017 08:31
Simple Recursive Method
/**
* 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;
@jsbonso
jsbonso / Java Number Primality Check.java
Last active October 14, 2017 22:56
Java: Check if Number is a Prime Number
/**
* 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.
*
@jsbonso
jsbonso / java blackjack implementation.java
Last active October 14, 2017 23:27
Java Blackjack Checker
/**
* 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) {
@jsbonso
jsbonso / PalindromeExample.java
Last active October 15, 2017 01:14
[Java] Palindrome Examples
/**
* 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());
}
@jsbonso
jsbonso / gist:9536da07adbfed4cbdef1b2512f4c319
Created October 18, 2017 04:53
Available Stock API that you can use
/**
* https://www.bloomberg.com/markets/watchlist/recent-ticker/GOOG:US
* https://www.bloomberg.com/markets/chart/data/1D/GOOG:US
*/
@jsbonso
jsbonso / Primer to GraphQL
Created October 19, 2017 05:30
Primer to GraphQL
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
@jsbonso
jsbonso / Docker CheatSheet.txt
Last active October 19, 2017 05:33
Docker Commands CheatSheet
-- 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.
@jsbonso
jsbonso / Arithmetic Slice.js
Created October 27, 2017 08:46
Arithmetic Slice
/*
* 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
@jsbonso
jsbonso / Java ForEach Lambda Example.java
Created October 15, 2017 00:01
Java ForEach Lambda Example
/**
* 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};