Skip to content

Instantly share code, notes, and snippets.

View dbachelder's full-sized avatar

dan bachelder dbachelder

View GitHub Profile
@9re
9re / ExifUtil.java
Created March 7, 2012 00:16
fix flipped / rotated image by getting exif orientation
import java.io.IOException;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import android.graphics.Bitmap;
import android.graphics.Matrix;
import android.os.Build;
@christopherperry
christopherperry / adb+
Created July 30, 2012 16:12
A bash script that let's you issue adb commands to multiple devices at once
#!/bin/bash
# Script adb+
# Usage
# You can run any command adb provides on all your currently connected devices
# ./adb+ <command> is the equivalent of ./adb -s <serial number> <command>
#
# Examples
# ./adb+ version
# ./adb+ install apidemo.apk
# ./adb+ uninstall com.example.android.apis
@j3tm0t0
j3tm0t0 / recover_opsworks_sg.sh
Created May 16, 2013 02:24
recover security groups for AWS OpsWorks
#!/bin/sh
# creating security groups
ec2-create-group 'AWS-OpsWorks-Web-Server' -d 'AWS OpsWorks Web server - do not change or delete'
ec2-create-group 'AWS-OpsWorks-Default-Server' -d 'AWS OpsWorks Default server - do not change or delete'
ec2-create-group 'AWS-OpsWorks-Blank-Server' -d 'AWS OpsWorks blank server - do not change or delete'
ec2-create-group 'AWS-OpsWorks-LB-Server' -d 'AWS OpsWorks load balancer - do not change or delete'
ec2-create-group 'AWS-OpsWorks-PHP-App-Server' -d 'AWS OpsWorks PHP-App server - do not change or delete'
ec2-create-group 'AWS-OpsWorks-DB-Master-Server' -d 'AWS OpsWorks database master server - do not change or delete'
ec2-create-group 'AWS-OpsWorks-Memcached-Server' -d 'AWS OpsWorks Memcached server - do not change or delete'
ec2-create-group 'AWS-OpsWorks-Monitoring-Master-Server' -d 'AWS OpsWorks Monitoring Ganglia server - do not change or delete'
@ignasi
ignasi / db_getter.sh
Created January 30, 2014 11:43
Get database from an Android app (Android 4.3+)
#!/bin/bash
# Android 4.3+ changes app's internal directory permissions and you can not just pull your
# databases to your computer, so I did this as a workaround to extract my databases.
# I only use it for debug, use it under your responsability.
package=$1
db_name=$2
path="/data/data/$package/"
@hvisser
hvisser / TestStringArrayConverter.java
Last active February 20, 2017 00:40
Custom field converter example for Cupboard
package nl.qbusict.cupboard;
import android.content.ContentValues;
import android.database.Cursor;
import android.database.MatrixCursor;
import android.test.AndroidTestCase;
import nl.qbusict.cupboard.convert.EntityConverter.ColumnType;
import nl.qbusict.cupboard.convert.FieldConverter;
android.applicationVariants.all{ variant ->
// This is an annoying hack to get around the fact that the Gradle plugin does not support
// having libraries with different minSdkVersions. Play Services has a min version of 9 (Gingerbread)
// but Android Maps Utils supports 8 (Froyo) still
variant.processManifest.doFirst {
File manifestFile = file("${buildDir}/exploded-bundles/ComGoogleMapsAndroidAndroidMapsUtils03.aar/AndroidManifest.xml")
if (manifestFile.exists()) {
println("Replacing minSdkVersion in Android Maps Utils")
String content = manifestFile.getText('UTF-8')
content = content.replaceAll(/minSdkVersion="8"/, 'minSdkVersion=\"9\"')
@felHR85
felHR85 / SoftKeyboard.java
Last active February 17, 2024 23:11
A solution to catch show/hide soft keyboard events in Android http://felhr85.net/2014/05/04/catch-soft-keyboard-showhidden-events-in-android/
/*
* Author: Felipe Herranz (felhr85@gmail.com)
* Contributors:Francesco Verheye (verheye.francesco@gmail.com)
* Israel Dominguez (dominguez.israel@gmail.com)
*/
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.atomic.AtomicBoolean;
import android.os.Handler;
@martyglaubitz
martyglaubitz / BorderDrawable.java
Last active August 29, 2015 14:02
A drawable which draws borders as background of a view
/* The MIT License (MIT)
Copyright (c) 2014, Marty Glaubitz
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
@dmarcato
dmarcato / strip_play_services.gradle
Last active December 21, 2022 10:10
Gradle task to strip unused packages on Google Play Services library
def toCamelCase(String string) {
String result = ""
string.findAll("[^\\W]+") { String word ->
result += word.capitalize()
}
return result
}
afterEvaluate { project ->
Configuration runtimeConfiguration = project.configurations.getByName('compile')
@martyglaubitz
martyglaubitz / DistributeLayout.java
Last active August 29, 2015 14:03
DistributingLayout
/* The MIT License (MIT)
Copyright (c) 2014, Marty Glaubitz
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions: