Skip to content

Instantly share code, notes, and snippets.

View jaredrummler's full-sized avatar

Jared Rummler jaredrummler

View GitHub Profile
@jaredrummler
jaredrummler / boot2gif.sh
Last active February 1, 2023 23:08
Convert an Android boot animation to an animated GIF
#!/bin/bash
################################################################################
#
# boot2gif.sh
#
# DESCRIPTION: Convert an Android boot animation to a GIF
# You will need ImageMagick to run this script.
#
# USAGE:
#
@jaredrummler
jaredrummler / FizzBuzz.kt
Created February 24, 2017 12:43
Kotlin FizzBuzz
fun main(args: Array<String>) {
for (i in 1..100) {
println(if (i % 15 == 0) "FizzBuzz" else if (i % 3 == 0) "Fizz" else if (i % 5 == 0) "Buzz" else i)
}
}
@jaredrummler
jaredrummler / NAME_FROM_UID.md
Last active December 21, 2016 11:15
Get name of UID/GID on Android

Android has a way to get the name for a numeric UID using android.os.Process.getUidForName(String name). There is no method to get the numeric id from a UID name. This really ugly reflection will get the numeric UID/GID:

public static String getNameForUid(int id) {
  try {
    Class<?> clazz = Class.forName("libcore.io.Libcore");
    Field field = clazz.getDeclaredField("os");
    if (!field.isAccessible()) {
      field.setAccessible(true);
    }
@jaredrummler
jaredrummler / PsCommand.java
Created December 19, 2016 05:13
Get a list of running processes using toolbox ps on a rooted Android device
import android.os.Parcel;
import android.os.Parcelable;
import android.support.annotation.WorkerThread;
import com.jrummyapps.android.shell.CommandResult;
import com.jrummyapps.android.shell.Shell;
import java.util.ArrayList;
import java.util.Collections;
@jaredrummler
jaredrummler / LS_COMMAND_REGEX.md
Created December 14, 2016 10:41
ls command regex

group symlink:

^\s*(\d+)?\s?([rwxSTstdcb\-lp?]{10})\s+(\d+)?\s?(\S+)\s+(\S+)\s+([0-9,]+)?\s+(\d+)?\s?([0-9\-]{10}\s+[0-9:]{5}|[A-Z][a-z]{2}\s+[0-9]{1,2}\s+[0-9:]{4,5})\s((?:(?!\s\->\s).)*)(\s\->\s)?(.*)

no symlink:

^\s*(\d+)?\s?([rwxSTstdcb\-lp?]{10})\s+(\d+)?\s?(\S+)\s+(\S+)\s+([0-9,]+)?\s+(\d+)?\s?([0-9\-]{10}\s+[0-9:]{5}|[A-Z][a-z]{2}\s+[0-9]{1,2}\s+[0-9:]{4,5})\s(.*)
@jaredrummler
jaredrummler / android-arsenal-adblock-placeholder-remover.user.js
Last active February 10, 2018 02:42
Redirect to project pages on android-arsenal.com. Saves a click.
// ==UserScript==
// @name android-arsenal-adblock-placeholder-remover.user.js
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Remove adBlock placeholders. Guilt++
// @author Jared Rummler
// @match https://android-arsenal.com/*
// @grant none
// ==/UserScript==
@jaredrummler
jaredrummler / README.md
Created November 30, 2016 01:47
Get number of results for a Google Search

Using Jsoup:

public static int getGoogleResultsCount(String query) throws IOException {
  String url = "https://www.google.com/search?q=" + query;
  Document document = Jsoup.connect(url)
      .userAgent("Mozilla/5.0 (Windows; U; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727)")
      .get();
  Element divResultStats = document.select("div#resultStats").first();
 return Integer.parseInt(divResultStats.text().replaceAll("\\D", ""));
@jaredrummler
jaredrummler / REGEX.md
Created November 22, 2016 21:47
regex collection
@jaredrummler
jaredrummler / SubIconDrawable.java
Created November 14, 2016 19:10
Draw drawable on bottom right of original drawable
public class SubIconDrawable {
private Drawable subIconDrawable;
public SubIconDrawable(Drawable drawable, Drawable subIconDrawable) {
super(drawable);
this.subIconDrawable = subIconDrawable;
}
@Override protected void onBoundsChange(Rect rect) {
#!/bin/bash
APK_FILE=$1
OUT_DIR=$2
printUsage() {
echo "$(basename $0) [APK_FILE] [OUT_DIR]"
}
# Set the output directory if none was provided