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
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 / p4merge
Last active Mar 24, 2019
Helper script for p4merge and Git on MacOSX
View p4merge
for arg; do [[ $arg = /* ]] || arg=$PWD/$arg; absargs+=("$arg"); done;
/Applications/ "${absargs[@]}"
henrik242 /
Last active Jan 11, 2019
Preliminary work that commits renames of .java files to .kt, and renames them back to prepare for IntelliJ code conversion
#!/usr/bin/env bash
set -o errexit -o pipefail -o nounset
if [[ $# -eq 0 ]]; then
echo "Usage: $0 [someotherclass.groovy ...]"
exit 1
printf "\n\nMoving files with git\n\n"
henrik242 /
Last active Dec 5, 2018
SolrCloud backup/restore without shared disk
#!/usr/bin/env bash
# explains that
# SolrCloud Backup/Restore requires a shared file system mounted at the same path on all nodes.
# This script uses the old Solr Backup/Restore procedure, which is useful if you don't have
# access to a shared disk.
# Requires that the target collection is already set up, with identical number of shards/replicas.
henrik242 / run-script-on-startup.command
Last active Oct 12, 2018
Run shell command in background upon macOS login, using tmux
View run-script-on-startup.command
#!/usr/bin/env bash
# Make this file executable with `chmod +x run-script-in-background.command`, and add it to
# System Preferences --> Users and Groups --> Startup Items. It needs to have the `.command` suffix.
tmux new-session -d -s ostepop \; send -t ostepop.0 "echo Let\'s do this\!; echo More stuff." ENTER

Keybase proof

I hereby claim:

  • I am henrik242 on github.
  • I am hnrk242 ( on keybase.
  • I have a public key ASBdZ40ASLGCs4Irw_zD4pJHgpR4M7t3AXGTyNp1WXFHiwo

To claim this, I am signing this object:

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/
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 /
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"));
You can’t perform that action at this time.