Skip to content

Instantly share code, notes, and snippets.

dan dbachelder

  • Zumper, Inc
  • SF
Block or report user

Report or block dbachelder

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@dbachelder
dbachelder / NoFinishActivityTestRule.java
Created Apr 29, 2015
Android test runner that doesn't finish the activity under test
View NoFinishActivityTestRule.java
package android.support.test.rule;
import android.app.Activity;
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
dbachelder / gist:9587898
Last active Dec 11, 2018
style the actionbar compat searchview. inspired by this article: http://nlopez.io/how-to-style-the-actionbar-searchview-programmatically/
View gist:9587898
final SupportMenuItem searchMenuItem = (SupportMenuItem) menu.findItem(R.id.menu_search);
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.");
searchView.setQueryHint(getActivity().getString(R.string.search_hint));
// wow. much hack. style search box..
Resources resources = searchView.getContext().getResources();
@dbachelder
dbachelder / PeekableDrawerLayout.java
Last active May 19, 2017
A version of support DrawerLayout that can open the drawer X pixels... uses reflection to access the private members of DrawerLayout
View PeekableDrawerLayout.java
package android.support.v4.widget;
import android.content.Context;
import android.graphics.Point;
import android.os.Build;
import android.support.v4.view.GravityCompat;
import android.support.v4.view.ViewCompat;
import android.util.AttributeSet;
import android.view.Display;
import android.view.Gravity;
View build.gradle
import com.android.build.gradle.AppPlugin
import com.android.build.gradle.LibraryPlugin
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)) {
View custom_component.java
protected Parcelable onSaveInstanceState() {
Parcelable superState = super.onSaveInstanceState();
return new SavedState(superState, numberPicker1.getValue(), numberPicker2.getValue(), numberPicker3.getValue());
}
@Override
protected void onRestoreInstanceState(Parcelable state) {
SavedState savedState = (SavedState) state;
super.onRestoreInstanceState(savedState.getSuperState());
@dbachelder
dbachelder / css_resources.md
Created Jan 14, 2014 — forked from jookyboi/css_resources.md
CSS libraries and guides to bring some order to the chaos.
View css_resources.md

Libraries

  • 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.

Guides

@dbachelder
dbachelder / 0_reuse_code.js
Created Jan 14, 2014
Here are some things you can do with Gists in GistBox.
View 0_reuse_code.js
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@dbachelder
dbachelder / gist:8322454
Created Jan 8, 2014
problem when building with elasticsearch1.0.0-beta2
View gist:8322454
[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
dbachelder / recover_opsworks_sg.sh
Last active Dec 20, 2015 — forked from j3tm0t0/recover_opsworks_sg.sh
added region and keys to script to make it more obvious what needs to be done
View recover_opsworks_sg.sh
#!/bin/sh
export AWS_ACCESS_KEY=
export AWS_SECRET_KEY=
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'
You can’t perform that action at this time.