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 that the given String is not null and has a value other than | |
* whitespace. | |
* | |
* {@code | |
* hasValue(null) = false | |
* hasValue("") = false | |
* hasValue(" ") = false | |
* hasValue("bob") = true | |
* hasValue(" bob ") = true |
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.security.MessageDigest; | |
public class HashUtil { | |
/** Change to SHA-256 or MD5 if needed */ | |
private static final String HASHING_ALGORITHM = "MD5"; | |
/** | |
* The usual default character encoding, but hard defining it to avoid | |
* complications. |
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
var DateUtil = { | |
/* Get the date for yesterday in YYYY-MM-DD format */ | |
getYesterdayYMD : function() { | |
var d = new Date(); | |
var m = d.getMonth() + 1; | |
var n = d.getDate() - 1; | |
var ds = d.getFullYear() + "-" + (m< 10? '0' + m : m) + "-" + (n<10 ? '0' + n : n); | |
return ds; | |
}, | |
/* Get the date for today in YYYY-MM-DD format */ |
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 a parameter from the url */ | |
function getVarFromURL(varName){ | |
var url = window.location.href; | |
url = url.substring(url.indexOf('?')); | |
var urlLowerCase = url.toLowerCase(); | |
varName = varName.toLowerCase(); | |
if (urlLowerCase.indexOf(varName + "=") != -1) { | |
var value = url.substring(urlLowerCase.indexOf(varName) + varName.length + 1); | |
if (value.indexOf('&') != -1) { | |
value = value.substring(0, value.indexOf('&')); |
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
/* Truncates value within a specified width and appends with ... */ | |
.truncate { | |
/*width: 100%;*/ /*optionally set width here, but more useful not set */ | |
white-space: nowrap; | |
overflow: hidden; | |
text-overflow: ellipsis; | |
} |
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 javax.annotation.Nonnull; | |
import java.util.Collection; | |
/** | |
* Utility class for setters of collections in objects. | |
* | |
* <pre> | |
* {@code | |
* private Set<String> items = new HashSet<>(); | |
* public void setItems(Collection<String> items) { | |
* CollectionSetter.refill(this.items, items); |
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 final class DateOperations { | |
/** | |
* Gets the Epoch seconds of the given LocalDateTime | |
* @return long of the seconds since the beginning of time (for Java) | |
*/ | |
public static long getLocalSeconds(LocalDateTime localDateTime) { | |
ZoneId zone = ZoneId.systemDefault(); | |
ZonedDateTime zdt = localDateTime.atZone(zone); | |
return zdt.toEpochSecond(); | |
} |