Skip to content

Instantly share code, notes, and snippets.

View scottyab's full-sized avatar

Scott Alexander-Bown scottyab

View GitHub Profile
@maurerbot
maurerbot / MeetupAuthActivity.java
Last active January 12, 2017 04:46
Created this to authenticate meetup for an android app.
import android.content.ContentValues;
import android.net.Uri;
import android.os.AsyncTask;
import android.util.Log;
import android.view.Window;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.Toast;
// leeloo oAuth lib https://bitbucket.org/smartproject/oauth-2.0/wiki/Home
@jdamcd
jdamcd / EmailAdapter.java
Last active December 12, 2015 07:48
Email adapter for AutoCompleteTextView
private ArrayAdapter<String> getEmailAddressAdapter(Context context) {
Account[] accounts = AccountManager.get(context).getAccountsByType("com.google");
String[] addresses = new String[accounts.length];
for (int i = 0; i < accounts.length; i++) {
addresses[i] = accounts[i].name;
}
return new ArrayAdapter<String>(context, android.R.layout.simple_dropdown_item_1line, addresses);
}
@jdamcd
jdamcd / AllEmailAdapter.java
Last active December 12, 2015 10:49
Email adapter for AutoCompleteTextView that looks for emails from all account types, not just Google.
private static final String EMAIL_REGEX = "^[_A-Za-z0-9-\\+]+(\\.[_A-Za-z0-9-]+)*@[A-Za-z0-9-]+(\\.[A-Za-z0-9]+)*(\\.[A-Za-z]{2,})$";
private static final Pattern EMAIL_PATTERN = Pattern.compile(EMAIL_REGEX);
private ArrayAdapter<String> getEmailAddressAdapter(Context context) {
Account[] accounts = AccountManager.get(context).getAccounts();
HashSet<String> emailSet = new HashSet<String>();
for (int i = 0; i < accounts.length; i++) {
if (isEmailAddress(accounts[i].name)) {
emailSet.add(accounts[i].name);
}
@imminent
imminent / GateKeeper.java
Created March 22, 2013 21:48
Android version gate keeper utility.
import javax.annotation.Nonnull;
import android.content.Context;
import android.content.res.Configuration;
import android.os.Build;
/**
* <p>Keeper of the {@linkplain Build#VERSION_CODES Android version gates}, used to guarantee non shall pass,
* unless they are worthy.</p>
* @author Dandre Allison
package com.bizzby.utils;
import android.util.Log;
import java.io.PrintWriter;
import java.io.StringWriter;
public class QLog
{
@jamiehuson
jamiehuson / JacksonConverter
Created September 16, 2013 21:32
A Jackson Converter for use with Square's Tape queue library
public class JacksonConverter<T> implements FileObjectQueue.Converter<T> {
private final ObjectMapper mMapper;
private final Class<T> mType;
public JacksonConverter(ObjectMapper mapper, Class<T> type) {
this.mType = type;
this.mMapper = mapper;
}
@plentz
plentz / nginx.conf
Last active April 24, 2024 11:15
Best nginx configuration for improved security(and performance)
# to generate your dhparam.pem file, run in the terminal
openssl dhparam -out /etc/nginx/ssl/dhparam.pem 2048
@commonsguy
commonsguy / SQLCipherV3Helper.java
Last active December 25, 2015 23:39
SQLiteHookedHelper and SQLCipherV3Helper
/***
Copyright (c) 2013 CommonsWare, LLC
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 distributed under the
License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
OF ANY KIND, either express or implied. See the License for the specific
language governing permissions and limitations under the License.
*/
@chrisjenx
chrisjenx / GsonBuilder.java
Last active October 19, 2015 18:47
Custom Gson Serialiser for android.support.v4.util.SimpleArrayMap;
return new GsonBuilder()
.registerTypeAdapter(SimpleArrayMapJsonSerializer.TYPE, new SimpleArrayMapJsonSerializer())
.create();
/*
* Copyright (C) 2014 Chris Banes
*
* 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