Skip to content

Instantly share code, notes, and snippets.

View bobaikato's full-sized avatar
😏
building Jipo

n乇ᴏ bobaikato

😏
building Jipo
View GitHub Profile
kind: Service
apiVersion: v1
metadata:
name: hostname-service
spec:
# Expose the service on a static port on each node
# so that we can access the service from outside the cluster
type: NodePort
# When the node receives a request on the static port (30163)
static String getStartingPlaceOfTheJourney(List<List<String>> journeysList) {
final int STARTING_POSITION = 0;
final int ENDING_POSITION = 1;
for (int index = 0; index < journeysList.size(); ++index) {
final int nextDistanceIndex = index + ENDING_POSITION;
if (nextDistanceIndex < journeysList.size()) {
final String startingPoint = journeysList.get(index)
.get(STARTING_POSITION);
@bobaikato
bobaikato / Remove_unused_dependencies_Maven.xml
Last active March 13, 2020 12:47
Remove unused dependencies Maven
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
<version>3.1.1</version>
<executions>
<execution>
<id>analyze</id>
<goals>
<goal>analyze-only</goal>
</goals>
<configuration>
final long calendarWeek = 44;
final LocalDate startDate = LocalDate.now()
.with(IsoFields.WEEK_OF_WEEK_BASED_YEAR, calendarWeek)
.with(TemporalAdjusters.previousOrSame(DayOfWeek.MONDAY));
final LocalDate endDate = startDate.plusDays(6);
File dir = new File("<DirectoryPath>");
String[] extensions = new String[] { "json", "java" };
System.out.println("Getting all .json and .java files in " + dir.getCanonicalPath()
+ " including those in subdirectories");
List<File> files = (List<File>) FileUtils.listFiles(dir, extensions, true);
for (File file : files) {
System.out.println("file: " + file.getCanonicalPath());
}
String sentence = "The sly brown Fox jumped over the lazy foX.";
String result = sentence.replaceAll("(?i)fox", "dog");
System.out.println("Input: " + sentence);
System.out.println("Output: " + result);
//Input: The sly brown Fox jumped over the lazy foX.
//Output: The sly brown dog jumped over the lazy dog.
package utility;
import java.util.AbstractList;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors;
@bobaikato
bobaikato / jar-exec-cmd.md
Created July 31, 2019 17:01
Run a maven created jar file using just the command line
<build>
    <plugins>
        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>exec-maven-plugin</artifactId>
            <version>1.2.1</version>
            <configuration>
                <mainClass>package.to.Main.Class</mainClass>
 
import static org.hamcrest.CoreMatchers.*;
import static org.junit.Assert.*;
import org.junit.*;
import org.junit.rules.ExpectedException;
import org.junit.runner.RunWith;
import junitparams.JUnitParamsRunner;
import junitparams.Parameters;
@bobaikato
bobaikato / CustomString.java
Last active April 14, 2019 09:54
Custom String Concatenation.
import java.util.Arrays;
class CustomString {
private static String concatenate(String... inputs) {
var stringSize = Arrays.stream(inputs).mapToInt(input -> input.toCharArray().length).sum();
var newInputCharArray = new char[stringSize];
int index = 0;