Skip to content

Instantly share code, notes, and snippets.

@linakis
linakis / change_commiter_name.sh
Created March 30, 2020 08:09
Command line that changes all commits with proper name and email. Make sure you change the `OLD_EMAIL`, `CORRECT_NAME` and `CORRECT_EMAIL`
git filter-branch --env-filter '
OLD_EMAIL="old_email@example.com"
CORRECT_NAME="Foo Bar"
CORRECT_EMAIL="correct_email@correct-example.com"
if [ "$GIT_COMMITTER_EMAIL" = "$OLD_EMAIL" ]
then
export GIT_COMMITTER_NAME="$CORRECT_NAME"
export GIT_COMMITTER_EMAIL="$CORRECT_EMAIL"
fi
if [ "$GIT_AUTHOR_EMAIL" = "$OLD_EMAIL" ]
@linakis
linakis / adb+
Last active March 3, 2020 10:08
adb device selection CLI.
clear;
echo "===============";
echo " ADB DEVICES";
echo "===============";
echo "";
adb_devices=( $(adb devices | grep -v devices | grep device | cut -f 1)#$(adb devices | grep -v devices | grep device | cut -f 2) );
if [ $((${#adb_devices[@]})) -eq "1" ] && [ "${adb_devices[0]}" == "#" ]
then
@linakis
linakis / PaysafeCheckDigit.java
Created February 8, 2018 07:41
Paysafe Check Digit calculation/validation based on Apache Commons validator
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 September 19, 2017 10:49
A helper class to make Android run time permission a little easier.
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 September 19, 2017 10:42
Android Application class for adding iOS didBecomeActive callback method
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 22:12
Rename files for android resource
for f in *; do mv "$f" "$(echo $f | tr "[:upper:]" "[:lower:]" | sed 's/[-\ ]/_/g')"; done;
@linakis
linakis / generate-ios-screenshots.sh
Created April 15, 2016 11:50
Imagemagick bash script to generate portrait iOS app store screenshots from 6+ input
#!/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 February 12, 2016 11:57
Android screenshots - Demo Mode for the Android System UI.
#!/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
/*
* 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 December 29, 2015 00:09
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
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;