Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / 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
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 / IconCheckBoxPreference.java
Created August 9, 2010 16:37
IconCheckBoxPreference: An Android CheckBox preference with an optional Icon
package com.jakewharton.utilities;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.preference.CheckBoxPreference;
import android.util.AttributeSet;
import android.view.View;
import android.widget.ImageView;
import com.jakewharton.wakkawallpaper.R;
@JakeWharton
JakeWharton / gist:506573
Created August 3, 2010 15:41
Disable any lazy loading of table properties by magical reflection voodoo
namespace JakeWharton.Utilities
{
public static class DataContextExtensions
{
/// <summary>
/// Disable any lazy loading of table properties by magical reflection voodoo.
///
/// See: http://stackoverflow.com/questions/3388276/disable-all-lazy-loading-or-force-eager-loading-for-a-linq-context
/// And: http://stackoverflow.com/questions/3396426/iterating-tables-in-a-context-and-the-properties-of-those-tables
/// And: http://stackoverflow.com/questions/3397843/how-to-determine-lazy-loaded-properties-at-runtime-on-a-linq-table
#!/usr/bin/perl -w
use strict;
use warnings;
use File::Basename;
use Getopt::Long;
#########################################################
# Flac to Mp3 Perl Converter - Terminal Edition
# Created by: Somnorific
# Based on: Scripts by Falkano and Nick Sklaventitis
@JakeWharton
JakeWharton / post-receive
Created April 9, 2010 13:57
git post-receive hook for updating Trac 0.12
#!/usr/bin/python
import sys
import subprocess
GIT_PATH = '/usr/bin/git'
TRAC_ADMIN_PATH = '/usr/local/bin/trac-admin'
VALID_BRANCHES = ['master']
TRAC_ENV = '/path/to/trac'
from rcdict import *
class User: pass
class Group(Model):
name = StringField()
admin = ForeignKey(User)
#users = ReverseForeignKey(User) generated automatically
class User(Model):
@JakeWharton
JakeWharton / ExpressionEvaluator.java
Created November 18, 2009 01:13
Java class to parse, evaluate, and convert between infix, prefix, and postfix expressions.
import java.util.ArrayList;
/***
* @name Expression Evaluator
* @author Jake Wharton
* @date 2005-11-07
*/
public class ExpressionEvaluator
{
public static enum EXPRESSIONTYPE