Skip to content

Instantly share code, notes, and snippets.

View jenslohmann's full-sized avatar

Jens A. Lohmann jenslohmann

  • Copenhagen, Denmark
View GitHub Profile
@jenslohmann
jenslohmann / JBossCrippleForXHRs.patch
Last active August 29, 2015 14:08
Patch for JBoss 6.1.0.Final (or rather its JBossWeb 3.0.0.CR2) to return a crippled WWW-Authenticate header for XMLHttpRequests
Index: org/apache/catalina/authenticator/BasicAuthenticator.java
<+>UTF-8
===================================================================
--- org/apache/catalina/authenticator/BasicAuthenticator.java (revision )
+++ org/apache/catalina/authenticator/BasicAuthenticator.java (revision )
@@ -191,6 +191,11 @@
request.getResponse().getCoyoteResponse().getMimeHeaders()
.addValue(AUTHENTICATE_BYTES, 0, AUTHENTICATE_BYTES.length);
CharChunk authenticateCC = authenticate.getCharChunk();
+ MessageBytes xRequestedWith =
@jenslohmann
jenslohmann / Clone repo on client
Created June 8, 2015 13:19
Git admin for simple newbies
git clone ssh://login@git.server/repo/blah.git
cd blah
git config user.name "Jens Lohmann"
git config user.email "jens.lohmann@mailserver.dk"
@jenslohmann
jenslohmann / PreserveEXIFdataWhenResizing.java
Last active August 29, 2015 14:23
Preserve EXIF data in jpeg when resizing
import org.apache.sanselan.ImageReadException;
import org.apache.sanselan.ImageWriteException;
import org.apache.sanselan.common.IImageMetadata;
import org.apache.sanselan.formats.jpeg.JpegImageMetadata;
import org.apache.sanselan.formats.jpeg.JpegImageParser;
import org.apache.sanselan.formats.jpeg.exifRewrite.ExifRewriter;
import org.apache.sanselan.formats.tiff.TiffImageMetadata;
public SomeClass {
public static TiffImageMetadata readExifMetadata(byte[] jpegData) throws ImageReadException, IOException {
@jenslohmann
jenslohmann / angular-focus-example.html
Last active August 29, 2015 14:27
How to move focus to a field the angular way
...
<textarea focus-on="IWantFocusWhenButtonClicked"></textarea>
<button ng-click="doFocus()">Focus</button>
...
@jenslohmann
jenslohmann / Wildfly 9.0 startup scripts for Debian 8.2 (systemd) inspired by files from wildfly 10 distribution
Last active November 3, 2015 12:30
Wildfly 9.0 startup scripts for Debian 8.2 (systemd) inspired by files from wildfly 10 distribution
groupadd -r wildfly
useradd -r -g wildfly -d /opt/wildfly -s /sbin/nologin wildfly
== Install WildFly
tar xvzf wildfly-9.0.1.Final.tar.gz -C /opt
ln -s /opt/wildfly-9.0.1.Final /opt/wildfly
chown -R wildfly:wildfly /opt/wildfly
== Configure systemd
@jenslohmann
jenslohmann / Add datasource that will reconnect after network failure
Created November 2, 2016 07:48
How to create a datasource using the wildfly CLI that will also reconnect after a network failure
data-source add --jndi-name=java:/<blah>DS --name=<blah>Pool --connection-url=jdbc:oracle:thin:@//<db-hostname>:1521/<SID/db.service> --driver-name=oracle --driver-class=oracle.jdbc.driver.OracleDriver --user-name=<db-user> --password=<db-user-password> --check-valid-connection-sql=select\ 1\ from\ dual --validate-on-match=false --background-validation=true --background-validation-millis=20000
@jenslohmann
jenslohmann / passswordgen
Created December 5, 2017 09:27
Poor man's password generator
#!/bin/bash
while pwd=$(openssl rand -base64 9); [[ ${pwd} == *[[:punct:]]* ]]; do :; done; echo ${pwd}
@jenslohmann
jenslohmann / certifcateGeneration
Last active June 19, 2018 09:53
Certificate generation on MacOSX
This might be helpful when generating signed (not strictly self-signed) certificates for use in development on MacOSX.
Testing (against server using the generated server cert):
curl --trace - -3 --insecure --cert clientcert.p12:changeit --get https://localhost:443/
Troubleshooting:
- Check the keychain (Cmd-Space "Keychain Access") for old entries. Delete them :-)
- "-3" avoids some MacOSX curl quirkiness.
- "--insecure" seems to be necessary for MacOSX curl. If you find a way to use "--cacert cacert.pem" instead then tell me :-)
@jenslohmann
jenslohmann / javameminfo
Last active November 6, 2018 14:04
Poor man's meminfo for the single JBoss process on the server
#!/bin/bash
if [ $(ps -ef|grep -E "java.*jboss"|grep -v grep|wc -l) -ne 1 ] ; then
echo "Too many (or no) java processes!"
else
jmap -heap $(ps -ef|grep -E "java.*jboss"|grep -v grep|tr -s " "|cut -d\ -f2)
fi
@jenslohmann
jenslohmann / gist:2328aa57dda9460ab9522d03413257ac
Created November 23, 2018 13:52
XPath to check for xsi:nil - it's dead simple
/@xsi:nil = 'true'