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 / gist:2bcb472b07e5d6cc4d2df51d4d511bd7
Created February 27, 2020 10:50
Notes on installing GraalVM on MacOS for native-image generation
Download Community Ed. GraalVM from https://github.com/graalvm/graalvm-ce-builds/releases
Unpack.
# sudo mv graalvm-ce-19.0.0 /Library/Java/JavaVirtualMachines
sudo mv graalvm-ce-java11-20.0.0 /Library/Java/JavaVirtualMachines
Verify: /usr/libexec/java_home -V
vi ~/.zprofile
--- Add: ---
export JAVA_HOME=$(/usr/libexec/java_home -v 11)
@jenslohmann
jenslohmann / gist:e31bf324a60d1a3961bd7cbcfaf8547e
Created August 22, 2019 12:43
Poor man's web server for MacOS
while true; do printf 'HTTP/1.1 200 OK\n\n' | nc -4 -k -l 23456; done
@jenslohmann
jenslohmann / PoorMansInjector.java
Created July 4, 2019 19:13
Helper class for injecting objects when not in a Dependency Injection context - typically when unit testing.
package dk.jlo.util;
import java.lang.reflect.Field;
/**
* Injects an object into a (private) field in a bean; primarily for poor man's injection for unit testing when not running in a Dependency Injection environment.<p>
* Travels through super classes if necessary.<p>
* Usage:
* <pre>
#!/bin/sh
echo "\033]0;${1}\007\c"
@jenslohmann
jenslohmann / gist:2328aa57dda9460ab9522d03413257ac
Created November 23, 2018 13:52
XPath to check for xsi:nil - it's dead simple
/@xsi:nil = 'true'
@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 / 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 / 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 / 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 / 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>
...