Skip to content

Instantly share code, notes, and snippets.

View dbachelder's full-sized avatar

dan bachelder dbachelder

View GitHub Profile
dbachelder /
Created April 29, 2015 23:44
Android test runner that doesn't finish the activity under test
import android.content.Intent;
import android.util.Log;
* this is a rule that does not finish the activity under test at the end of the test.
* useful for debugging and development. use in the same way as ActivityTestRule.
dbachelder / gist:9587898
Last active December 11, 2018 21:29
style the actionbar compat searchview. inspired by this article:
final SupportMenuItem searchMenuItem = (SupportMenuItem) menu.findItem(;
if (searchMenuItem == null) throw new IllegalArgumentException("menu item is null and that is very suspicious.");
this.searchView = (SearchView) searchMenuItem.getActionView();
if (searchView == null) throw new IllegalArgumentException("search view is null and that is very suspicious.");
// wow. much hack. style search box..
Resources resources = searchView.getContext().getResources();
dbachelder /
Last active May 19, 2017 11:16
A version of support DrawerLayout that can open the drawer X pixels... uses reflection to access the private members of DrawerLayout
import android.content.Context;
import android.os.Build;
import android.util.AttributeSet;
import android.view.Display;
import android.view.Gravity;
subprojects {
// 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
it.afterEvaluate { subProject ->
// is this a library or an app?
if(subProject.plugins.hasPlugin(AppPlugin.class) || subProject.plugins.hasPlugin(LibraryPlugin.class)) {
protected Parcelable onSaveInstanceState() {
Parcelable superState = super.onSaveInstanceState();
return new SavedState(superState, numberPicker1.getValue(), numberPicker2.getValue(), numberPicker3.getValue());
protected void onRestoreInstanceState(Parcelable state) {
SavedState savedState = (SavedState) state;
dbachelder /
Created January 14, 2014 22:59 — forked from jookyboi/
CSS libraries and guides to bring some order to the chaos.


  • 960 Grid System - An effort to streamline web development workflow by providing commonly used dimensions, based on a width of 960 pixels. There are two variants: 12 and 16 columns, which can be used separately or in tandem.
  • Compass - Open source CSS Authoring Framework.
  • Bootstrap - Sleek, intuitive, and powerful mobile first front-end framework for faster and easier web development.
  • Font Awesome - The iconic font designed for Bootstrap.
  • Zurb Foundation - Framework for writing responsive web sites.
  • SASS - CSS extension language which allows variables, mixins and rules nesting.
  • Skeleton - Boilerplate for responsive, mobile-friendly development.


dbachelder / 0_reuse_code.js
Created January 14, 2014 22:59
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
dbachelder / gist:8322454
Created January 8, 2014 19:06
problem when building with elasticsearch1.0.0-beta2
[info] Compiling 183 Scala sources to /home/dev/projects/core/target/scala-2.10/classes...
[warn] Class org.elasticsearch.common.joda.convert.FromString not found - continuing with a stub.
[warn] Caught: java.lang.NullPointerException while parsing annotations in /home/.ivy2/cache/org.elasticsearch/elasticsearch/jars/elasticsearch-1.0.0.Beta2.jar(org/elasticsearch/common/joda/time/DateTime.class)
[error] error while loading DateTime, class file '/home/.ivy2/cache/org.elasticsearch/elasticsearch/jars/elasticsearch-1.0.0.Beta2.jar(org/elasticsearch/common/joda/time/DateTime.class)' is broken
[error] (class scala.MatchError/p (of class java.lang.Character))
dbachelder /
Last active December 20, 2015 07:09 — forked from j3tm0t0/
added region and keys to script to make it more obvious what needs to be done
export AWS_REGION='us-west-1'
# creating security groups
ec2-create-group --region $AWS_REGION 'AWS-OpsWorks-Web-Server' -d 'AWS OpsWorks Web server - do not change or delete'
ec2-create-group --region $AWS_REGION 'AWS-OpsWorks-Default-Server' -d 'AWS OpsWorks Default server - do not change or delete'
ec2-create-group --region $AWS_REGION 'AWS-OpsWorks-Blank-Server' -d 'AWS OpsWorks blank server - do not change or delete'
ec2-create-group --region $AWS_REGION 'AWS-OpsWorks-LB-Server' -d 'AWS OpsWorks load balancer - do not change or delete'