How to grep through (aka. find) binary files looking for a byte sequence (aka. pattern match)

Here's my approach using more or less standard Unix/Linux tools:
find . -type f -exec fgrep -aqs $'\x3c\x3f\x70' '{}' \; -print

If your shell does not support the $'\xHH' notation (eg. standard POSIX shell does not, but bash and zsh do), then you can always fall back to echo's octal representation (although it's a bit uncomfortable since most hexeditors and viewers support the hexadecimal format):
patt="$(/bin/echo '\074\077\160')"
find . -type f -exec fgrep -aqs "$patt" '{}' \; -print

iStat Pro Widget External IP Fix

Open the $HOME/Library/Widgets/iStat Pro.wdgt/scripts/core.js script in a text editor, find the getExtIP() function and replace the following line:
ipURL = 'http://whatsmyip.islayer.com/?random='+new Date().getTime();

with this (or a similiar "what's my ip" service URL):
ipURL = 'http://www.whatsmyip.us/showipsimple.php?random='+new Date().getTime();

And the following:
if(extIP.length < 20 && ipConnection.status == 200 && extIP.match(/\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/)){

With these:
ip_regex = "\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}";
if(extIP.length < 100000 && ipConnection.status == 200 && extIP.match(new RegExp(ip_regex))){
    extIP = extIP.replace(new RegExp("^(.*[^\\d])?(" + ip_regex + ")([^\\d].*)?$"), "$2");

This patch lets you use quite many "what's my IP" services since the the script will take the first IP looking string from the result of the HTTP request.

Manually running a media scan on Android

The problem is well known: if you make changes in to filesystem using a method that does not notify Media Storage, then browsing your device via MTP won't show the changes (eg. new files, etc.).

Adblock Plus for Android does not yet support ad filtering for HTTPS/SSL connections

Adblock Plus for Android (ABP) uses the proxy approach for ad blocking, i.e. a process is continuously running in the background, listens on a specific TCP port (which is 2020 nowadays) for proxy HTTP requests and processes them based on it's ad filtering rules. If you're phone/tablet is rooted, ABP can automatically route all outgoing traffic through it's proxy. If your device is not rooted and it's running a more recent (4.2.2 or newer) Android version, then you've to manually configure your network connection to use ABP's proxy. The essential problem with this approach is that it can only process plain/unencrypted HTTP connections, while today most services go through HTTPS (SSL encryption). Let it be Facebook, Google or even warez sites like The Pirate Bay. ABP for Android is of little to no use on these sites. The only possible solution in this case is an in-app ad blocker. The Android version of Firefox does let you install the ABP extension, which will block even ads served via HTTPS/SSL. So you've a choice, even though somewhat limited (since you cannot use the browser of your choice ... you've to use Firefox if you want to get rid of HTTPS ads).

How to programmatically enable and disable airplane/flight mode on Android 4.2+

Previously I wrote this other post about how to change system settings (like Airplane Mode) by directly manipulating the SQLite database file that stores them. It turns out that there's a better way.

Linux Command Cheat Sheet

A pretty nice compilation of some of the more important linux commands. Of course you'll need to get familiar with them to be of any use, but at least it's a good starting point for beginners.

smcFanControl

For a couple of months now I experienced sudden freezes. It turned out to be an overheating issue. I've moved into a new flat and here I use WiFi all the time (vs. the previous setup, where the Mac got network via UTP). Apparently the WiFi module (AirPort ... which is an Atheros AR5418 chip in my case) generates tons of extra heat (even with no traffic at all Shock) and the factory fan control does not account for it properly. Using smcFanControl I can increase the lower boundary of the fan speed and avoid overheating.

How to set the email account for event invitation replies in Thunderbird/Lightning

If you receive an event invitation (from an Exchange Server), Lightning lets you accept or decline it and offers to send an Event Invitation Reply. The problem is that the email account used for sending this reply is picked a bit differently than users would expect. The account can be set in the calendar's properties. However if a user gets invitations from multiple sources (via multiple email addresses) into the same calendar, you cannot tell it to reply using the same email account that received the invitation. You can set this only on a per calendar basis. What a pity.

How to impersonate ("become") a package on the commandline in Android

The /system/bin/run-as command lets you execute a shell or a package as the owner of the package. But you've to be root or use ADB to use it. And the package has to be debuggable and user owned (i.e. system apps cannot be impersonated like this).

Ldd for ARM cross-compiler

Using Sourcery CodeBench Lite you can quite easily cross-compile tons of open-source projects for Android. But sometimes regardless of all your efforts, the compiled binary contains library dependencies. To list these dependencies, we regularily use ldd. The cross-compiler does not have an ldd script, but we can work around that by executing this instead:
arm-none-linux-gnueabi-readelf -a my_cross-compiled_executable | fgrep "Shared library:"

Syndicate content Syndicate content