Skip to content

Instantly share code, notes, and snippets.

@mdellavo
mdellavo / gist:8357196
Created January 10, 2014 16:13
access sdk.dir in gradle
def getSdkDir() {
Properties local = new Properties()
local.load(new FileInputStream("${rootDir}/local.properties"))
return local.getProperty('sdk.dir')
}
@mdellavo
mdellavo / build.gradle
Created December 7, 2013 16:25
A build.gradle for an app migrated from ant with a bunch of deps and a subproject
task wrapper(type: Wrapper) {
gradleVersion = '1.8'
}
buildscript {
repositories {
mavenCentral()
}
dependencies {
interface UserRelations {
@Relation(Score.class)
void getScores(QueryListener<Score> listener);
}
@Table(name="users")
public abstract static class User implements Entity, UserRelations {
public User() {}
Mapped classes are abstract where abstract annotated
getters that take a Query/Fetch lisener. Object will be proxied, if
an abstract getter is invoked, fetch and call listener.
abstract class Score implements Entity {
@Column(primaryKey=true)
Private int id;
private date;
private int score;
@Table("users")
public class User implements Entity {
private int id;
@Column("user_name")
private String userName;
}
@mdellavo
mdellavo / pull-db.sh
Created May 19, 2013 15:24
shell to pull database from unrooted android phone
#!/bin/sh
adb -d shell 'run-as org.quuux.eyecandy cat /data/data/org.quuux.eyecandy/databases/eyecandy.db > /sdcard/eyecandy.db'
adb pull /sdcard/eyecandy.db
adb -d shell 'rm /sdcard/eyecandy.db'
@mdellavo
mdellavo / Log.java
Last active December 17, 2015 12:09
A Drop in wrapper for Android's Log class which provides compile time exclusion of debug logging statements and format strings to eliminate heavy string building in release builds
public class Log {
private final String mTag;
private static String sPrefix;
public static void setsPrefix(final String prefix) {
sPrefix = prefix;
}
var ModalView = Backbone.View.extend({
el: '#modal',
events: {
'click a.close': 'onClose',
'click a.submit': 'onSubmit',
'shown': 'onShown'
},
onClose: function() {
@mdellavo
mdellavo / PausableThread.java
Created December 28, 2012 02:03
Pausable Thread Class
class PausableThread extends Thread {
private boolean running, paused;
private static final int FPS = 30;
public PausableThread() {
super();
pauseRunning();
}
@Override
@mdellavo
mdellavo / gist:4226498
Created December 6, 2012 17:51
Nexus 4 Camera Capture and Preview Sizes
Capture Sizes
3264 x 2448 (7.99 MP) = 1.333333
3264 x 2176 (7.10 MP) = 1.500000
3264 x 1836 (5.99 MP) = 1.777778
2592 x 1944 (5.04 MP) = 1.333333
2048 x 1536 (3.15 MP) = 1.333333
1920 x 1080 (2.07 MP) = 1.777778
1600 x 1200 (1.92 MP) = 1.333333
1280 x 960 (1.23 MP) = 1.333333
1280 x 720 (0.92 MP) = 1.777778