Skip to content

Instantly share code, notes, and snippets.

View scottyab's full-sized avatar

Scott Alexander-Bown scottyab

View GitHub Profile
#!/usr/bin/env bash
# exit if fails
set -o errexit
set -o pipefail
# reads the first arg as the file - expected list of file names without extension
filename="${1:-}"
# loops through each line
while read -r line
@scottyab
scottyab / SafePendingIntent.java
Created May 14, 2014 16:10
Creating an explicit pending intent is safer than implicit
//explicit (to MyService)
Intent intent = new Intent(context, MyService.class);
PendingIntent pi = PendingIntent.getService(getApplicationContext(), 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
//implicit
Intent intent = new Intent("com.my.app.action")
PendingIntent pi = PendingIntent.getService(getApplicationContext(), 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
@scottyab
scottyab / add-copyright.py
Last active May 24, 2018 09:17 — forked from rodrigosetti/add-copyright.py
Adds Copyright Notice to a bunch of Java and Kotlin files
@scottyab
scottyab / Contract Killer 3.md
Created November 24, 2017 12:38 — forked from malarkey/Contract Killer 3.md
The latest version of my ‘killer contract’ for web designers and developers

Contract Killer

The popular open-source contract for web professionals by Stuff & Nonsense

  • Originally published: 23rd December 2008
  • Revised date: March 15th 2016
  • Original post

@scottyab
scottyab / PRNGFixes.java
Last active February 6, 2017 02:58
Enforce correct initialisation of Random numbers - call this from Application.onCreate(). Basically copy of the code from the Some SecureRandom Thoughts blog post http://android- * developers.blogspot.co.uk/2013/08/some-securerandom-thoughts.html
package com.scottyab.encryption;
/*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will Google be held liable for any damages
* arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, as long as the origin is not misrepresented.
package com.enquos.nutrition.dashboard;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.util.AttributeSet;
import android.util.DisplayMetrics;
import android.view.View;
@scottyab
scottyab / QLog.java
Created March 4, 2016 10:39 — forked from chrisjenx/QLog.java
QLog
package com.bizzby.utils;
import android.util.Log;
import java.io.PrintWriter;
import java.io.StringWriter;
public class QLog
{
@scottyab
scottyab / gist:ff0bf65bd73f1572fa49
Created January 4, 2016 14:06
Example of crittercism api upload for proguard-mapping.txt
curl “https://app.crittercism.com/api_beta/proguard/<app_id>" -F proguard=@”<path/to/proguard-mapping.txt>” -F app_version=”app-version-name” -F key=<key>
@scottyab
scottyab / become-spongy.sh
Created December 17, 2013 12:01
Script to rename bouncycastle files to be spongycastle. From https://github.com/rtyley/spongycastle/
#!/bin/bash
# no further use for remaining crypto stuff
rm -Rf crypto
# Package rename org.bouncycastle to org.spongycastle
find -name bouncycastle | xargs rename s/bouncycastle/spongycastle/
find bc* -type f | xargs sed -i s/bouncycastle/spongycastle/g