Skip to content

Instantly share code, notes, and snippets.

View perchrh's full-sized avatar

Per Christian Henden perchrh

View GitHub Profile
@perchrh
perchrh / commit-msg
Created March 26, 2019 09:12
.git/hooks/commit-msg for verifiying Jira id is present in commit message
#!/usr/bin/env bash
# set this to your active development branch
# based on https://gist.github.com/pgilad/5d7e4db725a906bd7aa7
develop_branch="develop"
current_branch="$(git rev-parse --abbrev-ref HEAD)"
# regex to validate in commit msg
commit_regex='(VUDDF-[0-9]+|merge)'
error_msg="Aborting commit. Your commit message is missing either a JIRA Issue ('VUDDF-1111') or 'Merge'"
# only check commit messages on main development branch
@perchrh
perchrh / JerseyExampleIementation.java
Last active April 5, 2019 13:11
Modern Java 11 Http Client implementation of org.glassfish.jersey.client.internal.HttpUrlConnector._apply
package org.digitalsprouts.example.http_client;
import org.glassfish.jersey.client.ClientProperties;
import org.glassfish.jersey.client.ClientResponse;
import org.glassfish.jersey.message.internal.Statuses;
import javax.ws.rs.core.Response;
import java.io.IOException;
import java.io.InputStream;
import java.net.http.HttpClient;
@perchrh
perchrh / Sentiance.swift
Created December 28, 2019 13:59
manglende callbacks
func setupSentiance(completion: (() -> Void)? = nil, failure: ((_ error: SentianceError) -> Void)? = nil) {
if CLLocationManager.authorizationStatus() != .authorizedAlways, CMMotionActivityManager.authorizationStatus() != .authorized { return }
guard let realm = try? Realm(), let _ = realm.objects(User.self).first else { return }
if let isInitialised = SENTSDK.sharedInstance()?.getInitState() {
if isInitialised == .SENTInitInProgress { return }
if isInitialised == .SENTInitialized {
if let sdkStatus = SENTSDK.sharedInstance()?.getStatus()?.startStatus, sdkStatus == .started {
completion?()