Skip to content

Instantly share code, notes, and snippets.

View dustin-graham's full-sized avatar

Dustin Graham dustin-graham

  • AxleHire
  • United States
View GitHub Profile
@dustin-graham
dustin-graham / OrderedForm.h
Created November 7, 2011 17:50
Automated iOS form component for tabbing through text fields and auto scrolling/sizing scroll views
//
// OrderedForm.h
// KSLClassifieds
//
// Created by Dustin Graham on 11/4/11.
// Copyright (c) 2011 __MyCompanyName__. All rights reserved.
//
#import <Foundation/Foundation.h>
#import "StandardInputAccessory.h"
@dustin-graham
dustin-graham / gist:5571452
Created May 13, 2013 20:56
LogCat for Retrofit 1.0 runtime error when running on Android. This doesn't happen in standard Java console apps.
05-13 14:55:03.464: E/AndroidRuntime(1568): FATAL EXCEPTION: main
05-13 14:55:03.464: E/AndroidRuntime(1568): java.lang.ExceptionInInitializerError
05-13 14:55:03.464: E/AndroidRuntime(1568): at retrofit.RestAdapter$RestHandler.invoke(RestAdapter.java:173)
05-13 14:55:03.464: E/AndroidRuntime(1568): at com.rain.example.retrofit.sanitycheck.$Proxy0.getRepresentativesByZip(Native Method)
05-13 14:55:03.464: E/AndroidRuntime(1568): at com.rain.example.retrofit.sanitycheck.MainActivity.onCreate(MainActivity.java:61)
05-13 14:55:03.464: E/AndroidRuntime(1568): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
05-13 14:55:03.464: E/AndroidRuntime(1568): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
05-13 14:55:03.464: E/AndroidRuntime(1568): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
05-13 14:55:03.464: E/AndroidRuntime(1568): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
05-13 14:55:03.464: E
@dustin-graham
dustin-graham / gist:5571520
Created May 13, 2013 21:04
Simple activity to pull data from whoismyrepresentative.org. This code throws a runtime error: java.lang.ExceptionInInitializerError caused by java.util.regex.PatternSyntaxException: Syntax error U_REGEX_RULE_SYNTAX near index 21: 05-13 14:55:03.464: E/AndroidRuntime(1568): \{([a-z][a-z0-9_-]*)} of RestMethodInfo line 46
package com.rain.example.retrofit.sanitycheck;
import java.util.List;
import retrofit.RestAdapter;
import retrofit.http.GET;
import retrofit.http.Query;
import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
@dustin-graham
dustin-graham / DateHelper.java
Created August 27, 2013 18:40
handy tool for working with time strings
package com.ifit.android.sdk.util;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.Locale;
import java.util.TimeZone;
public abstract class CustomizedTypeAdapterFactory<C>
implements TypeAdapterFactory {
private final Class<C> customizedClass;
public CustomizedTypeAdapterFactory(Class<C> customizedClass) {
this.customizedClass = customizedClass;
}
@SuppressWarnings("unchecked") // we use a runtime check to guarantee that 'C' and 'T' are equal
public final <T> TypeAdapter<T> create(Gson gson, TypeToken<T> type) {
@dustin-graham
dustin-graham / CellRenderer.java
Created September 27, 2013 21:53
Doing ListViews with "delegates" and "CellRenderers"
public interface CellRenderer {
public static int CELL_TYPE_SCHEDULE = 0;
public static int CELL_TYPE_HISTORY = 1;
void renderRowCell(String workoutId, Date dateScheduled, double meters, double otherValue, int calories, String title, String workoutType);
void renderRowCell(String workoutId, Date dateScheduled, double meters, double otherValue, int calories, String title, String workoutType, String thumbnailURL);
}
@dustin-graham
dustin-graham / nginx.conf
Created October 3, 2013 15:46
my nginx.conf file
#user nobody;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
#user nobody;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
@dustin-graham
dustin-graham / demokit_mod.ino
Created October 25, 2013 17:52
ADK demo sketch is wrong in the ADK 2011 library code. The CapSense library has been changed and is now named CapacitiveSensor.
#include <Wire.h>
#include <Servo.h>
#include <Max3421e.h>
#include <Usb.h>
#include <AndroidAccessory.h>
#include <CapacitiveSensor.h>
#define LED3_RED 2
@dustin-graham
dustin-graham / RainEmployeeProvider.java
Created February 22, 2014 00:09
An example Android ContentProvider
package com.rain.example.data.provider;
import com.rain.example.data.database.RainEmployeeDatabase;
import com.rain.example.data.database.table.*;
import android.provider.BaseColumns;
import android.text.TextUtils;
import android.content.ContentUris;
import android.database.sqlite.SQLiteQueryBuilder;