Skip to content

Instantly share code, notes, and snippets.

Nikos Linakis linakis

View GitHub Profile
@linakis
linakis / PaysafeCheckDigit.java
Created Feb 8, 2018
Paysafe Check Digit calculation/validation based on Apache Commons validator
View PaysafeCheckDigit.java
import org.apache.commons.validator.routines.checkdigit.CheckDigit;
import org.apache.commons.validator.routines.checkdigit.CheckDigitException;
import org.apache.commons.validator.routines.checkdigit.ModulusCheckDigit;
/**
* Modulus 10 <b>Paysafe</b> Check Digit calculation/validation.
* <p>
* Check digit calculation is based on <i>modulus 10</i> with digits in
* an <i>odd</i> position (from left to right) being weighted 1 and <i>even</i>
* position digits being weighted 3.
@linakis
linakis / PermissionsHelper.java
Created Sep 19, 2017
A helper class to make Android run time permission a little easier.
View PermissionsHelper.java
import android.app.Activity;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.net.Uri;
import android.provider.Settings;
import android.support.design.widget.Snackbar;
import android.support.v4.app.ActivityCompat;
import android.support.v4.content.ContextCompat;
import android.support.v7.app.AlertDialog;
@linakis
linakis / StateAwareApplication.java
Created Sep 19, 2017
Android Application class for adding iOS didBecomeActive callback method
View StateAwareApplication.java
import android.app.Activity;
import android.app.Application;
import android.os.Bundle;
import java.util.Date;
/**
* Simple Application providing didBecomeActive callback method.
*/
public abstract class StateAwareApplication extends Application implements Application.ActivityLifecycleCallbacks {
@linakis
linakis / rename_android_resources.bash
Last active May 17, 2017
Rename files for android resource
View rename_android_resources.bash
for f in *; do mv "$f" "$(echo $f | tr "[:upper:]" "[:lower:]" | sed 's/[-\ ]/_/g')"; done;
@linakis
linakis / generate-ios-screenshots.sh
Created Apr 15, 2016
Imagemagick bash script to generate portrait iOS app store screenshots from 6+ input
View generate-ios-screenshots.sh
#!/bin/sh
# Generate iPhone Portrait Screenshots from 6+ for app store submission.
# From folder containing 6+ screenshots do:
# ./generate-ios-screenshots.sh *.png
mkdir -p 3.5
mkdir -p 4.0
mkdir -p 4.7
mkdir -p 5.5
@linakis
linakis / android-screenshooting-demo-mode.sh
Last active Feb 12, 2016
Android screenshots - Demo Mode for the Android System UI.
View android-screenshooting-demo-mode.sh
#!/bin/sh
CMD=$1
if [[ $ADB == "" ]]; then
ADB=adb
fi
if [[ $CMD != "on" && $CMD != "off" ]]; then
echo "Usage: $0 [on|off] [hhmm] [screenshot_path]" >&2
exit
View CheatSheet.java
/*
* Copyright 2012 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@linakis
linakis / GeocoderHelper
Last active Dec 29, 2015
This is a helper class to compensate a known Android bug that forces Geocoder to throw an IOException For more info check: https://code.google.com/p/android/issues/detail?id=38009
View GeocoderHelper
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
You can’t perform that action at this time.