Skip to content

Instantly share code, notes, and snippets.

Avatar

Per Christian Henden perchrh

View GitHub Profile
@perchrh
perchrh / Sentiance.swift
Created Dec 28, 2019
manglende callbacks
View Sentiance.swift
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?()
@perchrh
perchrh / JerseyExampleIementation.java
Last active Apr 5, 2019
Modern Java 11 Http Client implementation of org.glassfish.jersey.client.internal.HttpUrlConnector._apply
View JerseyExampleIementation.java
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 / commit-msg
Created Mar 26, 2019
.git/hooks/commit-msg for verifiying Jira id is present in commit message
View commit-msg
#!/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