Skip to content

Instantly share code, notes, and snippets.

View mauiaaron's full-sized avatar

Aaron Culliney mauiaaron

View GitHub Profile
@mauiaaron
mauiaaron / backup.sh
Created July 24, 2015 17:15
Android backup to tarfile
adb backup -f SomeAndroidApp.ab com.example.SomeAndroidApp
dd if=SomeAndroidApp.ab bs=1 skip=24 | openssl zlib -d > SomeAndroidApp.tar
# TODO : investigate http://sourceforge.net/projects/adbextractor/
# TODO : investigate https://github.com/nelenkov/android-backup-extractor
@mauiaaron
mauiaaron / adb_sanitize.c
Last active August 29, 2015 14:22
Sanitize/convert CRLF -> LF for Android adb command
//
// Sigh ... adb shell changes LF to CRLF in binary streams ...
//
// http://stackoverflow.com/questions/13578416/read-binary-stdout-data-from-adb-shell
//
// Problem:
// ( adb shell run-as com.example.someapp dd if=/data/data/com.example.someapp/some_binfile.bin 2\>/dev/null ) > local_binfile.bin
//
// * Without piping through adb_sanitize you would get a corrupted binary
//
@mauiaaron
mauiaaron / gist:8550720
Created January 21, 2014 23:31
File Descriptor Counts on Linux
#ifndef NDEBUG
#include <string.h>
#include <stdio.h>
#include <dirent.h>
#include <fcntl.h>
#include <unistd.h>
#include <errno.h>
#include <sys/resource.h>
int _debug_get_num_fds() {
int fd_count = 0;
@mauiaaron
mauiaaron / gist:7105043
Created October 22, 2013 17:57
Workaround Android log limit
/*
Yes, 1024 is an internal limit of __android_log_print / __android_log_vprint functions which printf() uses. See https://github.com/android/platform_system_core/blob/master/liblog/logd_write.c
As a workaround I can suggest using custom printf function:
*/
#include <android/log.h>
void uprintf(const char* format, ...) {
va_list args;
@mauiaaron
mauiaaron / iOS_check_memory.c
Last active December 23, 2015 07:09
Checking available memory on iOS.
#include <stdio.h>
#include <mach/mach.h>
natural_t mach_getTotalBytes() {
static natural_t totalBytes=0;
if (totalBytes>0) {
return totalBytes;
}
mach_port_t host_port;