Skip to content

Instantly share code, notes, and snippets.

Avatar

Jens A. Lohmann jenslohmann

  • Copenhagen, Denmark
View GitHub Profile
@jenslohmann
jenslohmann / gist:2bcb472b07e5d6cc4d2df51d4d511bd7
Created Feb 27, 2020
Notes on installing GraalVM on MacOS for native-image generation
View gist:2bcb472b07e5d6cc4d2df51d4d511bd7
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)
View gist:e31bf324a60d1a3961bd7cbcfaf8547e
while true; do printf 'HTTP/1.1 200 OK\n\n' | nc -4 -k -l 23456; done
@jenslohmann
jenslohmann / PoorMansInjector.java
Created Jul 4, 2019
Helper class for injecting objects when not in a Dependency Injection context - typically when unit testing.
View PoorMansInjector.java
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>
View setTabTitle
#!/bin/sh
echo "\033]0;${1}\007\c"
@jenslohmann
jenslohmann / javameminfo
Last active Nov 6, 2018
Poor man's meminfo for the single JBoss process on the server
View javameminfo
#!/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 Dec 5, 2017
Poor man's password generator
View passswordgen
#!/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 Nov 2, 2016
How to create a datasource using the wildfly CLI that will also reconnect after a network failure
View Add datasource that will reconnect after 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 Nov 3, 2015
Wildfly 9.0 startup scripts for Debian 8.2 (systemd) inspired by files from wildfly 10 distribution
View 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 Aug 29, 2015
How to move focus to a field the angular way
View angular-focus-example.html
...
<textarea focus-on="IWantFocusWhenButtonClicked"></textarea>
<button ng-click="doFocus()">Focus</button>
...