Skip to content

Instantly share code, notes, and snippets.

extended device statistics
device r/s w/s kr/s kw/s wait actv svc_t %w %b
cmdk0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0 0
cmdk1 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0 0
cmdk2 3.0 0.0 96.0 0.0 0.0 0.0 0.2 0 0
sd1 3.0 0.0 96.0 0.0 0.0 0.0 0.3 0 0
sd2 3.0 0.0 96.0 0.0 0.0 0.0 0.7 0 0
sd3 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0 0
sd4 3.0 0.0 96.0 0.0 0.0 0.0 0.7 0 0
extended device statistics
@JakeWharton
JakeWharton / hardlinkify.py
Created April 13, 2011 15:56
Python script to facilitate the hardlinking of directories and their files.
#!/usr/bin/env python
#
# Python script to facilitate the hardlinking of directories and their files.
import sys
if sys.version_info < (2, 3):
raise RuntimeError('Python 2.3+ is required.')
import logging
import optparse
@JakeWharton
JakeWharton / crlf_fix.py
Created May 19, 2011 19:10
Python script to fix common CRLF and Unicode problems when working with Visual Studio and git.
#!/usr/bin/env python
import sys
if sys.version_info < (2, 6):
raise RuntimeError("Python 2.6+ is required.")
import codecs
import logging
import optparse
import os
@JakeWharton
JakeWharton / PreferenceFragment.java
Created July 26, 2011 23:39
Beginning of a PreferenceFragment implementation that will work back to Android 1.6
package android.support.v4.preference;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.preference.Preference;
import android.preference.PreferenceManager;
import android.preference.PreferenceScreen;
@JakeWharton
JakeWharton / AndroidManifest.xml
Created August 5, 2011 03:05
How to use ActionBarSherlock tab style on native TabWidget.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.actionbarsherlock.sample.stylenativetabs"
android:versionCode="1"
android:versionName="1.0.0">
<uses-sdk android:minSdkVersion="4" />
<application android:label="Styled Native Tabs" android:theme="@style/Theme.Sherlock">
@JakeWharton
JakeWharton / IcsAbsSpinner.java
Created February 22, 2012 05:38
Beginnings of a pre-HC dropdown Spinner
/*
* Copyright (C) 2006 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@JakeWharton
JakeWharton / ViewHoldingAdapter.java
Created April 26, 2012 06:54
Template for a list adapter which uses a view holder to cache lookups.
public class TweetAdapter extends BaseAdapter {
// ...
public View getView(int position, View convertView, ViewGroup parent) {
TweetViewHolder vh = TweetViewHolder.get(convertView, parent);
Tweet item = getItem(position);
vh.user.setText(item.user);
vh.tweet.setText(item.tweet);
@JakeWharton
JakeWharton / ContractFragment.java
Created May 6, 2012 09:12
Base fragment to ensure the parent activity implements a contract interface.
/* Base fragment to ensure the parent activity implements a contract interface. */
public abstract class ContractFragment<T> extends Fragment {
private T mContract;
@Override
public void onAttach(Activity activity) {
try {
mContract = (T)activity;
} catch (ClassCastException e) {
throw new IllegalStateException(activity.getClass().getSimpleName()
public class CheckableFrameLayout extends FrameLayout implements Checkable {
private static final int[] CHECKED_STATE_SET = {
android.R.attr.state_activated,
android.R.attr.state_checked,
};
private boolean mChecked;
public CheckableFrameLayout(Context context) {
super(context);
@JakeWharton
JakeWharton / AspectRatioImageView.java
Created June 2, 2012 02:14
ImageView that respects an aspect ratio applied to a specific measurement.
// Copyright 2012 Square, Inc.
package com.squareup.widgets;
import android.content.Context;
import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.widget.ImageView;
/** Maintains an aspect ratio based on either width or height. Disabled by default. */
public class AspectRatioImageView extends ImageView {