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 / 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 / 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 / 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 / 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 / toString Generator
Last active June 20, 2022 08:53
Java toString() generator for IntelliJ IDEA that generates JSON
public java.lang.String toString() {
#if ( $members.size() > 0 )
#set ( $i = 0 )
return "{\"_class\":\"$classname\", " +
#foreach( $member in $members )
#set ( $i = $i + 1 )
#if ( $i == $members.size() )
#set ( $postfix = "+" )
#else
#set ( $postfix = "+ "", "" + " )