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
# Get the latest file that's added in the folder | |
LATEST_FILE=`ls -tp | grep -v /$ | head -1` | |
echo $LATEST_FILE | |
# Upload the new file to your Amazon S3 Bucket. | |
# In this example, the "jonbonso-media" S3 bucket has an associated CloudFront distribution | |
# with a custom domain of "media.jonbonso.com" | |
aws s3 cp $LATEST_FILE s3://jonbonso-media |
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
#!/bin/bash | |
for i in {1..250} | |
do | |
curl -o /dev/null \ | |
-w "%{time_starttransfer}\n" \ | |
https://google.com >> prod.txt | |
done |
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
MY_IP=`curl checkip.amazonaws.com` | |
echo $MY_IP | |
aws ec2 authorize-security-group-ingress \ | |
--group-id sg-01298cde13c80c75 \ | |
--protocol tcp \ | |
--port 22 \ | |
--cidr $MY_IP/32 \ | |
--region us-east-1 |
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
class FindTheLengthOfLongestSubstringUsingWhileLoop { | |
public int lengthOfLongestSubstring(String s) { | |
/** | |
Examples: | |
#1 - | |
eabcdabcbb = 4 | |
"abcd" is the longest substring | |
4 is the length of "abcd" |
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
class FindTheLengthOfLongestSubstring { | |
public int lengthOfLongestSubstring(String s) { | |
/** | |
Examples: | |
#1 - | |
eabcdabcbb = 4 | |
"abcd" is the longest substring | |
4 is the length of "abcd" |
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 Palindrome | |
{ | |
public static void main(String[] args) { | |
String input = "ababa"; | |
String input1 = "mom"; | |
String input2 = "nono"; | |
String input3 = "A man, a plan, a canal: Panama!"; |
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
/** | |
This tracks the Elapsed Time for the 2 Solutions for the Classic Two Sum Problem | |
You will discover how immensely better an (O)n solution is (twoSumOptimized) | |
than a brute force (O)n^2 solution (twoSumBruteForce) by checking the start and end | |
times of both methods | |
*/ | |
import java.util.Map; |
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
/** | |
* | |
Two Sum Solution #2 - Using a HashMap and iterates the array in a single pass approach | |
Author: Jon Bonso | |
Goal: Get the two indices from the array that sums up to the value of the given target | |
MATH THEORY: |
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
/** | |
* | |
Two Sum Solution #1 - Brute Force Approach | |
Approach | |
- Brute force approach by using a nested loop | |
- Create the two loops to process the array, wherein the second loop is one step ahead of the previous loop and traversing the array elements in a quadratic manner | |
- The first loop uses the variable i to hold the first index while the second loop uses the variable j to hold the latter one. | |
- Compare the values of the i and j indices. If they are the same, return the indices as output |
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 Odd or Even Coding Example | |
Author: Jon Bonso | |
Demo Link: https://www.online-java.com/BYJCIjwhpg | |
Mathematical Theory: | |
- Parity is the property of an integer which determines if it is even or odd. | |
- An even number is an integer that can be divided exactly by 2 is an even number. |
NewerOlder