Skip to content

Instantly share code, notes, and snippets.

View donnfelker's full-sized avatar

Donn Felker donnfelker

View GitHub Profile
@donnfelker
donnfelker / gist:5391243
Created April 15, 2013 20:58
CustomeObject Exampl
public class Customer {
String firstName;
String lastName;
// 20 Other properties
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
// Connect to your API with your http lib, i use http-request: https://github.com/kevinsawicki/http-request
// Then get the reader. The 'request' variable below is just a HttpRequest object
// as shown here: http://kevinsawicki.github.io/http-request/
final Reader reader = request.reader();
final ObjectMapper mapper = new ObjectMapper();
final JsonFactory factory = mapper.getFactory();
// Create a new streaming parser with the reader
JsonParser jp = factory.createParser(reader);
@donnfelker
donnfelker / BootstrapModule.java
Last active December 21, 2015 03:38
UrlImageView.java - Abstracts Picasso behind a custom ImageView and injects Picasso via Dagger.
import dagger.Module;
import dagger.Provides;
@Module
(
complete = false
)
public class BootstrapModule {
@Provides
Picasso providesPicasso(Context context) {
@donnfelker
donnfelker / DeepLinkRouterTest.java
Last active July 19, 2016 10:42
ShadowTaskStackBuilder Blog Code
@Test
public void shouldBeAbleToGoToComments() {
Uri deepLink = Uri.parse("pfm:///user/frank/status/123/?version=88983845");
System.out.println(String.format("Testing %s", deepLink.toString()));
// The intent to start.
Intent expectedIntent = new Intent(Robolectric.application, Status.class);
expectedIntent.putExtra(Constants.Extras.STATUS_ID, 123L);
//r = require('rethinkdb')
var MongoClient = require('mongodb').MongoClient,
format = require('util').format;
var querystring = require('querystring');
var https = require('https');
var Inserter = function (collection) {
this.collection = collection;
@donnfelker
donnfelker / build.gradle
Created January 31, 2014 23:42
Excluding with Gradle
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
compile('com.google.android.gms:play-services:3.1.+') {
exclude module: 'support-v4'
}
compile 'com.android.support:appcompat-v7:+'
compile 'com.android.support:support-v4:13.0.+'
compile 'com.squareup.dagger:dagger:1.1.0'
compile 'com.squareup.dagger:dagger-compiler:1.1.0'
compile 'com.squareup.picasso:picasso:2.1.1'
@donnfelker
donnfelker / .gitconfig
Last active August 15, 2021 10:05
My .gitconfig
[user]
name = FirstName LastName
email = you@yourdomain.com
[alias]
A = add -A
a = add
aa = add --all
ae = add --edit
ai = add --interactive
amend = commit --amend -C HEAD
@donnfelker
donnfelker / build.gradle
Last active January 12, 2024 17:49
gradle properties in Android Studio
// Other build stuff
task ndkBuild(type:Exec) {
if(androidNdkPath != null) {
def ndkBuild = new File(androidNdkPath, 'ndk-build')
commandLine ndkBuild
} else {
// do something else
}
}
@donnfelker
donnfelker / CircularTransformation.java
Last active December 2, 2020 20:47
Picasso and CircularTransform Example
import android.graphics.*;
import com.squareup.picasso.Transformation;
/**
* Transforms an image into a circle representation. Such as a avatar.
*/
public class CircularTransformation implements Transformation
{
int radius = 10;
@donnfelker
donnfelker / android-19-circle.yml
Last active March 12, 2021 13:19
Sample CircleCI Configuration For an Android App
#
# Build configuration for Circle CI
#
general:
artifacts:
- /home/ubuntu/your-app-name/app/build/outputs/apk/
machine:
environment: