Skip to content

Instantly share code, notes, and snippets.

Brett C. bmchild

Block or report user

Report or block bmchild

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@bmchild
bmchild / MyReflectionTestUtils.java
Created Jul 11, 2012
Use reflection to compare getters on two objects
View MyReflectionTestUtils.java
/**
*
*/
package com.mypackage.utilities;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.List;
import org.apache.commons.lang.builder.EqualsBuilder;
@bmchild
bmchild / NotEquals.java
Created Sep 14, 2012
NotEquals Validator
View NotEquals.java
/**
*
*/
package com.bmchild.validation.constraints;
import static java.lang.annotation.ElementType.ANNOTATION_TYPE;
import static java.lang.annotation.ElementType.CONSTRUCTOR;
import static java.lang.annotation.ElementType.FIELD;
import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.ElementType.PARAMETER;
@bmchild
bmchild / 1-generated.xml
Last active Jun 3, 2019
Dom4J example of creating an XML document from xpath and value information. Dependencies: Dom4J, Jaxen, Apache Commons, Log4J
View 1-generated.xml
<?xml version="1.0" encoding="ISO-8859-1"?>
<root>
<data>
<discharge_status>ACTIVE</discharge_status>
<suspension_rec>
<start>0815</start>
<end>0115</end>
</suspension_rec>
<suspension_rec>
View CasAuthenticationUtils.java
package com.bmchild.stack.commons.utilities.security;
import java.io.IOException;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.HttpStatus;
import org.apache.commons.httpclient.NameValuePair;
@bmchild
bmchild / Controller.java
Last active Sep 18, 2018
Example of how to wire up a chunked response and how to consume it via angular.
View Controller.java
@RequestMapping(value = "/runJobAndGetLogs", method = RequestMethod.GET)
public ResponseEntity<StreamingResponseBody> runJobAndGetLogs() throws IOException {
final InputStream inputStream = someService.runJobAndGetReportProgress();
StreamingResponseBody body = StreamingResponseBody body = (outputStream) -> {
try (BufferedInputStream br = new BufferedInputStream(inputStream)) {
// just copying to the outputstream
byte[] contents = new byte[1024];
int bytesRead = 0;
while ((bytesRead = br.read(contents)) != -1) {
@bmchild
bmchild / AllFieldsOrNone .java
Created Sep 26, 2012
AllFieldsOrNone SpringMVC 3 JSR-303 Validator
View AllFieldsOrNone .java
/**
*
*/
package com.bmchild.validation.constraints;
import static java.lang.annotation.ElementType.ANNOTATION_TYPE;
import static java.lang.annotation.ElementType.CONSTRUCTOR;
import static java.lang.annotation.ElementType.FIELD;
import static java.lang.annotation.ElementType.TYPE;
import static java.lang.annotation.ElementType.METHOD;
@bmchild
bmchild / CustomMethodSecurityExpressionHandler.java
Created Jan 19, 2012
Custom regex lookup access Expression with Spring Security 3.1. The lookup, hasRegexRole, is available on the JSP or on the method.
View CustomMethodSecurityExpressionHandler.java
package com.bmchild.security.access.expression;
import org.aopalliance.intercept.MethodInvocation;
import org.apache.log4j.Logger;
import org.springframework.security.access.expression.SecurityExpressionRoot;
import org.springframework.security.access.expression.method.DefaultMethodSecurityExpressionHandler;
import org.springframework.security.core.Authentication;
/**
* @author bchild
View XMLService.java
/**
*
*/
package com.bmchild.service.xml;
import java.io.IOException;
import java.io.InputStream;
import org.dom4j.Document;
import org.dom4j.Node;
@bmchild
bmchild / CasLogin.java
Created May 2, 2014
Simple CAS Java Rest Client
View CasLogin.java
package com.bmchild.pocrestclient;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.logging.Logger;
@bmchild
bmchild / .bash_profile
Created Jan 3, 2017
function to zip text + encrypt, 2 params (text to encrypt, filename w/o extension). Add to .bash_profile
View .bash_profile
#function to zip text + encrypt, 2 params (text to encrypt, filename w/o extension)
function zipe() {
echo "$1" > $2.txt && zip -e $2.zip $2.txt && rm $2.txt
}
You can’t perform that action at this time.