Skip to content

Instantly share code, notes, and snippets.

@JakeWharton
JakeWharton / README.md
Last active January 8, 2020 02:13
A special activity which facilitates restarting your application process.
//- templated by jade
svg(width=640 height=480 style="background-color:grey;")
circle(
cx=30 cy=30
r=25
stroke="grey" stroke-width=1
fill="wheat")
rect(
width=50 height=50
x=60 y=10
@alexjlockwood
alexjlockwood / MainActivity.java
Last active August 12, 2020 12:06
Sample usage of the "android.app.Application.ActivityLifecycleCallbacks" class.
public class MainActivity extends Activity {
private final MyActivityLifecycleCallbacks mCallbacks = new MyActivityLifecycleCallbacks();
@Override
protected void onCreate(Bundle savedInstanceState) {
// Always register before calling into the super class.
getApplication().registerActivityLifecycleCallbacks(mCallbacks);
super.onCreate(savedInstanceState);
@JakeWharton
JakeWharton / dex.sh
Last active March 25, 2024 13:54
`classes.dex` method count helpers. Requires smali/baksmali from https://code.google.com/p/smali/ and dexdump from the build-tools in the Android SDK be on your PATH.
function dex-method-count() {
cat $1 | head -c 92 | tail -c 4 | hexdump -e '1/4 "%d\n"'
}
function dex-method-count-by-package() {
dir=$(mktemp -d -t dex)
baksmali $1 -o $dir
for pkg in `find $dir/* -type d`; do
smali $pkg -o $pkg/classes.dex
count=$(dex-method-count $pkg/classes.dex)
name=$(echo ${pkg:(${#dir} + 1)} | tr '/' '.')
@riywo
riywo / ssh_tailf.pl
Created August 7, 2012 16:46
perlでssh tail -fをいい感じに
use strict;
use warnings;
my $host = $ARGV[0] or die;
my $ssh = 'ssh -t';
my $cmd = 'tail -F -n0 /tmp/hoge.log';
my $pid = open my $fh, '-|', qq/$ssh $host '$cmd'/ or die;
while (<$fh>) {
if (/hoge/) {