This file contains hidden or 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
function checkDate(dateString){ | |
if(!/^\d{4}\/\d{1,2}\/\d{1,2}$/.test(dateString)) | |
return false; | |
var parts = dateString.split("/"); | |
var year = parseInt(parts[0], 10); | |
var month = parseInt(parts[1], 10); | |
var day = parseInt(parts[2], 10); | |
console.log(parts) |
This file contains hidden or 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
try { | |
Process p = Runtime.getRuntime().exec(new String[]{ | |
"/usr/sbin/sendmail", | |
"-t" | |
}); | |
try (OutputStreamWriter os = new OutputStreamWriter(p.getOutputStream(), "UTF8")) { | |
os.write("Content-Type: text/html\n"); | |
os.write("From: [email protected]\n"); | |
os.write("To: [email protected]\n"); | |
os.write("CC: [email protected]\n"); |
This file contains hidden or 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 OsCheck { | |
/** | |
* types of Operating Systems | |
*/ | |
public enum OSType { | |
Windows, MacOS, Linux, Other | |
}; | |
// cached result of OS detection | |
protected static OSType detectedOS; |
This file contains hidden or 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
Map<String, String> map = ... | |
for (Map.Entry<String, String> entry : map.entrySet()) | |
{ | |
System.out.println(entry.getKey() + "/" + entry.getValue()); | |
} |
This file contains hidden or 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
Part of this mapping code has been kindly borrowed from Apache Ant. | |
The mapping matches URLs using the following rules: | |
? matches one character | |
* matches zero or more characters | |
** matches zero or more directories in a path | |
{spring:[a-z]+} matches the regexp [a-z]+ as a path variable named "spring" | |
Examples | |
com/t?st.jsp — matches com/test.jsp but also com/tast.jsp or com/txst.jsp |
This file contains hidden or 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
iptables -A INPUT -p tcp --tcp-flags ALL NONE -j DROP | |
iptables -A INPUT -p tcp ! --syn -m state --state NEW -j DROP | |
iptables -A INPUT -p tcp --tcp-flags ALL ALL -j DROP | |
iptables -A INPUT -i lo -j ACCEPT | |
iptables -A INPUT -p tcp -m tcp --dport 8080 -j ACCEPT | |
iptables -L -n | |
iptables-save | sudo tee /etc/sysconfig/iptables | |
service iptables restart |
This file contains hidden or 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
mvn spring-boot:run -Drun.jvmArguments="-Dspring.profiles.active=design" |
This file contains hidden or 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
GRANT ALL PRIVILEGES ON *.* TO 'USERNAME'@'IP' IDENTIFIED BY 'PASSWORD'; | |
FLUSH PRIVILEGES; | |
exit; |
This file contains hidden or 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
@ExceptionHandler(MethodArgumentNotValidException.class) | |
@ResponseBody | |
public ValidationError handleValidationException(MethodArgumentNotValidExceptionexception) { | |
Set<ValidationError> errors = new HashSet<ValidationError>(); | |
for (ObjectError er : exception.getBindingResult().getAllErrors()) { | |
errors.add(new ValidationError(er.getObjectName(), er.getDefaultMessage())); | |
} | |
return new ValidationErrorResponse(errs); |