Skip to content

Instantly share code, notes, and snippets.

henrik242

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
View maven-deploy-file.sh
#!/bin/bash
if [ $# -lt 3 ]; then
echo "Usage: maven-deploy-file groupId artifactId version [packaging] [repository]"
exit 1
fi
GROUP=$1
ARTIFACT=$2
VERSION=$3
@henrik242
henrik242 / DisableCertificateValidation.java
Created Dec 22, 2011
Disable validation of SSL certificates in Java
View DisableCertificateValidation.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
henrik242 / surf-control.sh
Created Feb 17, 2012
Productivity improving firewall script for MacOSX / BSD
View surf-control.sh
#!/bin/bash
##
## Requires pwgen, wc, sed, host, ipfw, sudo
##
HOSTS="last.fm www.discogs.com www.facebook.com facebook.com
macrumors.com dealextreme.com www.dealextreme.com db.no www.db.no
vg.no www.vg.no aftenposten.no www.aftenposten.no amazon.com
www.amazon.com"
@henrik242
henrik242 / check-ssl-expiry.sh
Last active Dec 17, 2015
Checks for upcoming expiry of SSL certificates, e.g. HTTPS or LDAPS. Useful for cron jobs and server monitoring.
View check-ssl-expiry.sh
#!/bin/bash
SERVER=my.example.com:443
WARNDAYS=30
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
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
henrik242 / pingstats.sh
Last active Apr 19, 2016
A little script to monitor my network connection
View pingstats.sh
#!/bin/bash
# Add to crontab, e.g.:
#
# * * * * * $HOME/cron/pingstats.sh
IP1=84.xx.20.yy
IP2=129.xx.30.yy
IP3=84.xx.64.yy
@henrik242
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
JAVAEXEC="$JAVA_HOME/bin/java"
else
echo "ERROR: Could not find java binary"
@henrik242
henrik242 / HttpStuff.java
Last active Mar 2, 2017
HTTP POST and GET in plain Java
View HttpStuff.java
import java.io.*;
import java.net.*;
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("http://example.com/", "foo=bar&baz=moo"));
@henrik242
henrik242 / Target monitor selector for XBMC.md
Last active Sep 26, 2017
Target monitor selector for XBMC
View Target monitor selector for XBMC.md

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
henrik242 / Activate OSX Screensaver With Hotkey.md
Last active Dec 14, 2017
MacOSX hotkey for locking screen by starting screensaver
View Activate OSX Screensaver With Hotkey.md

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.

Preparations

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

The simple way

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