Skip to content

Instantly share code, notes, and snippets.

View donnfelker's full-sized avatar

Donn Felker donnfelker

View GitHub Profile
@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
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'
//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 / 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);
@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) {
// 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 / 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) {
@donnfelker
donnfelker / gist:4388456
Created December 27, 2012 13:41
Centering in Bootstrap
http://jsfiddle.net/rfkrocktk/hcQ48/
@donnfelker
donnfelker / example.js
Created June 27, 2012 21:20
Express 3 Changes in res.json
// v0.6.19 way of returning JSON.
exports.index = function(req, res) {
Workout.find({}, function(err, docs) {
if(!err) {
res.json( { workouts: docs }, 200);
} else {
res.json( { message: err }, 500);
}
});
}
@donnfelker
donnfelker / EditCredtCardIntl.java
Created March 27, 2012 17:52
EditCredtCardIntl.java
public class EditCreditCardIntl extends EditCreditCard {
@InjectView( R.id.cc_payment_method_layout ) LinearLayout paymentMethodLayout;
@InjectView( R.id.cc_payment_method ) Spinner paymentMethod;
// other code
}