All posts tagged #example all posts RSS-feed

Example log4j2.xml (development)

For local development, I like to change some things in my log4j2 configuration. Make lines shorter, e.g. no worker names (just pid) or dates (just times). Prevent all logging to files, just console. Use colors for errors and warnings so they stand out. Filter out specific types of messages, and keep only specific other ones at debug level. Use buffering and async for better performance. So here it is! <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <Configuration monitorInterval="30"> <Appenders> <Console name="Console" target="SYSTEM_OUT" bufferSize="100">... full post»

Java overload + vararg pitfall

If you are using overloads In Java, and one of them uses varargs, then there's a rare pitfall to be aware of. I ran into this a while back. There were two methods, similar to this: public void method( @Nullable Object first, @Nullable String second, @Nullable Integer third, @Nullable BigDecimal fourth, @Nullable Double fifth ) throws Exception { and public void method( @Nonnull Integer... varargs ) throws Exception { Then, someone added a sixth argument to the first method. Simultaneously... full post»

Symmetric encryption in Rust

I'm working on a file encryption utility (endec) in Rust. Encrypting and decrypting doesn't need much code, but it took me several hours of fiddling to arrive at the final version, so I thought I'd share the result. The crates I'm using (for the symmetric encryption part) are: aes for encryption secstr to store keys in memory more safely block-modes for block cipher utils So let's get right down to the code: use ::aes::Aes256; use ::block_modes::Cbc; use ::block_modes::BlockMode; use ::block_modes::block_padding::Iso7816;... full post»