Skip to content

Instantly share code, notes, and snippets.

@kevinhooke
kevinhooke / gist:d0a5b0dda5ebfac74808
Created September 26, 2015 00:25
Oracle sql to_date
to_date('25-SEP-2015 10:42:00', 'DD-MON-YYYY HH:MI:SS')
@kevinhooke
kevinhooke / gist:7031281892b3baf5b6c6
Created October 2, 2015 20:07
scp file (e.g. MongoDB export file) from OpenShift
rhc scp your-appname download . app-root/data/export-filename.json
@kevinhooke
kevinhooke / gist:0edc43560667cf718355
Last active October 6, 2015 20:32
Export from MongoDB on OpenShift
#$OPENSHIFT_NOSQL_DB_PORT was changed on OpenShift at some point where NOSQL is now the db type, like MONGODB
#so for MongoDB use $OPENSHIFT_MONGODB_DB_PORT
mongoexport --host $OPENSHIFT_NOSQL_DB_HOST--port $OPENSHIFT_NOSQL_DB_PORT --authenticationDatabase admin --username admin --password yourpassword --db your-app-name --collection your-collection-name --out export-filename.json
"partial/ajax".equals(httpRequest.getHeader("Faces-Request")
@kevinhooke
kevinhooke / gist:efa25cd3afd627fb7f97
Created October 17, 2015 00:11
Write HTTP Redirect for a JSF AJAX Partial Request
httpResponse.setContentType("text/xml");
httpResponse.getWriter()
.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>")
.printf("<partial-response><redirect url=\"%s\"></redirect></partial-response>", "/the/url");
#per post: http://stackoverflow.com/questions/19512749/how-to-capture-soap-messages-from-a-tomcat-java-app-to-an-external-server
-Dhttps.proxyHost=127.0.0.1 -Dhttps.proxyPort=8888 -DproxySet=true -DproxyHost=127.0.0.1 -DproxyPort=8888
@kevinhooke
kevinhooke / gist:cfd0193fa18f6d5fb797
Created December 9, 2015 01:42
Jersey client api : get String representation of returned Response
response.readEntity(String.class);
@kevinhooke
kevinhooke / gist:5c0a48c57afe4dba6919
Created December 13, 2015 22:55
bash script - find files matching filename pattern, search first line for matching pattern
#!/bin/bash
for f in `find -E . -regex ".*ext1|.*ext2|.*ext3"`
do
line=$(head -n 1 $f)
if [[ $line =~ TextAtStartOfLine:[[:space:]]*([[:digit:]]+) ]]; then
echo "${BASH_REMATCH[0]}" # print whole match
echo "${BASH_REMATCH[1]}" # print 1st group match
fi
done
@kevinhooke
kevinhooke / gist:fc1a6a49547d55ff9f44
Created December 13, 2015 22:57
bash script - find files matching pattern, grep file content for pattern, pipe results to file
#!/bin/bash
for f in $(find -E . -regex ".*ext1|.*ext2|.*ext3")
do
echo $f $'\n' $(egrep -o 'TextAtStartOfLine:[[:space:]]*[[:digit:]]+' $f) $'\n' >> report"$(date)".txt
done
@kevinhooke
kevinhooke / gist:e1384f8bfe77bb2970b4
Created December 16, 2015 23:31
Jackson Jersey mapping - exclude any unknown properties
@JsonIgnoreProperties(ignoreUnknown = true)