Skip to content

Instantly share code, notes, and snippets.


Block or report user

Report or block henrik242

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
if [ $# -lt 3 ]; then
echo "Usage: maven-deploy-file groupId artifactId version [packaging] [repository]"
exit 1
henrik242 /
Created Dec 22, 2011
Disable validation of SSL certificates in Java
public static void disableCertificateValidation() {
// Create a trust manager that does not validate certificate chains
TrustManager[] trustAllCerts = new TrustManager[] {
new X509TrustManager() {
public X509Certificate[] getAcceptedIssuers() {
return new X509Certificate[0];
public void checkClientTrusted(X509Certificate[] certs, String authType) {}
public void checkServerTrusted(X509Certificate[] certs, String authType) {}
henrik242 /
Created Feb 17, 2012
Productivity improving firewall script for MacOSX / BSD
## Requires pwgen, wc, sed, host, ipfw, sudo
henrik242 /
Last active Dec 17, 2015
Checks for upcoming expiry of SSL certificates, e.g. HTTPS or LDAPS. Useful for cron jobs and server monitoring.
EXPIRE=$(openssl s_client -connect $SERVER 2>/dev/null </dev/null | openssl x509 -noout -enddate | cut -d= -f2)
DAYS=$((( $(date --date "${EXPIRE}" +%s) - $(date +%s) ) / 86400));
[ $DAYS -lt $WARNDAYS ] && echo "WARNING: SSL certificate for $SERVER expires in $DAYS days"
henrik242 / commit-msg
Last active Mar 30, 2016
Git hook to automatically create JIRA issues if not present in commit message
View commit-msg
#!/usr/bin/env bash
# How to install:
# cp commit-msg your-project/.git/hooks/
# chmod 755 your-project/.git/hooks/commit-msg
# Then update the USER, PASS, PROJECT and JIRAURL variables in your-project/.git/hooks/commit-msg
henrik242 /
Last active Apr 19, 2016
A little script to monitor my network connection
# Add to crontab, e.g.:
# * * * * * $HOME/cron/
henrik242 / groovy
Created Aug 3, 2016
Poor man's /usr/bin/groovy
View groovy
#!/usr/bin/env bash
# poor man's /usr/bin/groovy :)
if test -x "$(which java)"; then
JAVAEXEC="$(which java)"
elif test -x "$JAVA_HOME/bin/java"; then
echo "ERROR: Could not find java binary"
henrik242 /
Last active Mar 2, 2017
HTTP POST and GET in plain Java
import java.util.Scanner;
import static java.nio.charset.StandardCharsets.UTF_8;
public class HttpStuff {
public static void main(String[] args) throws IOException {
System.out.println(post("", "foo=bar&baz=moo"));
henrik242 / Target monitor selector for
Last active Sep 26, 2017
Target monitor selector for XBMC
View Target monitor selector for

Target monitor selector for XBMC

I have a TV and a projector connected to my Mac Mini media center, and can choose either screen by using these scripts.

The scripts overwrite advancedsettings.xml in XBMC's userdata folder. I got the required data by configuring XBMC for each target screen, and diffing the resulting guisettings.xml files afterwards.

  • xbmc-for-tv.command

    My Samsung 1080p LED TV needs a -250 ms audio delay, and is the main display. It's hooked up to the Mini DisplayPort output.

henrik242 / Activate OSX Screensaver With
Last active Dec 14, 2017
MacOSX hotkey for locking screen by starting screensaver
View Activate OSX Screensaver With

You can usually lock the screen by hitting ctrl-shift-power, but that will power down external monitors, which might take several boring seconds to start up again. Also, a MacBook with a TouchBar doesn't have the power button anymore. With the following guide you can lock the screen by starting the screensaver, keeping the monitors running.


Set System Preferences » Security & Privacy » General » Require password immediately after sleep...

The simple way

  1. Download and unzip it to $HOME/Library/Services/
You can’t perform that action at this time.