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
#!/usr/bin/env bash | |
#------------------------------------------------------------------------------- | |
# | |
# array_contains - returns 0 if array contains the specified value, else 1 | |
# | |
# $1 : term to search for | |
# $2+ : array to inspect | |
# | |
# sources: |
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
#!/usr/bin/env bash | |
#------------------------------------------------------------------------------- | |
# | |
# print_args - easily inspect arguments passed to a bash script | |
# | |
# sources: | |
# https://unix.stackexchange.com/a/332126/183920 | |
# | |
#------------------------------------------------------------------------------- |
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 | |
set | grep "^[A-Z]" | sed -e 's/[[:space:]].*//' -e 's/=.*//' | |
# tested on bash, ksh, tcsh, zsh | |
# Sources: | |
# https://askubuntu.com/a/275972/360539 | |
# https://stackoverflow.com/a/20348145/2925434 | |
# https://www.tutorialspoint.com/unix/unix-regular-expressions.htm |
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
import java.io.BufferedReader; | |
import java.io.FileNotFoundException; | |
import java.io.FileReader; | |
import java.io.IOException; | |
import java.util.ArrayList; | |
import java.util.Arrays; | |
import java.util.Collections; | |
import java.util.List; | |
import java.util.Map; | |
import java.util.function.Function; |
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
/** | |
* Javadoc for filesystem path edge cases. | |
* | |
* <hr style="height:1px;border:0;border-top:1px solid #CCC"> | |
* | |
* <h2><strong>Edge Case 0: Inline Windows Filesystem Paths</strong></h2> | |
* | |
* <p>Here is an inline Windows fs path with backslashes: | |
* <code>"C:\Users\user\file.txt"</code>. You must replace the | |
* {@code '\'} characters with {@code "\"} in the source code, otherwise |
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
import java.sql.Connection; | |
import java.sql.DriverManager; | |
import java.sql.SQLException; | |
import java.sql.Statement; | |
import java.sql.ResultSet; | |
import java.sql.ResultSetMetaData; | |
/** | |
* Example class, showing how to find owner of an embedded Derby database. | |
* |
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
import java.util.AbstractMap.SimpleEntry; | |
import java.util.ArrayList; | |
import java.util.Collection; | |
import java.util.Collections; | |
import java.util.Iterator; | |
import java.util.List; | |
import java.util.Optional; | |
import java.util.stream.Collectors; | |
import java.util.stream.IntStream; |
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
import java.util.AbstractMap.SimpleEntry; | |
import java.util.ArrayList; | |
import java.util.List; | |
import java.util.Map.Entry; | |
public class ParseCLArgs { | |
// try with | |
// $ java ParseCLArgs arg -short anotherArg --long - -- ---toolong |
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
import java.io.BufferedReader; | |
import java.io.File; | |
import java.io.InputStreamReader; | |
import java.io.IOException; | |
import java.nio.file.FileSystems; | |
import java.nio.file.FileVisitResult; | |
import java.nio.file.Files; | |
import java.nio.file.Path; | |
import java.nio.file.PathMatcher; |
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
import java.util.ArrayList; | |
import java.util.List; | |
import java.util.regex.Matcher; | |
import java.util.regex.Pattern; | |
import java.util.stream.Collectors; | |
public class SplitXSV { | |
public static void main (String[] args) { |