Skip to content

Instantly share code, notes, and snippets.

View keybase.md

Keybase proof

I hereby claim:

  • I am paddyzab on github.
  • I am paddyzab (https://keybase.io/paddyzab) on keybase.
  • I have a public key whose fingerprint is 5034 7928 087B CFE9 D962 C410 8843 B667 1D88 C023

To claim this, I am signing this object:

@paddyzab
paddyzab / Bounds.java
Created Feb 23, 2016
Two helper methods to improve semantics of range comparison.
View Bounds.java
private boolean isOutsideRange(int i, int lowerBound, int upperBound) {
return (i < lowerBound || upperBound < i);
}
private boolean isInsideRange(int i, int lowerBound, int upperBound) {
return (i < lowerBound && upperBound < i);
}
View RootUtil.java
public class RootUtil {
public static boolean isDeviceRooted() {
return checkRootMethod1() || checkRootMethod2() || checkRootMethod3();
}
private static boolean checkRootMethod1() {
String buildTags = android.os.Build.TAGS;
return buildTags != null && buildTags.contains("test-keys");
}
View take_and_resize_screenshot
function mytakescreenshoot() {
adb shell screencap -p | perl -pe 's/\x0D\x0A/\x0A/g' > screen.png sips -Z 640 screen.png
echo "Resized and saved in current folder as: screen.png"
}
@paddyzab
paddyzab / rename_for_android
Created Jan 31, 2015
Small script for cleaning resources for Android
View rename_for_android
#!/usr/bin/python
# -*- coding: iso-8859-15 -*-
import os
#Small script to change the names of the files
#containing dashes to replace them with underline
#Android asset manager cannot compile dashes, and
#sometimes it's easier to run the script than to
#bother designer to change.
View testingColors.class
private static void assertIsColorClose(TextView label, int textColor) {
int currentTextColor = label.getCurrentTextColor();
int currentRed = (currentTextColor >> 16) & 0xFF;
int currentGreen = (currentTextColor >> 8) & 0xFF;
int currentBlue = (currentTextColor >> 0) & 0xFF;
int expectedRed = (textColor >> 16) & 0xFF;
int expectedGreen = (textColor >> 8) & 0xFF;
int expectedBlue = (textColor >> 0) & 0xFF;
@paddyzab
paddyzab / pull_files
Last active Aug 29, 2015
Pull all png files from device through adb
View pull_files
#!/bin/bash
#Get all of a directory(sdcard), and filter them
for file in `adb shell ls /sdcard/Pictures/Screenshots/ | grep .png`
do
file=`echo -e $file | tr -d "\r\n"`;
# create the directory to store the files in your filesystem
mkdir -p ~/fetched_screenshots
View gist:54dc248b2d013c7861eb
Verifying that +patryk is my Bitcoin username. You can send me #bitcoin here: https://onename.io/patryk
View print_float
void lcdPrintFloat( float val, byte precision) {
// prints val on a ver 0012 text lcd with number of decimal places determine by precision
// precision is a number from 0 to 6 indicating the desired decimial places
// example: lcdPrintFloat( 3.1415, 2); // prints 3.14 (two decimal places)
if(val < 0.0){
lcd.print('-');
val = -val;
}
@paddyzab
paddyzab / install_on_multiple
Created Jul 20, 2014
Small shell script to install apk on multiple devices from adb
View install_on_multiple
#!/bin/bash
# Script adb+
# Usage
# You can run any command adb provides on all your currently connected devices
# ./adb+ <command> is the equivalent of ./adb -s <serial number> <command>
#
# Examples
# ./adb+ version
# ./adb+ install apidemo.apk
# ./adb+ uninstall com.example.android.apis